Closed Bug 1233809 Opened 9 years ago Closed 6 years ago

Daylight Savings Time Displays the Wrong Date in JavaScript on Windows

Categories

(Core :: JavaScript Engine, defect)

46 Branch
All
Windows
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 1346211

People

(Reporter: ememisya, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Linux; Android 4.4.2; SCH-I535 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36

Steps to reproduce:

March 10 1980 is shown as GMT -04:00 for Firefox on Windows while Firefox on Unix systems display GMT -05:00.  This bug effects all versions of Firefox.  Tested on Windows 7, 8.1 & 10.

The issue may be reproduced from the JavaScript link below:

https://jsfiddle.net/Lguc3v7d/

This is likely related to the 2005 change to the U.S. Daylight Savings Time and Firefox getting post 2005 policy for the above date.


Actual results:

On Windows only, GMT-04:00 is displayed for a JavaScript Date object set to March 10 1980


Expected results:

The Date object should have displayed GMT-05:00
Severity: normal → critical
OS: Unspecified → Windows
Hardware: Unspecified → All
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Any update on this?

Further details: Historical daylight savings time modifications aren't reflected with Firefox on Windows OS (seems to effect all versions). new Date()).getTime() epoch time value of 12:00AM March 10 1980 goes out as March 9 11:00PM 1980 on Eastern Daylight Savings (North America) since the most recent DST policy is applied and not the one which was on 1980.
I see a similar output in Chrome 47 and IE 11, so I'm not sure it is a real bug.
Blocks: 285663
Severity: critical → normal
To test this, you'll need a Firefox on Linux (Let's say Debian), and a Firefox on Windows (Let's say Win10).  Set both time zones to Eastern Time (North America) on both machines and run firefox (v43+ will do fine).

Browse to https://jsfiddle.net/Lguc3v7d/ on these environments and you'll notice that the same code (as simple as new Date()) will produce two different outputs.  You can further confirm this by outputting .getTimezoneOffset() where on one machine (Windows) it will be 240 and the other (Linux) 300.  Reason for this is historically DST started on April 27 1980 (last Sunday) whereas given the most current law in the Eastern Standard Time zone (2007 onward) it starts on the second Sunday of March.

Therefore the Windows implementation is incorrect.

I've temporarily patched this issue (until the bug is resolved) in my code by overriding the Date object on the script level (with a major performance hit as it is no longer native code):

_DefaultDateConstructor = Date.prototype.constructor,
function CustomDate() {
  if (arguments.length === 1) {
    this._internalDate = new _DefaultDateConstructor(arguments[0]);
  }
...
  this.instanceIsInEDT = isInEDT(this._internalDate);
  if (!Number.isNaN(this._internalDate.getTime())) {
    if (this.instanceIsInEDT && this._internalDate.getTimezoneOffset() === 300) {
      console.debug("DETECTED BROKEN EST DST!  Fixing instance by removing an hour...");
      this._internalDate.setTime(this._internalDate.getTime() - (1 * 60 * 60 * 1000));
      this._internalDate.getTimezoneOffset = function () {
        return 240;
      };
...
}
Date = CustomDate;
Date.prototype.constructor = Date;

However it needs to be fixed in the source.  I'll go ahead and checkout Firefox source and find out which line needs to be changed if it helps.
Severity: normal → critical
Turns out (In reply to YF (Yang) from comment #2)
> I see a similar output in Chrome 47 and IE 11, so I'm not sure it is a real
> bug.

I just went ahead and ran the test code in Chrome 47, and you are correct in that Chrome 47 is also affected by this exact bug on Windows (correct on Linux).  I'll go ahead and file this issue for Chrome as well.

Edge v20 browser is effected by a completely different bug where Eastern Daylight Savings time seems to start at 2nd Sunday of April, which historically is once again incorrect.

This is pretty huge, at this time most birthdays are broken on modern browsers, especially worse if you were born at midnight in US.

Here are couple of websites showing the correct start and end dates of daylight savings time in North America:

https://en.wikipedia.org/wiki/History_of_time_in_the_United_States
https://www.timeanddate.com/time/change/usa/virginia-beach
Severity: critical → major
Dup'ing forward to bug 1346211 which should have fixed this problem. Please reopen if the issue is still present. Thanks!
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.