Fixed time zone issues with date.
This commit is contained in:
parent
a4e91f94e2
commit
09063dd611
1 changed files with 17 additions and 18 deletions
|
@ -292,11 +292,11 @@ class App.ControllerForm extends App.Controller
|
||||||
unixtime = new Date( Date.parse( "#{attribute.value}T00:00:00Z" ) )
|
unixtime = new Date( Date.parse( "#{attribute.value}T00:00:00Z" ) )
|
||||||
else
|
else
|
||||||
unixtime = new Date( attribute.value )
|
unixtime = new Date( attribute.value )
|
||||||
year = unixtime.getYear() + 1900
|
year = unixtime.getUTCFullYear()
|
||||||
month = unixtime.getMonth() + 1
|
month = unixtime.getUTCMonth() + 1
|
||||||
day = unixtime.getDate()
|
day = unixtime.getUTCDate()
|
||||||
hour = unixtime.getHours()
|
hour = unixtime.getUTCHours()
|
||||||
minute = unixtime.getMinutes()
|
minute = unixtime.getUTCMinutes()
|
||||||
item = $( App.view('generic/date')(
|
item = $( App.view('generic/date')(
|
||||||
attribute: attribute
|
attribute: attribute
|
||||||
year: year
|
year: year
|
||||||
|
@ -322,10 +322,10 @@ class App.ControllerForm extends App.Controller
|
||||||
time = new Date( Date.parse( "#{year}-#{format(month)}-#{format(day)}T00:00:00Z" ) )
|
time = new Date( Date.parse( "#{year}-#{format(month)}-#{format(day)}T00:00:00Z" ) )
|
||||||
else
|
else
|
||||||
time = new Date()
|
time = new Date()
|
||||||
time.setMinutes( time.getMinutes() + diff + time.getTimezoneOffset() )
|
#time.setMinutes( time.getMinutes() + diff + time.getTimezoneOffset() )
|
||||||
item.closest('.form-group').find("[name=\"{date}#{name}___day\"]").val( time.getDate() )
|
item.closest('.form-group').find("[name=\"{date}#{name}___day\"]").val( time.getUTCDate() )
|
||||||
item.closest('.form-group').find("[name=\"{date}#{name}___month\"]").val( time.getMonth()+1 )
|
item.closest('.form-group').find("[name=\"{date}#{name}___month\"]").val( time.getUTCMonth()+1 )
|
||||||
item.closest('.form-group').find("[name=\"{date}#{name}___year\"]").val( time.getFullYear() )
|
item.closest('.form-group').find("[name=\"{date}#{name}___year\"]").val( time.getUTCFullYear() )
|
||||||
|
|
||||||
item.find('.js-today').bind('click', (e) ->
|
item.find('.js-today').bind('click', (e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
@ -430,7 +430,7 @@ class App.ControllerForm extends App.Controller
|
||||||
unixtime = new Date( Date.parse( attribute.value ) )
|
unixtime = new Date( Date.parse( attribute.value ) )
|
||||||
else
|
else
|
||||||
unixtime = new Date( attribute.value )
|
unixtime = new Date( attribute.value )
|
||||||
year = unixtime.getYear() + 1900
|
year = unixtime.getFullYear()
|
||||||
month = unixtime.getMonth() + 1
|
month = unixtime.getMonth() + 1
|
||||||
day = unixtime.getDate()
|
day = unixtime.getDate()
|
||||||
hour = unixtime.getHours()
|
hour = unixtime.getHours()
|
||||||
|
@ -2328,8 +2328,8 @@ class App.ControllerForm extends App.Controller
|
||||||
year = param[ "#{dateKey}year" ]
|
year = param[ "#{dateKey}year" ]
|
||||||
month = param[ "#{dateKey}month" ]
|
month = param[ "#{dateKey}month" ]
|
||||||
day = param[ "#{dateKey}day" ]
|
day = param[ "#{dateKey}day" ]
|
||||||
timezone = (new Date()).getTimezoneOffset()/60
|
|
||||||
if lookupForm.find('[data-name="' + namespace[0] + '"]').hasClass('is-hidden')
|
if lookupForm.find('[data-name = "' + namespace[0] + '"]').hasClass('is-hidden')
|
||||||
param[ namespace[0] ] = null
|
param[ namespace[0] ] = null
|
||||||
else if year && month && day && day
|
else if year && month && day && day
|
||||||
format = (number) ->
|
format = (number) ->
|
||||||
|
@ -2340,8 +2340,7 @@ class App.ControllerForm extends App.Controller
|
||||||
time = new Date( Date.parse( "#{year}-#{format(month)}-#{format(day)}T00:00:00Z" ) )
|
time = new Date( Date.parse( "#{year}-#{format(month)}-#{format(day)}T00:00:00Z" ) )
|
||||||
if time && time.toString() is 'Invalid Date'
|
if time && time.toString() is 'Invalid Date'
|
||||||
throw "Invalid Date #{year}-#{format(month)}-#{format(day)}"
|
throw "Invalid Date #{year}-#{format(month)}-#{format(day)}"
|
||||||
time.setMinutes( time.getMinutes() + time.getTimezoneOffset() )
|
param[ namespace[0] ] = "#{time.getUTCFullYear()}-#{format(time.getUTCMonth()+1)}-#{format(time.getUTCDate())}"
|
||||||
param[ namespace[0] ] = "#{time.getFullYear()}-#{format(time.getMonth()+1)}-#{format(time.getDate())}"
|
|
||||||
catch err
|
catch err
|
||||||
param[ namespace[0] ] = undefined
|
param[ namespace[0] ] = undefined
|
||||||
console.log('ERR', err)
|
console.log('ERR', err)
|
||||||
|
@ -2366,7 +2365,7 @@ class App.ControllerForm extends App.Controller
|
||||||
day = param[ "#{datetimeKey}day" ]
|
day = param[ "#{datetimeKey}day" ]
|
||||||
hour = param[ "#{datetimeKey}hour" ]
|
hour = param[ "#{datetimeKey}hour" ]
|
||||||
minute = param[ "#{datetimeKey}minute" ]
|
minute = param[ "#{datetimeKey}minute" ]
|
||||||
timezone = (new Date()).getTimezoneOffset()/60
|
|
||||||
if lookupForm.find('[data-name="' + namespace[0] + '"]').hasClass('is-hidden')
|
if lookupForm.find('[data-name="' + namespace[0] + '"]').hasClass('is-hidden')
|
||||||
param[ namespace[0] ] = null
|
param[ namespace[0] ] = null
|
||||||
else if year && month && day && hour && minute
|
else if year && month && day && hour && minute
|
||||||
|
|
Loading…
Reference in a new issue