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: Simplify Duration parsing #1907

Merged
merged 2 commits into from
Dec 17, 2021

Conversation

gibson042
Copy link
Collaborator

@gibson042 gibson042 commented Nov 6, 2021

...as mentioned in #1759. This also fixes some spec bugs from use of floor with negative values.

This also requires care with respect to using mathematical values rather than approximations, and I'd like to see a test for input like ±PT46H66M71.50040904S (which produced an off-by-one error at the nanoseconds level when I was evaluating a JS-based implementation of the new algorithm that took too many liberties in that respect).

Fixes #1754

@codecov
Copy link

codecov bot commented Nov 6, 2021

Codecov Report

Merging #1907 (c39358b) into main (1bcbb69) will increase coverage by 5.07%.
The diff coverage is n/a.

❗ Current head c39358b differs from pull request most recent head 7a21347. Consider uploading reports for the commit 7a21347 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1907      +/-   ##
==========================================
+ Coverage   89.85%   94.92%   +5.07%     
==========================================
  Files          17       19       +2     
  Lines       10929    10991      +62     
  Branches     1582     1721     +139     
==========================================
+ Hits         9820    10433     +613     
+ Misses       1071      543     -528     
+ Partials       38       15      -23     
Flag Coverage Δ
test262 81.74% <ø> (?)
tests 89.74% <ø> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
polyfill/lib/legacydate.mjs 0.00% <0.00%> (ø)
polyfill/lib/shim.mjs 100.00% <0.00%> (ø)
polyfill/lib/intl.mjs 100.00% <0.00%> (+1.59%) ⬆️
polyfill/lib/ecmascript.mjs 94.99% <0.00%> (+2.31%) ⬆️
polyfill/lib/intrinsicclass.mjs 51.35% <0.00%> (+2.70%) ⬆️
polyfill/lib/duration.mjs 98.03% <0.00%> (+4.71%) ⬆️
polyfill/lib/calendar.mjs 94.39% <0.00%> (+4.92%) ⬆️
polyfill/lib/timezone.mjs 93.46% <0.00%> (+6.53%) ⬆️
polyfill/lib/plaindatetime.mjs 97.55% <0.00%> (+6.77%) ⬆️
polyfill/lib/zoneddatetime.mjs 98.49% <0.00%> (+7.20%) ⬆️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1bcbb69...7a21347. Read the comment docs.

@gibson042 gibson042 changed the title simplify Duration parsing Normative: Simplify Duration parsing Nov 7, 2021
Copy link
Collaborator

@ptomato ptomato left a comment

Choose a reason for hiding this comment

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

This looks great! I had not made the connection with the ParseText machinery. I assume we should use ParseText in all the other AOs that parse our ISO 8601 grammar.

I have a hunch that we could adopt as much of this change as would be possible in a separate editorial-only PR, and keep the actual normative bug-fixing PR small? I think that would help delegates review the normative change for December. Is it possible to split this up with that in mind?

spec/abstractops.html Show resolved Hide resolved
@ptomato ptomato added the spec-text Specification text involved label Nov 9, 2021
spec/abstractops.html Outdated Show resolved Hide resolved
@gibson042
Copy link
Collaborator Author

I have a hunch that we could adopt as much of this change as would be possible in a separate editorial-only PR, and keep the actual normative bug-fixing PR small? I think that would help delegates review the normative change for December. Is it possible to split this up with that in mind?

If adoption of ParseText is not considered normative then I think this PR is there now, with the first two commits accomplishing that and the remainder removing DurationHandleFractions and fixing #1754 in the process by ignoring duration sign until the end of the operation.

@ptomato
Copy link
Collaborator

ptomato commented Nov 15, 2021

I would guess that the adoption of ParseText is not normative, because I don't think it would be possible to write a test that would distinguish whether an implementation was following the spec text before or after that change.

So, the only one that needs to be presented in December is "Normative: Remove DurationHandleFractions"? Can we change the order of the commits so that "Editorial: Ignore sign until the end" and "Editorial: Assign MVs to new aliases rather than replacing Parse Nodes" are applied to the current spec text, and then preserved when moving code around in "Normative: Remove DurationHandleFractions"? (I'm happy to do this if you think it's an OK idea, I find rebasing patches relaxing)

@gibson042
Copy link
Collaborator Author

gibson042 commented Nov 16, 2021

Can we change the order of the commits so that "Editorial: Ignore sign until the end" and "Editorial: Assign MVs to new aliases rather than replacing Parse Nodes" are applied to the current spec text, and then preserved when moving code around in "Normative: Remove DurationHandleFractions"? (I'm happy to do this if you think it's an OK idea, I find rebasing patches relaxing)

Yes, feel free! But I'm not sure you'll be able to meaningfully reorder "Ignore sign until the end", because calling DurationHandleFractions with only nonnegative values will probably implement the normative change that fixes #1754.

@justingrant justingrant marked this pull request as draft November 18, 2021 18:23
@ptomato ptomato force-pushed the 2021-11-simplify-parse-duration branch from b3ec4c4 to 7a21347 Compare November 19, 2021 22:56
@ptomato
Copy link
Collaborator

ptomato commented Nov 19, 2021

OK, I've rebased this.

@ptomato ptomato added the needs plenary input Needs to be presented to the committee and feedback incorporated label Nov 30, 2021
@gibson042 gibson042 marked this pull request as ready for review December 16, 2021 23:05
@ptomato
Copy link
Collaborator

ptomato commented Dec 17, 2021

This achieved consensus at the December 2021 TC39 meeting.

@ptomato ptomato merged commit 6dae066 into tc39:main Dec 17, 2021
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 4, 2022
tc39/proposal-temporal#1907 was a bug that caused
negative Duration strings with fractional units to be rounded incorrectly.
Add tests that ensure the rounding mode is correct.

This was a normative change that achieved consensus at the December 2021
TC39 meeting.
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 5, 2022
tc39/proposal-temporal#1907 was a bug that caused
negative Duration strings with fractional units to be rounded incorrectly.
Add tests that ensure the rounding mode is correct.

This was a normative change that achieved consensus at the December 2021
TC39 meeting.
rwaldron pushed a commit to tc39/test262 that referenced this pull request Feb 8, 2022
tc39/proposal-temporal#1907 was a bug that caused
negative Duration strings with fractional units to be rounded incorrectly.
Add tests that ensure the rounding mode is correct.

This was a normative change that achieved consensus at the December 2021
TC39 meeting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs plenary input Needs to be presented to the committee and feedback incorporated spec-text Specification text involved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DurationHandleFractions: spec does floor, polyfill does trunc
2 participants