Closed Bug 637244 Opened 14 years ago Closed 6 years ago

Date created during the period of daylight saving time

Categories

(Core :: JavaScript Engine, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1346211

People

(Reporter: version.ru, Unassigned)

References

Details

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13 Build Identifier: "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13" >>> d = new Date("1942-03-01T00:00:00") Sun Mar 01 1942 00:00:00 GMT+0700 (NOVT) {} >>> d.setMonth(3); // set To April -875865600000 >>> d Tue Mar 31 1942 23:00:00 GMT+0700 (NOVT) {} // wrong! also: >>> d = new Date("Oct 31 2010") Sun Oct 31 2010 00:00:00 GMT+0700 (NOVT) {} >>> d.setMonth(10); // set to Nov. 1291140000000 >>> d Wed Dec 01 2010 00:00:00 GMT+0600 (NOVT) {} // wrong! Also tickets on some problem: Reproducible: Always See also bugs: https://bugzilla.mozilla.org/show_bug.cgi?id=610185 https://bugzilla.mozilla.org/show_bug.cgi?id=608603
Whats the regression range on this?
>>> new Date('Apr 1 1942'); Tue Mar 31 1942 23:00:00 GMT+0700 (NOVT) {}
Sorry, I meant does this work with Firefox 3.6? Did this break recently?
Bug affected Firefox v3.6.13. I just found this bug recently. (fyi, i'm not native english speaker)
More cases in script (used google closure library): for (var y = 1940; y <=2014; y++) { for (var m = 0; m < 12; m++) { var numDays = goog.date.getNumberOfDaysInMonth(y, m); for (var d = 1; d <= numDays; d++) { var date = new Date(y, m, d); if (date.getMonth() != m) { console.warn('Incorrect date:', date); } } } } Ouput: Incorrect date: Tue Mar 31 1903 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 1914 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 1925 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Sat Mar 31 1928 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 1931 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 1942 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 1953 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Sat Mar 31 1956 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 1959 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 1981 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Wed Mar 31 1982 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Thu Mar 31 1983 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Sat Mar 31 1984 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Sat Mar 31 2040 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 2043 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 2054 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 2065 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Sat Mar 31 2068 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 2071 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 2082 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 2093 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Sat Mar 31 2096 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 2099 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 2105 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Sat Mar 31 2108 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 2111 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 2122 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 2133 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Sat Mar 31 2136 23:00:00 GMT+0700 (NOVT) {} Incorrect date: Tue Mar 31 2139 23:00:00 GMT+0700 (NOVT) {}
Sorry, year range is not actual for output, year range for current output is [1900; 2142]
Using the testcases in comment 0, I can't reproduce the April issue. I _can_ reproduce the Novemeber, issue, but that behavior is correct. The date starts off as October 31, then the month is set to November. But there is no November 31, so ES5 section 15.9.1.12 will end up returning Dec 1 for the day.
An interesting question: In your locale, does daylight savings time start on the night from March 31 to April 1?
In Russia, for daylight saving time is carried out on the last Sunday of March (in 2010 - 28 March, 2011 - March 27). On this day, at two o'clock arrow takes one hour ahead. andrey@deus:~$ echo $LANG ru_RU.utf8
Summary: Date.setMonth works incorrect → Date created during the period of daylight saving time
Jeff, you know about this DST stuff, right?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Google Chrome: >>>new Date('Sun Apr 01 1984 00:00:00 GMT+0700 (NOVST)') Sun Apr 01 1984 00:00:00 GMT+0700 (NOVST) Firefox: >>> new Date('Sun Apr 01 1984 00:00:00 GMT+0700 (NOVST)') Sun Apr 01 1984 01:00:00 GMT+0800 (NOVT) {} Personally, I see no reason why the browser to change the GMT from the specified and, again, shift the time forward one hour. That is, in my humble opinion, Google Chrome is behaving correctly with the date.
I was wrong at the expense of Google Chrome: >>> new Date('March 1 1984 GMT+0600') Thu Mar 01 1984 00:00:00 GMT+0600 (NOVT) >>> new Date('March 1 1984 GMT+0700') Wed Feb 29 1984 23:00:00 GMT+0600 (NOVT) Most likely there are no bugs here.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → INVALID
No, Chrome just displays the date in the current GMT. Firefox: >>> new Date(1984, 3, 1) Sat Mar 31 1984 23:00:00 GMT+0700 (NOVT) {} >>> new Date(1984, 3, 1).toUTCString() "Sat, 31 Mar 1984 16:00:00 GMT" >>> new Date(1984, 3, 1).getTime() 449596800000 >>> new Date('Apr 1 1942') Tue Mar 31 1942 23:00:00 GMT+0700 (NOVT) {} Google Chrome: >>> new Date(1984, 3, 1) Sun Apr 01 1984 00:00:00 GMT+0700 (NOVST) >>> new Date(1984, 3, 1).toUTCString() "Sat, 31 Mar 1984 17:00:00 GMT" >>> new Date(1984, 3, 1).getTime() 449600400000 >>> new Date('Apr 1 1942') Wed Apr 01 1942 00:00:00 GMT+0700 (NOVST) Where is use case to test: var year = 1942; var month = 3; var date = 1; var d = new Date(year, month, date); if (d.getMonth() != month) { console.warn('Incorrect behavior:', d) } else { console.info('ok'); }
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
I think that is normal behavior is that if the constructor of the Date object passing the specified year, month and day in their locale, the output methods getFullYear (), getMonth () and getDate () should return results relevant to the arguments passed to the constructor
In addition on Windows XP (locale=ru) Firefox work properly: >>> new Date(1984, 3, 1) Sun Apr 01 1984 00:00:00 GMT+0700 {}
Assignee: general → nobody
It seems like the date calculation just can't turn the hour back over the day boundary correctly. >>> var d = new Date(2040,2,31,20) >>> console.log(d.toLocaleString(), d.getDate(), d.getHours(), >>> d.getTimezoneOffset()) >>> for (var i = 0; i < 6; i++) { >>> d.setHours(d.getHours() + 2) >>> console.log(d.toLocaleString(), d.getDate(), d.getHours(), >>> d.getTimezoneOffset()) >>> } >>> Sat Mar 31 2040 20:00:00 GMT+0300 (EEST) 31 20 -180 >>> Sat Mar 31 2040 22:00:00 GMT+0300 (EEST) 31 22 -180 >>> Sat Mar 31 2040 23:00:00 GMT+0300 (EEST) 31 23 -180 >>> Sun Apr 01 2040 01:00:00 GMT+0400 (EEST) 1 1 -240 >>> Sun Apr 01 2040 03:00:00 GMT+0400 (EEST) 1 3 -240 >>> Sun Apr 01 2040 05:00:00 GMT+0400 (EEST) 1 5 -240 >>> Sun Apr 01 2040 07:00:00 GMT+0400 (EEST) 1 7 -240 Tested with Can this be just improperly set up daylight saving data? It usually happens at 3 in the morning or something similar.
According to theory, during the shift to DST, the clock jumps over one hour. For instance, from 27 Mar 2016 02:59 EET, it should advance to 27 Mar 2016 04:00 EET. A moment such as 27 Mar 2016 03:20 EET does not exist and Chrome, IE or java interpret it as 27 Mar 2016 04:20 EET, on the rationale that you obtain it by adding 21 minutes to 02:59. However, in FF 43.0.4 for Mac I get the following result in the Firebug console: > new Date(2016,2,27,2,59) > Date {Sun Mar 27 2016 02:59:00 GMT+0200 (EET)} > new Date(2016,2,27,3,0) > Date {Sun Mar 27 2016 02:00:00 GMT+0200 (EET)} Is there a logical explanation for the behavior or is it a bug?
Blocks: 285663
Dup'ing forward to bug 1346211 which should have fixed this problem. Please reopen if the issue is still present. Thanks!
Status: REOPENED → RESOLVED
Closed: 14 years ago6 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.