-
Notifications
You must be signed in to change notification settings - Fork 153
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
Normative: Disallow one day long time zone offsets #2260
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2260 +/- ##
=======================================
Coverage 95.01% 95.01%
=======================================
Files 20 20
Lines 10803 10803
Branches 1925 1925
=======================================
Hits 10264 10264
Misses 503 503
Partials 36 36
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Is this a timezone offset from UTC? If so, it can only range from -12 to +14 hours. If it's the difference between any two timezones, it could be as much as 26 hours. |
It is the offset for a single time zone at a specific instant. The built-in time zone object supports up-to js> new Temporal.TimeZone("+23:59:59.999999999").getOffsetNanosecondsFor(new Temporal.Instant(0n))
86399999999999 |
Is the design intending to support possible future timezones with larger offsets than 14 hours? If so, why wouldn't "24 hours" be a valid value? |
The supported range is actually even longer because of LMT (local mean time):
const min = new Temporal.Instant(-86_40000_00000_00000_00000n);
let minOffset = +Infinity;
let maxOffset = -Infinity;
let minTimeZone;
let maxTimeZone;
for (let id of Intl.supportedValuesOf("timeZone")) {
console.log(id);
let tz = new Temporal.TimeZone(id);
let instant = min;
for (let i = 0; i < 1000; ++i) {
let offset = tz.getOffsetNanosecondsFor(instant);
if (offset < minOffset) {
minOffset = offset;
minTimeZone = id;
}
if (offset > maxOffset) {
maxOffset = offset;
maxTimeZone = id;
}
let next = tz.getNextTransition(instant);
if (next === null) {
break;
}
instant = next;
}
}
console.log("minOffset:", minOffset, minTimeZone);
console.log("maxOffset:", maxOffset, maxTimeZone); |
Is it up to 23 hours and 59 minutes, or a smaller value? I'm trying to understand why 24 hours is a magic illegal number but "24 hours - 1 minute" is fine. |
The maximum for built-in time zone objects is "+23:59:59.999999999" (and "-23:59:59.999999999" in the other direction). This can happen only when the time zone is created from an offset string. |
Thanks, it all makes sense now :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good catch.
Would you mind splitting out the editorial change into a separate pull request so we can merge it ahead of presenting the normative change?
Built-in time zones don't support an offset of `nsPerDay` nanoseconds and there isn't any reason user-defined time zones should be able to support time zones offsets of `nsPerDay` nanoseconds.
…ndsFor This tests the normative change from tc39/proposal-temporal#2260 which achieved consensus in the July 2022 TC39 meeting. The return value from a userland getOffsetNanosecondsFor method is no longer allowed to be exactly one 24-hour day.
Tests are in tc39/test262#3669. |
…ndsFor This tests the normative change from tc39/proposal-temporal#2260 which achieved consensus in the July 2022 TC39 meeting. The return value from a userland getOffsetNanosecondsFor method is no longer allowed to be exactly one 24-hour day.
This is the corresponding change to the polyfill that was changed in the spec text in f239577.
658df46
to
f5b51cb
Compare
This achieved consensus in the July 2022 TC39 plenary meeting. I've added a commit that updates the reference code, and pulls in the new test262 tests. |
…ndsFor This tests the normative change from tc39/proposal-temporal#2260 which achieved consensus in the July 2022 TC39 meeting. The return value from a userland getOffsetNanosecondsFor method is no longer allowed to be exactly one 24-hour day.
…ndsFor This tests the normative change from tc39/proposal-temporal#2260 which achieved consensus in the July 2022 TC39 meeting. The return value from a userland getOffsetNanosecondsFor method is no longer allowed to be exactly one 24-hour day.
No description provided.