Closed
Bug 1567862
Opened 6 years ago
Closed 6 years ago
JS engine's `new Date().getTimezoneOffset()` is wrong if the browser was started in a different timezone to the current one
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 1348916
People
(Reporter: Gijs, Unassigned)
Details
I traveled from Europe to the UK this weekend. My browser instance was started in Europe and is still alive. This is some browser console output:
> new Date().getTimezoneOffset()
< -120
> new Date().toString()
< "Mon Jul 22 2019 12:38:11 GMT+0200 (Central European Summer Time)"
> new Date()
< Date Mon Jul 22 2019 11:38:27 GMT+0100 (British Summer Time)
# note: I don't know how devtools does this, but it somehow manages to get it right...
This is a bit annoying. I don't know if a summer time change would cause the same issue, but it seems concerning. I'm not at all a JS engine expert, but from a casual check, the use of cachedLocalTime
at https://searchfox.org/mozilla-central/rev/b9041f813de0a05bf6de95a145d4e25004499517/js/src/jsdate.cpp#1902,1906 looks like it might be the culprit. I guess in the ideal case we should update whatever it's caching when the OS notifies us of a timezone change (assuming that we're using caching for performance reasons). In case it matters, I'm on mac (fx69 beta).
Reporter | ||
Comment 1•6 years ago
|
||
Oh, and:
> Intl.DateTimeFormat().resolvedOptions().timeZone
< "Europe/Amsterdam"
Updated•6 years ago
|
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•