Skip to content
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: Limit offset time zones to minutes precision #2607

Merged
merged 3 commits into from
Jul 18, 2023

Conversation

justingrant
Copy link
Collaborator

@justingrant justingrant commented Jun 14, 2023

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:00 not -05 nor -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.

Copy link
Collaborator

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

spec/abstractops.html Outdated Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
spec/mainadditions.html Outdated Show resolved Hide resolved
spec/mainadditions.html Outdated Show resolved Hide resolved
spec/timezone.html Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jun 15, 2023

Codecov Report

Merging #2607 (fd7fccd) into main (9253db8) will decrease coverage by 0.03%.
The diff coverage is 91.42%.

@@            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              
Impacted Files Coverage Δ
polyfill/lib/ecmascript.mjs 98.21% <91.17%> (-0.05%) ⬇️
polyfill/lib/regex.mjs 100.00% <100.00%> (ø)

@justingrant justingrant force-pushed the offset-timezone-minutes branch 11 times, most recently from 9f1fc24 to 53f8027 Compare June 16, 2023 10:10
@justingrant
Copy link
Collaborator Author

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.

@justingrant
Copy link
Collaborator Author

Also, I updated the OP so you can see a summary of the latest design.

@justingrant justingrant force-pushed the offset-timezone-minutes branch 7 times, most recently from 09cec14 to f6818ce Compare June 18, 2023 00:49
@justingrant
Copy link
Collaborator Author

@gibson042 @ptomato PR is now ready for review. I split it up into one editorial commit that refactors offset handling, and two normative commits:

  • A small one that ensures that SystemTimeZoneIdentifier only returns offset strings in normal form
  • A big one that makes the nanoseconds=>minutes change for offset time zones

I'll work on Test262 next.

Copy link
Collaborator

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of good work here, but I think a little more is still warranted.

spec/mainadditions.html Outdated Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
spec/mainadditions.html Outdated Show resolved Hide resolved
spec/timezone.html Outdated Show resolved Hide resolved
spec/timezone.html Outdated Show resolved Hide resolved
spec/timezone.html Outdated Show resolved Hide resolved
spec/timezone.html Outdated Show resolved Hide resolved
@justingrant justingrant changed the title WIP: Limit offset time zones to minutes precision DRAFT: Limit offset time zones to minutes precision Jun 18, 2023
@justingrant justingrant force-pushed the offset-timezone-minutes branch 2 times, most recently from 2c3a752 to 36487a6 Compare July 17, 2023 19:42
@justingrant
Copy link
Collaborator Author

I think it's fine to make those minor editorial changes in the coming days. Let me know when everyone is happy about it, and I'll merge tc39/test262#3862 and follow it up by pushing a commit to update test262 and then merge this.

@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.
justingrant added a commit to justingrant/test262 that referenced this pull request Jul 18, 2023
ptomato pushed a commit to tc39/test262 that referenced this pull request Jul 18, 2023
@ptomato ptomato merged commit 861aba9 into tc39:main Jul 18, 2023
9 checks passed
justingrant added a commit to justingrant/test262 that referenced this pull request Jul 21, 2023
This commit verifies that ISO strings with sub-minute offsets cannot
be parsed into time zone identifiers. This was a change introduced in
the recently-merged tc39/proposal-temporal#2607, but tests for this case
were missing from tc39#3862 (the tests for that PR).

I noticed in codecov results on an unrelated PR that this case wasn't
being tested, so fixing that mistake now.
justingrant added a commit to justingrant/test262 that referenced this pull request Jul 21, 2023
This commit verifies that ISO strings with sub-minute offsets cannot
be parsed into time zone identifiers. This was a change introduced in
the recently-merged tc39/proposal-temporal#2607, but tests for this case
were missing from tc39#3862 (the tests for that PR).

I noticed in codecov results on an unrelated PR that this case wasn't
being tested, so fixing that mistake now.
justingrant added a commit to justingrant/test262 that referenced this pull request Jul 21, 2023
This commit verifies that ISO strings with sub-minute offsets cannot
be parsed into time zone identifiers. This was a change introduced in
the recently-merged tc39/proposal-temporal#2607, but tests for this case
were missing from tc39#3862 (the tests for that PR).

I noticed in codecov results on an unrelated PR that this case wasn't
being tested, so fixing that mistake now.
justingrant added a commit to justingrant/test262 that referenced this pull request Jul 21, 2023
This commit verifies that ISO strings with sub-minute offsets cannot
be parsed into time zone identifiers. This was a change introduced in
the recently-merged tc39/proposal-temporal#2607, but tests for this case
were missing from tc39#3862 (the tests for that PR).

I noticed in codecov results on an unrelated PR that this case wasn't
being tested, so fixing that mistake now.
justingrant added a commit to justingrant/test262 that referenced this pull request Jul 21, 2023
There was one remaining Temporal test that was parsing an ISO string
with a sub-minute offset into a Temporal.TimeZone. A polyfill bug was
allowing this test case to pass, even though after
tc39/proposal-temporal#2607 it should have failed.

This commit removes the bad test case.
ben-allen pushed a commit to ben-allen/test262 that referenced this pull request Jul 21, 2023
Modify/add tests for tc39/proposal-temporal#2607

added tests for valid language tags

removed unnecessary requirement for DisplayNames-v2
Ms2ger pushed a commit to justingrant/test262 that referenced this pull request Jul 25, 2023
This commit verifies that ISO strings with sub-minute offsets cannot
be parsed into time zone identifiers. This was a change introduced in
the recently-merged tc39/proposal-temporal#2607, but tests for this case
were missing from tc39#3862 (the tests for that PR).

I noticed in codecov results on an unrelated PR that this case wasn't
being tested, so fixing that mistake now.
Ms2ger pushed a commit to justingrant/test262 that referenced this pull request Jul 25, 2023
There was one remaining Temporal test that was parsing an ISO string
with a sub-minute offset into a Temporal.TimeZone. A polyfill bug was
allowing this test case to pass, even though after
tc39/proposal-temporal#2607 it should have failed.

This commit removes the bad test case.
ptomato pushed a commit to justingrant/test262 that referenced this pull request Aug 9, 2023
This commit verifies that ISO strings with sub-minute offsets cannot
be parsed into time zone identifiers. This was a change introduced in
the recently-merged tc39/proposal-temporal#2607, but tests for this case
were missing from tc39#3862 (the tests for that PR).

I noticed in codecov results on an unrelated PR that this case wasn't
being tested, so fixing that mistake now.
ptomato pushed a commit to justingrant/test262 that referenced this pull request Aug 9, 2023
There was one remaining Temporal test that was parsing an ISO string
with a sub-minute offset into a Temporal.TimeZone. A polyfill bug was
allowing this test case to pass, even though after
tc39/proposal-temporal#2607 it should have failed.

This commit removes the bad test case.
ptomato pushed a commit to tc39/test262 that referenced this pull request Aug 9, 2023
This commit verifies that ISO strings with sub-minute offsets cannot
be parsed into time zone identifiers. This was a change introduced in
the recently-merged tc39/proposal-temporal#2607, but tests for this case
were missing from #3862 (the tests for that PR).

I noticed in codecov results on an unrelated PR that this case wasn't
being tested, so fixing that mistake now.
ptomato pushed a commit to tc39/test262 that referenced this pull request Aug 9, 2023
There was one remaining Temporal test that was parsing an ISO string
with a sub-minute offset into a Temporal.TimeZone. A polyfill bug was
allowing this test case to pass, even though after
tc39/proposal-temporal#2607 it should have failed.

This commit removes the bad test case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants