trentrichardson / jQuery-Timepicker-Addon

Adds a timepicker to jQueryUI Datepicker
http://trentrichardson.com/examples/timepicker/
MIT License
2.66k stars 1.05k forks source link

jQuery-Timepicker-Addon-1.5.5 setDate with different selected timezone from localtimezone set incorrectly #825

Open iamtennislover opened 9 years ago

iamtennislover commented 9 years ago

I am pretty sure this is a bug, Basically, my browser/local is in (-300 minutes offset from UTC, Mountain) MST timezone. I have a simple datetimepicker with timezoneList only in CDT (Centra, -300 minutes offset from UTC).

$('#timezone_example_2').datetimepicker({
    timeFormat: 'HH:mm z',
    timezoneList: [ 
            //{ value: -360, label: 'MST' }, / my local timezone
            { value: -300, label: 'CDT' }
        ]
});

Now, when I call setDate 1st time, the timer is set to current timestamp as localtimezone (this is expected and this is what I want);

However, when I call setDate 2nd time, the timer gets incorrectly set to 1 hour behind localtimezone

> Date()                                                            // This is my current timezone with current timestamp
> "Wed Jun 24 2015 11:33:05 GMT-0600 (Mountain Daylight Time)"
> $('#timezone_example_2').datetimepicker('getDate')                // as you can see, no timeset to #timezone_example_2
> null
> $('#timezone_example_2').datetimepicker('setDate', new Date())    // 1st time setting to #timezone_example_2 causes it to set to "06/24/2015 11:33 -0500"
> []
> $('#timezone_example_2').datetimepicker('getDate')
> Wed Jun 24 2015 10:33:00 GMT-0600 (Mountain Daylight Time)
> $('#timezone_example_2').datetimepicker('setDate', new Date())    // 2nd time setting to #timezone_example_2 causes it to set to "06/24/2015 10:33 -0500" (This is not correct. It should be set to 06/24/2015 12:33 -0500 as current timestamp is 06/24/2015 11:33 -0600)
> []
> $('#timezone_example_2').datetimepicker('getDate')
> Wed Jun 24 2015 09:33:00 GMT-0600 (Mountain Daylight Time)
> new Date()
> Wed Jun 24 2015 11:33:40 GMT-0600 (Mountain Daylight Time)