Closed
Bug 879261
Opened 11 years ago
Closed 7 years ago
javascript seems to be using time zones backwards
Categories
(Core :: JavaScript: Standard Library, defect)
Tracking
()
People
(Reporter: joseph, Unassigned)
References
Details
Attachments
(1 file)
61.84 KB,
image/png
|
Details |
User Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36 Steps to reproduce: I asked this question on stack overflow here (http://stackoverflow.com/questions/16903678/javascript-seems-to-be-using-time-zones-backwards-with-firefox) To summarize, I ran this code in console: new Date(1362891600000); var date = new Date(1362891600000); var time = date.getHours(); new Date(date.setHours(date.getHours() + 24)); Actual results: I got these results displayed with the first date having a time zone of EDT, and the second date having time zone of EST: http://i.stack.imgur.com/Zi6Dj.png Expected results: The time zone are backwards, the first date should have been EST and the second EDT
Updated•11 years ago
|
Component: Untriaged → Internationalization
Product: Firefox → Core
Possible duplicate of Bug 886410. This bug only appears to manifest on Windows. (Tested Firefox 23.0 on both Windows and Mac, and the problem only appears to happen in Windows.)
Comment 2•10 years ago
|
||
This still occurs on FF30.0 for Windows. new Date(2014,0,1).toString() Wed Jan 01 2014 00:00:00 GMT-0800 (Pacific Daylight Time) new Date(2014, 7, 1).toString() Fri Aug 01 2014 00:00:00 GMT-0700 (Pacific Standard Time) The offset are correct, but the names are reversed.
1.) bug 886410 and bug 912710 are probably dupes. 2.) "Internationalization"? Why? This got nothing to do with locales. 3.) This seems to only be broken when the machine is in a "Daylight Time"-phase. E.g. setting the date to January 1st (Standard Time for northern hemisphere) and trying the examples above and from the other two bugs show the proper strings. 4.) Regression-range: Last good revision: 8592c41069c2 (2013-01-11) First bad revision: 1761f4a9081c (2013-01-12) Pushlog: http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=8592c41069c2&tochange=1761f4a9081c Maybe bug 827816? Also maybe 828567, but I don't know if it applies. Testsite I used for testing: http://jsfiddle.net/cfrsj384/
Flags: needinfo?(amarchesini)
Comment 4•10 years ago
|
||
(In reply to Matt Johnson from comment #2) > This still occurs on FF30.0 for Windows. > > new Date(2014,0,1).toString() > Wed Jan 01 2014 00:00:00 GMT-0800 (Pacific Daylight Time) > > new Date(2014, 7, 1).toString() > Fri Aug 01 2014 00:00:00 GMT-0700 (Pacific Standard Time) > > The offset are correct, but the names are reversed. Regression window(m-i) Good: http://hg.mozilla.org/integration/mozilla-inbound/rev/855363cef324 Mozilla/5.0 (Windows NT 6.2; WOW64; rv:21.0) Gecko/20130110 Firefox/21.0 ID:20130110145709 Bad: http://hg.mozilla.org/integration/mozilla-inbound/rev/51c998dda383 Mozilla/5.0 (Windows NT 6.2; WOW64; rv:21.0) Gecko/20130110 Firefox/21.0 ID:20130110155807 Pushlog: http://hg.mozilla.org/integration/mozilla-inbound/pushloghtml?fromchange=855363cef324&tochange=51c998dda383 Suspect: 5a88ed3a3ace Andrea Marchesini — Bug 827816 - Wrong timezone offset for UK and Ireland as they had year-round DST from 1969-1971, r=brendan, r=gal
Updated•10 years ago
|
status-firefox32:
--- → affected
status-firefox33:
--- → affected
status-firefox34:
--- → affected
status-firefox35:
--- → affected
status-firefox-esr31:
--- → affected
Comment 5•10 years ago
|
||
That code has been fully rewritten by waldo. I'm happy to help, but first I want to see what waldo thinks about this issue.
Flags: needinfo?(amarchesini) → needinfo?(jwalden+bmo)
Comment 8•9 years ago
|
||
I dont know if I am facing with the same bug, but in my case toString() produces correct result, yet toLocaleString() and toLocaleDateString() are producing wrong result. Here is my test code: >>> <html> <p id="tz"></p> <script type="text/javascript"> document.getElementById("tz").innerHTML = 'toString(): ' + new Date().toString() + '<br>' + 'toLocaleString(): ' + new Date().toLocaleString() + '<br>' + 'toLocaleDateString(): ' + new Date().toLocaleDateString() + '<br>' + 'getTimezoneOffset(): ' + new Date().getTimezoneOffset() / 60; </script> </html> <<< And here is result (note 1 hour difference): >>> toString(): Sat Feb 14 2015 00:32:14 GMT+0300 (Russia TZ 2 Standard Time) toLocaleString(): 14.02.2015, 1:32:14 toLocaleDateString(): 14.02.2015 getTimezoneOffset(): -3 <<<
Comment 9•9 years ago
|
||
I can reproduce this on Windows 7 x64, but not Linux Mint KDE 17.1. Steps to reproduce: 1. Paste the following into the location bar, then press Enter: data:text/html,<script>alert(new Date());</script> Actual results: If DST is in effect, the alert box says, “Standard Time”. If DST is not in effect, the alert box says, “Daylight Time”. Expected results: If DST is in effect, the alert box should say, “Daylight Time”. If DST is not in effect, the alert box should say, “Standard Time”. Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:40.0) Gecko/20100101 Firefox/40.0 Built from https://hg.mozilla.org/mozilla-central/rev/eb3a1c0262e4 Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0 Built from https://hg.mozilla.org/mozilla-central/rev/0a46652bd992
Updated•9 years ago
|
Component: Internationalization → JavaScript: Standard Library
Comment 12•9 years ago
|
||
(In reply to Andrea Marchesini (:baku) 2014-09-23 07:38:11 PDT from comment #5) > That code has been fully rewritten by waldo. I'm happy to help, but first I > want to see what waldo thinks about this issue.
Flags: needinfo?(amarchesini)
Comment 13•8 years ago
|
||
DST is back in the northern hemisphere, and so is this bug.
Comment 17•8 years ago
|
||
This bug was pointed out to me by a web developer. His application worked correctly for IE, Edge, Chrome, and Safari, but was breaking on Firefox because of this bug. (He will code around it.) There have been two needinfo requests open for two years, maybe we should give up on those requests.
OS: Windows 8 → Windows
Comment 18•8 years ago
|
||
I am encountering this problem on FF 47.0 on Windows 7 Enterprise SP 1, 64-bit. It is causing times to be displayed incorrectly in my web app. Please fix!
Comment 19•8 years ago
|
||
We have this problem on a Windows 7 x64 Enterprise computer. var d = new Date(1476428709 * 1000); alert(d); Firefox: Fri Oct 14 2016 03:05:09 GMT-0400 (Eastern Standard Time). valueOf: 1476428709000 Chrome: Fri Oct 14 2016 03:05:09 GMT-0400 (Eastern Daylight Time). valueOf: 1476428709000 yet I noticed if I pick a date not in daylight saving time: var d = new Date(1452400000 * 1000); alert(d); Firefox: Sat Jan 09 2016 23:26:40 GMT-0500 (Eastern Daylight Time). valueOf: 1452400000000 Chrome: Sat Jan 09 2016 23:26:40 GMT-0500 (Eastern Standard Time). valueOf: 1452400000000 Ref my stackoverflow question: http://stackoverflow.com/questions/40051721/bad-javascript-date-timestamps-from-epoch-in-firefox This has bug has open for years with no traction; is there someone else with Mozilla that can take a look?
Flags: needinfo?(bob)
Comment 20•8 years ago
|
||
IIRC the patch in bug 830304 (currently pending review) fixes this issue.
Comment 21•8 years ago
|
||
(In reply to André Bargull from comment #20) > IIRC the patch in bug 830304 (currently pending review) fixes this issue. Thank you for that information. I downloaded from your try builds folder and tested the build, and it does fix the issue here. I tested several of the epochs we have and also the OP's epochs. var d = new Date(1362891600000); alert(d); Sun Mar 10 2013 00:00:00 GMT-0500 (Eastern Standard Time) var d = new Date(1362891600000); d.setHours(d.getHours() + 24); alert(d); Mon Mar 11 2013 00:00:00 GMT-0400 (Eastern Daylight Time) If anyone wants to try the build it's here: https://ftp.mozilla.org/pub/firefox/try-builds/andre.bargull@gmail.com-58477b66af97127f02063372492e915ae0816189/try-win32/firefox-52.0a1.en-US.win32.zip
Flags: needinfo?(bob)
Comment 23•7 years ago
|
||
Fixed in https://hg.mozilla.org/mozilla-central/rev/b7ef07909cc4 Before (Win10): new Date(1362891600000).toString() "Sun Mar 10 2013 00:00:00 GMT-0500 (Eastern Daylight Time)" d = new Date(1362891600000); new Date(d.setHours(d.getHours() + 24)).toString() "Mon Mar 11 2013 00:00:00 GMT-0400 (Eastern Standard Time)" After (Win10): new Date(1362891600000).toString() "Sun Mar 10 2013 00:00:00 GMT-0500 (Eastern Standard Time)" d = new Date(1362891600000); new Date(d.setHours(d.getHours() + 24)).toString() "Mon Mar 11 2013 00:00:00 GMT-0400 (Eastern Daylight Time)"
Status: NEW → RESOLVED
Closed: 7 years ago
Flags: needinfo?(jwalden+bmo)
Flags: needinfo?(amarchesini)
Resolution: --- → FIXED
Updated•7 years ago
|
Keywords: regression
You need to log in
before you can comment on or make changes to this bug.
Description
•