Normative: Limit offset time zones to minutes precision#2607
Normative: Limit offset time zones to minutes precision#2607
Conversation
gibson042
left a comment
There was a problem hiding this comment.
I got a little in, but honestly am feeling overwhelmed by the plethora of abstract operations. For me at least, I think the splits hinder comprehension.
ae020e9 to
1dd7030
Compare
Codecov Report
@@ Coverage Diff @@
## main #2607 +/- ##
==========================================
- Coverage 95.96% 95.94% -0.03%
==========================================
Files 20 20
Lines 11536 11550 +14
Branches 2191 2197 +6
==========================================
+ Hits 11071 11082 +11
- Misses 401 404 +3
Partials 64 64
|
9f1fc24 to
53f8027
Compare
|
V2 is available. It's a refactor based on @gibson042's advice around parsing and grammar. Let me know if you see problems with this version. If not then I'll move onto Test262. |
|
Also, I updated the OP so you can see a summary of the latest design. |
09cec14 to
f6818ce
Compare
|
@gibson042 @ptomato PR is now ready for review. I split it up into one editorial commit that refactors offset handling, and two normative commits:
I'll work on Test262 next. |
gibson042
left a comment
There was a problem hiding this comment.
There's a lot of good work here, but I think a little more is still warranted.
f6818ce to
123cb3e
Compare
tc39/proposal-temporal#2607 was approved in the July 2023 TC39 meeting, which removes the need for this proposal to change SystemTimeZoneIdentifier.
dda8f6c to
199a94b
Compare
This editorial commit refactors FormatSecondsStringPart to include similar editorial changes made to GetOffsetStringFor in tc39#2607.
This editorial commit refactors FormatSecondsStringPart to include similar editorial changes made to GetOffsetStringFor in tc39#2607.
33ae966 to
5345608
Compare
|
All review comments are addressed and PR is rebased to main. Tests over in tc39/test262#3862 are I think also ready to merge if we're OK merging them despite concerns in https://github.com/tc39/test262/pull/3862/files#r1259590953 that I'd prefer to defer for now. |
This editorial commit refactors FormatSecondsStringPart to include similar editorial changes made to GetOffsetStringFor in tc39#2607.
This editorial commit removes redundant spec text dealing with time formatting: * Adds a new AO FormatTimeString, and calls it in TemporalTimeToString, TemporalDateTimeToString, and TimeString (the legacy date AO in 262). * Removes FormatSecondsStringPart and replaces it with a new AO FormatFractionalSeconds, and call it in FormatTimeString and TemporalDurationToString. The text of this new AO is aligned with similar text in GetOffsetStringFor in tc39#2607. * Replaces sub-second formatting text in TemporalDurationToString with a call to FormatFractionalSeconds. * Aligns polyfill code to these spec changes. * Adjusts polyfill code in a few places to better match the spec. Note that this commit doesn't touch spec text for formatting time zone offsets because there are several in-flight PRs dealing with offsets and I wanted to keep this PR merge-conflict-free. But once those PRs land and the dust settles, then I'll send another editorial PR to DRY offset string formatting too, by using FormatTimeString to replace bespoke formatting text for offsets.
This editorial commit removes redundant spec text dealing with time formatting: * Adds a new AO FormatTimeString, and calls it in TemporalTimeToString, TemporalDateTimeToString, and TimeString (the legacy date AO in 262). * Removes FormatSecondsStringPart and replaces it with a new AO FormatFractionalSeconds, and call it in FormatTimeString and TemporalDurationToString. The text of this new AO is aligned with similar text in GetOffsetStringFor in tc39#2607. * Replaces sub-second formatting text in TemporalDurationToString with a call to FormatFractionalSeconds. * Aligns polyfill code to these spec changes. * Adjusts polyfill code in a few places to better match the spec. Note that this commit doesn't touch spec text for formatting time zone offsets because there are several in-flight PRs dealing with offsets and I wanted to keep this PR merge-conflict-free. But once those PRs land and the dust settles, then I'll send another editorial PR to DRY offset string formatting too, by using FormatTimeString to replace bespoke formatting text for offsets.
This editorial commit removes redundant spec text dealing with time formatting: * Adds a new AO FormatTimeString, and calls it in TemporalTimeToString, TemporalDateTimeToString, and TimeString (the legacy date AO in 262). * Removes FormatSecondsStringPart and replaces it with a new AO FormatFractionalSeconds, and call it in FormatTimeString and TemporalDurationToString. The text of this new AO is aligned with similar text in GetOffsetStringFor in tc39#2607. * Replaces sub-second formatting text in TemporalDurationToString with a call to FormatFractionalSeconds. * Aligns polyfill code to these spec changes. * Adjusts polyfill code in a few places to better match the spec. Note that this commit doesn't touch spec text for formatting time zone offsets because there are several in-flight PRs dealing with offsets and I wanted to keep this PR merge-conflict-free. But once those PRs land and the dust settles, then I'll send another editorial PR to DRY offset string formatting too, by using FormatTimeString to replace bespoke formatting text for offsets.
This editorial commit removes redundant spec text dealing with time formatting: * Adds a new AO FormatTimeString, and calls it in TemporalTimeToString, TemporalDateTimeToString, and TimeString (the legacy date AO in 262). * Removes FormatSecondsStringPart and replaces it with a new AO FormatFractionalSeconds, and call it in FormatTimeString and TemporalDurationToString. The text of this new AO is aligned with similar text in GetOffsetStringFor in #2607. * Replaces sub-second formatting text in TemporalDurationToString with a call to FormatFractionalSeconds. * Aligns polyfill code to these spec changes. * Adjusts polyfill code in a few places to better match the spec. Note that this commit doesn't touch spec text for formatting time zone offsets because there are several in-flight PRs dealing with offsets and I wanted to keep this PR merge-conflict-free. But once those PRs land and the dust settles, then I'll send another editorial PR to DRY offset string formatting too, by using FormatTimeString to replace bespoke formatting text for offsets.
Modify/add tests for tc39/proposal-temporal#2607
2c3a752 to
36487a6
Compare
@ptomato I think this one is ready to merge. After it's merged I can rebase #2574 on the updated main, and then that PR should be ready to go as well after tests are reviewed and merged. |
At implementers' request to reduce the storage requirements of Temporal.TimeZone from 49+ bits to 12-13 bits, this commit requires that the [[OffsetNanoseconds]] internal slot of Temporal.TimeZone is limited to minute precision. Sub-minute precision is still allowed for custom time zone objects and built-in named time zones. In other words, this commit changes storage requirements but not internal calculation requirements. This commit is fairly narrow: * Changes |TimeZoneUTCOffsetName| production to restrict allowed offset syntax for parsing. * Changes FormatOffsetTimeZoneIdentifier AO to format minute strings only. * Moves sub-minute offset formatting from FormatOffsetTimeZoneIdentifier to instead be inlined in GetOffsetStringFor, which is now the only place where sub-minute offsets are formatted. Fixes tc39#2593.
This commit adds a "normalized format of a time zone identifier" definition, and uses it to ensure that SystemTimeZoneIdentifier only returns normalized identifiers like "-05:00" (not "-0500" nor "-05") or "America/Los_Angeles" (not "AMERICA/LOS_ANGELES" nor "AmErIcA/lOs_AnGeLeS"). No current implementations return offset strings in non-normalized format, so although this is a normative change, it won't break existing ECMAScript code nor will it require changes to current implementations. Fixes tc39#2584.
This PR limits offset time zones to minutes precision to address implementer feedback that the storage requirements of Temporal.TimeZone are too large. This PR reduces Temporal.TimeZone storage requirements from 49 bits to 12-13 bits.
The first normative commit changes
|TimeZoneUTCOffsetName|to minutes precision and moves sub-minute offset formatting from FormatOffsetTimeZoneIdentifier to GetOffsetStringFor.The second normative commit ensures that SystemTimeZoneIdentifier cannot return offsets greater than minute precision, and ensures that any offsets are returned in normalized form (e.g.
-05:00not-05nor-0500). Note that no current implementation returns offsets from SystemTimeZoneIdentifier, so although this commit is a normative change to an existing ECMA-262 abstract operation, it won't require changes to existing implementation nor will it break existing ECMAScript programs.This PR fixes #2593 and fixes #2584, and is marked as a draft until it can be presented at the July 2023 TC39 plenary meeting.
Tests are at tc39/test262#3862.