[Editor 1.5.4] TimeZone bug with Date Picker
[Editor 1.5.4] TimeZone bug with Date Picker
Hello, it looks like there is a bug with the date picker when the client's browser is in certain time zones (i.e. UTC-5, UTC-8).
Here are the repro steps:
- Change your timezone to UTC-5 (Eastern Standard Time) or any time zone before UTC (UTC-X)
- Restart browser (so timezone changes take place)
- Go to the DatePicker Example
- Select 'New' and edit one of the date fields
- Select February 1st, 2016
- Edit the field again, and press the 'back one month' button
- The problem is that the month changes to January 2015 instead of January 2016
A similar problem occurs if you select December 1st, 2016. If you move one month ahead, it moves to January 2016 and not January 2017.
Note that if you select any day other than the first day of the month, there is no problem.
I think the bug is when Editor is converting dates to UTC. If you convert Feburary 1st, 2016 00h00 to UTC, it ends up being January 31st 19h00, 2016. The datepicker converts this back to Feb 1st. However if you subtract a month, you get Dec 31st 2015, and the datepicker takes that year even if it converts the day to Jan 1st.
Please let me know if you can repro, and if there are any workarounds that I could implement. Thanks!
This question has an accepted answers - jump to answer
Answers
Thanks for letting me know about this. I'll dig into this issue and post back first thing tomorrow.
Allan
Hi Allan,
I spent some more time with the code after I posted this and made 3 small edits that seem to fix the issue for me.
In dataTables.editor.js I changed lines 7040-7041 from:
to:
And I also changed the
this.s.display.getFullYear()
tothis.s.display.getUTCFullYear()
in the_setCalander
and_setTitle
functions.This works for me, but I'm not 100% sure if it works completely. I'd be interested to see if you come to the same solution. Thanks!
Hi,
Thanks for the update! I concur on all points. There was also one other
setFullYear
which needed to be updated to use UTC time.The fixes will be in Editor 1.5.5 which I expect to drop tomorrow.
Regards,
Allan