Closed
Bug 1514677
Opened 6 years ago
Closed 6 years ago
getHours on Date with DST before 1980 returns wrong value
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 1346211
People
(Reporter: maddin.schuetz, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
Steps to reproduce:
Calling getHours on a Date with DST before 1980 returns a wrong value on a machine with german timezone.
In Germany before 1980 there was no DST.
Actual results:
new Date("1977-07-03T01:11:27.822Z").getHours() returns 3
Expected results:
new Date("1977-07-03T01:11:27.822Z").getHours() returns 2
The function toLocaleTimeString returns the right value.
This jasmine test fails in Firefox, in other browsers it works:
it("this test fails", () => {
const dat = new Date("1977-07-03T01:11:27.822Z");
expect(dat.getHours()).toEqual(+dat.toLocaleTimeString(undefined, { hour: "2-digit" }).substr(0, 2));
});
Updated•6 years ago
|
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Reporter | ||
Comment 1•6 years ago
|
||
Found another case:
Dates between 1980 and 1996. In this time in germany the DST lasted only until september, not until october as most other states in EU.
So this test also fails:
it("this test fails too", () => {
const dat = new Date("1995-09-28T01:11:27.822Z");
expect(dat.getHours()).toEqual(+dat.toLocaleTimeString(undefined, { hour: "2-digit" }).substr(0, 2));
});
It works with a year >= 1996
Comment 2•6 years ago
|
||
Starting with Firefox 63 (bug 1346211), we're using more accurate historical time zone data. Before Firefox 63, the POSIX API of the underlying OS was queried for any time zone computation, which means on Windows only the current time zone rules were applied. This should explain the results in comment #0 and comment #1, because both reflect the current EU rules instead of the time zone rules in Germany at that point of time.
So basically updating to a more recent Firefox version should fix the issue.
Reporter | ||
Comment 3•6 years ago
|
||
Thank you :anba the tests work in Firefox 64
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
Comment 4•6 years ago
|
||
Great, thanks for verifying!
You need to log in
before you can comment on or make changes to this bug.
Description
•