diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index 0f6752308..b7702955b 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -320,12 +320,13 @@ class App.ControllerForm extends App.Controller number if !reset && (year isnt '' && month isnt '' && day isnt '') time = new Date( Date.parse( "#{year}-#{format(month)}-#{format(day)}T00:00:00Z" ) ) + time.setMinutes( time.getMinutes() + diff + time.getTimezoneOffset() ) else time = new Date() - #time.setMinutes( time.getMinutes() + diff + time.getTimezoneOffset() ) - item.closest('.form-group').find("[name=\"{date}#{name}___day\"]").val( time.getUTCDate() ) - item.closest('.form-group').find("[name=\"{date}#{name}___month\"]").val( time.getUTCMonth()+1 ) - item.closest('.form-group').find("[name=\"{date}#{name}___year\"]").val( time.getUTCFullYear() ) + time.setMinutes( time.getMinutes() + diff ) + item.closest('.form-group').find("[name=\"{date}#{name}___day\"]").val( time.getDate() ) + item.closest('.form-group').find("[name=\"{date}#{name}___month\"]").val( time.getMonth()+1 ) + item.closest('.form-group').find("[name=\"{date}#{name}___year\"]").val( time.getFullYear() ) item.find('.js-today').bind('click', (e) -> e.preventDefault() @@ -462,9 +463,10 @@ class App.ControllerForm extends App.Controller number if !reset && (year isnt '' && month isnt '' && day isnt '' && hour isnt '' && day isnt '') time = new Date( Date.parse( "#{year}-#{format(month)}-#{format(day)}T#{format(hour)}:#{format(minute)}:00Z" ) ) + time.setMinutes( time.getMinutes() + diff + time.getTimezoneOffset() ) else time = new Date() - time.setMinutes( time.getMinutes() + diff + time.getTimezoneOffset() ) + time.setMinutes( time.getMinutes() + diff ) #console.log('T', time, time.getHours(), time.getMinutes()) item.closest('.form-group').find("[name=\"{datetime}#{name}___day\"]").val( time.getDate() ) item.closest('.form-group').find("[name=\"{datetime}#{name}___month\"]").val( time.getMonth()+1 ) diff --git a/public/assets/tests/form-validation.js b/public/assets/tests/form-validation.js index 6c3b4bb7f..8a9dd6884 100644 --- a/public/assets/tests/form-validation.js +++ b/public/assets/tests/form-validation.js @@ -248,4 +248,84 @@ test( "date validation check", function() { equal( el.find('[data-name="date1"]').closest('.form-group').hasClass('has-error'), true, 'check date1 has-error') equal( el.find('[data-name="date1"]').closest('.form-group').find('.help-inline').text(), '', 'check date1 error message') +}); + +test( "datetime selector check", function() { + + $('#forms').append('