-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getTimezoneOffset should not round #33306
Comments
I was just about to link to that issue. :-) The relevant code in V8 is this: node/deps/v8/src/objects/js-objects.cc Lines 5804 to 5808 in bcdbd57
Lines 95 to 99 in bcdbd57
Which operates on ints, not doubles. I'll close this out because it's ultimately not a Node.js issue but we can cherry-pick upstream fixes once they materialize. Thanks anyway for the bug report! |
What steps will reproduce the bug?
Run NodeJS REPL in the
Asia/Hong_Kong
timezone (TZ=Asia/Hong_Kong node
) and runHow often does it reproduce? Is there a required condition?
Always reproduces
What is the expected behavior?
According to https://www.timeanddate.com/time/zone/hong-kong/hong-kong (look at the Time zone changes for: 1850-1899) the timezone was
+7:36:42
which would suggest the timezone offset should be-456.7
, potentially with a sub-second differenceIn case you need an "official" listing, the IANA tz database lists the following for
Asia/Hong_Kong
:So it definitely has a sub-minute component
What do you see instead?
-456
it appears NodeJS is rounding.According to the spec https://tc39.es/ecma262/#sec-date.prototype.gettimezoneoffset
That division is not integer division. Other date functions which do require integer results are explicitly specced with an appropriate integer operation.
Additional information
This also affects Chrome, so this is probably a v8 bug.
Related issues:
utcOffset()
result in firefox and chrome moment/moment#5515The text was updated successfully, but these errors were encountered: