[Fixed] Incorrect date calculation in certain time zones
June 20, 2008 - 1:02pm — niko
| Project: | Date Input |
| Version: | 1.1.6 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Description
I don't know why but for March month 2009 dates are calculated incorrect. The calendar displays two days with "28". See attachment for example.
Also there is a bigger problem for April 2009 when start of week is "0" (Sunday)
Thank you for great calendar!
| Attachment | Size |
|---|---|
| April 2009.png | 2 KB |
| March 2009.png | 13.13 KB |
| March 2009.png | 13.13 KB |

Comments
#1
Sorry I'm not able to duplicate this at all. What browser are you using? Have you modified the plugin in any way?
#2
Please re-open if you still consider this to be an issue.
#3
Testing files - I included clean version 1.1.6 in a test file. See zip attached. - Bug with March, April months, when week starts on Sunday.
Browsers: Firefox 3, IE 7...
Thank you!
#4
I've downloaded your zip folder and run the test file in there - I still see no issue on my own computer. I don't know if this is possible, but perhaps there is something wrong with your computer's clock? Or perhaps it is affected by time zone somehow - what time zone are you in? Could you try it on a different time zone/computer?
Cheers
#5
You are right! it depends on time zone.
In GMT +2 there is this bug. in GMT -5 it's ok!
#6
Ok, this is very strange! I am not able to reproduce the bug on Linux (my usual platform), but under Windows, if I set the timezone to GMT +2, I see April 30th 2009 appear twice. I do not see March 28th 2009 appear twice, however.
I will look into it, though I can't promise how soon I will find the time.
#7
#8
Same thing here.
I'm in time zone GMT +2, and using version 1.1.6.
I found the same bug in March 1994. it shows the date 31 twice, and then you can't navigate further to April.
The problem occured in firefox 2.xx on Linux Mephis 6.5.
I tried to recreate it on IE6 and on Firefox 3.0.3 under Windows XP but in both platforms the date showed OK.
#9
Hi everybody.
This bug is related with math operations on Date functions. On single precision math, milliseconds diference makes date drop on previous day-number. To solve it just set current day at noon at line 84. Replace
var currentDay = new Date(rangeStart.getFullYear(), rangeStart.getMonth(), rangeStart.getDate() + i);for this
var currentDay = new Date(rangeStart.getFullYear(), rangeStart.getMonth(), rangeStart.getDate() + i,12,00);Still.. this don't solve everything.. one more thing is stringToDate function. Same call on Date at line 150.
return new Date(matches[3], this.shortMonthNum(matches[2]), matches[1]);goes to
return new Date(matches[3], this.shortMonthNum(matches[2]), matches[1],12,00);Thanks to jonleighton for this great calendar.
Regards
Arsenicus
#10
Thanks, I've committed this: http://github.com/jonleighton/date_input/commit/8931219512e91c4862b6b3eb...
Will make a new release shortly.
#11