#5440 closed defect (worksforme)
dojo.date.add() calculations don't respect time zones properly
Reported by: | guest | Owned by: | Bryan Forbes |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Date | Version: | 1.0 |
Keywords: | Cc: | grzegon@… | |
Blocked By: | Blocking: |
Description
I encounter a strange problem. Having _Calendar widget for December 2007 printed out, once I click on 1-DEC-2007, both 1-DEC-2007 and 1-JAN-2008 become selected (dijitCalendarSelectedDate).
I've done some debugging (you might find this helpful):
I've inspected what happens when printing dates in _populateGrid of _Calendar, especially for dates in next month (JAN-2008):
After _Calendar.js:82, var date = new Date(month);
the date is:
date.toString()
= "Sat Dec 01 2007 00:00:00 GMT+0100 (Central European Standard Time)"date.toUTCString()
= "Fri, 30 Nov 2007 23:00:00 GMT"date.getTime()
= 1196463600000
Then let's assume adj = 1
in the if-branch (_Calendar.js:85-96). And then happens: date = dojo.date.add(date, "month", adj);
(_Calendar.js:99). And after that the value is:
date.toString()
= "Mon Dec 31 2007 00:00:00 GMT+0100 (Central European Standard Time)"date.toUTCString()
= "Sun, 30 Dec 2007 23:00:00 GMT"date.getTime()
= 1199055600000
Which seems wrong to me. In consequence when printing first 5 days for JAN-2008 it iterates between 1-DEC-2007 and 5-DEC-2007, because date.setDate(1) returns 1-DEC-2007, not 1-JAN-2008. (NB: for previous month dates it iterates over OCT-2007, not NOV-2007)
Some additional info:
- dojo.date.getTimezoneName(new Date()) = "Central European Standard Time"
- dojo version is 1.0.2
If you need some more information, please let me know.
Change History (10)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
A workaround would be to follow this:
dojo.date.add(new Date(2007,11,1,12,0,0), "month",1) = Tue Jan 01 2008 12:00:00 GMT+0100 (Central European Standard Time)
comment:3 Changed 12 years ago by
Milestone: | → 1.0.3 |
---|---|
Owner: | changed from Adam Peller to Bryan Forbes |
Priority: | normal → high |
severity: | normal → major |
Sounds related to the UTC date patch #5315 that went into 1.0.2. Bryan, can you take a look?
comment:4 Changed 12 years ago by
I need to know two things before I can really diagnose (and replicate) this bug:
- What OS and browser you are using.
- What timezone you are using in your OS configuration (I couldn't find a timezone that output Central European Standard Time in Firefox).
Using Firefox in Ubuntu 7.10 and the following timezones, I get these results:
America/Chicago (CST): >>> new Date(2007,11,1) Sat Dec 01 2007 00:00:00 GMT-0600 (CST) >>> dojo.date.add(new Date(2007,11,1), "month", 1) Tue Jan 01 2008 00:00:00 GMT-0600 (CST) Europe/Berlin (CET): >>> new Date(2007,11,1) Sat Dec 01 2007 00:00:00 GMT+0100 (CET) >>> dojo.date.add(new Date(2007,11,1), "month", 1) Tue Jan 01 2008 00:00:00 GMT+0100 (CET)
comment:5 Changed 12 years ago by
Hi,
Originally I had observed the problem on Windows XP EN, 32-bit, Firefox 2.0.x, locale: Poland (I will try to give you the exact details tomorrow). Now I am sitting in front of Firefox on Ubuntu 7.10 as well, 2.6.22-14-generic, and I can only confirm that here it's OK.
Regards, Grzegorz Oledzki
comment:6 Changed 12 years ago by
Hm... At the moment I can't reproduce the problem either. Hmmm. I'll come back to you as soon as I am able to reproduce it myself. I am sure the problem had really taken place, because I've been pasting the outputs directly from the browser.
FYI: I use Windows XP Pro, Version 2002, Service Pack 2, and "Date and time" settings (in Systray | Clock | Adjust Date and Time) report "Current time zone: Central European Standard Time". Time zone chosen is "(GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb". Firefox is "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11".
comment:7 Changed 12 years ago by
For last couple of weeks the problem has not re-appeared in our application, although we're still using the same Dojo (1.0.2), and the same components. I guess I must've been doing something wrong. I think you can close this ticket. Thanks anyway...
Regards, Grzegorz Olędzki
comment:8 Changed 12 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
ugh. this timezone stuff makes me nervous. we did make a fix in 1.1 to use the date constructor once and not use the accessors. this seems to help with some odd cases, but mostly where historical cases are a problem (like initially setting a date to 1972 then changing the year, and problems with daylight savings)
do let us know if anything comes up
Even a simpler example would be:
which it's not a problem for me, but _Calendar expects something else. I can only guess that's more a
dojo/date.js
issue, rather thandijit._Calendar
.