Closed Bug 1530538 Opened 7 years ago Closed 7 years ago

setSeconds adds an hour when it shouldn't when timezone is set to London

Categories

(Core :: JavaScript Engine, defect)

65 Branch
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: gabriel.russell, Unassigned)

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36

Steps to reproduce:

I realize that this is not the correct use of setSeconds, but the bug appears to be real none the less. If you set your timezone to London and call set seconds like shown, an extra hour is added, giving the wrong time. If the timezone is not set to London ( I used both New_York, and Rome to test ) then calling setSeconds like so returned the correct time. Interestingly the chrome gives the same results.

Actual results:

d = new Date(0);
Date 1970-01-01T00:00:00.000Z
d.setSeconds(1550283154);
1550286754000
d;
Date 2019-02-16T03:12:34.000Z

Note, that says 3:12 am

Expected results:

d = new Date(0);
Date 1970-01-01T00:00:00.000Z
d.setTime(1550283154000);
1550283154000
d;
Date 2019-02-16T02:12:34.000Z

Note, that says 2:12 am

Thanks for reporting this issue.

Can you provide detailed steps to reproduce? Thanks a lot.

Placing this on Core: JavaScript Engine if it's not correct please feel free to change it.

Component: Untriaged → JavaScript Engine
Product: Firefox → Core

The one hour difference is expected, because London was at GMT+1 on 1970-01-01, but GMT+0 on 2019-02-16. So when 1550283154 seconds are added on top of 1970-01-01T01:00:00.000 local time, it's one hour later than expected, because currently London uses GMT+0. The same effect is visible with other time zones which use a different time zone offset on 1970-01-01 compared to 2019-02-16. For example Australia/Sydney was at GMT+10 (no DST) on 1970-01-01, but GMT+11 (GMT+10 base offset plus one hour DST) on 2019-02-16.

Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.