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: Use singular unit names throughout #1509

Merged
merged 1 commit into from
May 31, 2021
Merged

Conversation

ptomato
Copy link
Collaborator

@ptomato ptomato commented May 10, 2021

Both singular and plural names remain accepted everywhere, and 'week' is
now accepted where previously only 'weeks' was. However, the singular form
is now preferred for Temporal.Duration as well, and the spec text should
reflect this.

Ensure that options objects passed to user code have the correct singular
unit strings on them.

Closes: #1491

@ptomato ptomato requested a review from Ms2ger May 10, 2021 20:52
@ptomato ptomato marked this pull request as draft May 10, 2021 20:52
@ptomato
Copy link
Collaborator Author

ptomato commented May 10, 2021

Draft while still missing test262 tests.

(edit: also to avoid merging it accidentally before TC39 consensus)

@codecov
Copy link

codecov bot commented May 10, 2021

Codecov Report

Merging #1509 (dcadb53) into main (8d0aa65) will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1509      +/-   ##
==========================================
- Coverage   95.59%   95.57%   -0.02%     
==========================================
  Files          19       19              
  Lines       11139    11139              
  Branches     1736     1736              
==========================================
- Hits        10648    10646       -2     
- Misses        485      487       +2     
  Partials        6        6              
Flag Coverage Δ
test262 61.15% <ø> (ø)
tests 91.76% <ø> (ø)

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

Impacted Files Coverage Δ
polyfill/lib/calendar.mjs 94.34% <0.00%> (-0.11%) ⬇️

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 8d0aa65...dcadb53. Read the comment docs.

Copy link
Collaborator

@justingrant justingrant left a comment

Choose a reason for hiding this comment

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

LGTM

@ptomato ptomato added the needs plenary input Needs to be presented to the committee and feedback incorporated label May 12, 2021
Both singular and plural names remain accepted everywhere, and 'week' is
now accepted where previously only 'weeks' was. However, the singular form
is now preferred for Temporal.Duration as well, and the spec text should
reflect this.

Ensure that options objects passed to user code have the correct singular
unit strings on them.

Closes: #1491
@ptomato ptomato force-pushed the 1491-singular-unit-names branch from f4a0db9 to dcadb53 Compare May 21, 2021 18:56
1. Perform ? ValidateTemporalUnitRange(_largestUnit_, _smallestUnit_).
1. Let _roundingMode_ be ? ToTemporalRoundingMode(_options_, *"trunc"*).
1. Set _roundingMode_ to ! NegateTemporalRoundingMode(_roundingMode_).
1. Let _roundingIncrement_ be ? ToTemporalRoundingIncrement(_options_, *undefined*, *false*).
1. Let _result_ be ? CalendarDateUntil(_temporalDate_.[[Calendar]], _other_, _temporalDate_, _options_).
1. If _smallestUnit_ is *"days"* and _roundingIncrement_ = 1, then
1. Let _untilOptions_ be ? MergeLargestUnitOption(_options_, _largestUnit_).
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Ms2ger @justingrant Relative to the version you previously reviewed, I added this MergeLargestUnitOption invocation to PlainDate.until and PlainDate.since, which essentially passes { ...options, largestUnit } to Calendar.dateUntil, instead of options directly. I decided to do this after writing some test262 tests, so that dateUntil always receives an options bag with a normalized largestUnit, instead of having that depend on which Temporal method you call.

ptomato added a commit that referenced this pull request May 21, 2021
This is the implementation of the normative changes in #1509 in the
polyfill, accompanied by test262 tests to ensure that passing plural and
singular values for largestUnit, smallestUnit, and unit behaves the same;
and also that Calendar.dateUntil() is only ever called with options bags
that contain singular values for largestUnit.

See: #1491
Copy link
Contributor

@FrankYFTang FrankYFTang left a comment

Choose a reason for hiding this comment

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

ToLargestTemporalUnit has 3 args as stated in https://tc39.es/proposal-temporal/#sec-temporal-tolargesttemporalunit but this PR put 4 args here.

        1. Let _largestUnit_ be ? ToLargestTemporalUnit(_options_, « ....  », *"auto"*, *"day"*).
        
    

not clear how to interpret the "auto" and "day" as the last two args here.

@ptomato
Copy link
Collaborator Author

ptomato commented May 25, 2021

@FrankYFTang This PR also changes ToLargestTemporalUnit accordingly to have 4 args (1 of which is optional).

@FrankYFTang
Copy link
Contributor

@FrankYFTang This PR also changes ToLargestTemporalUnit accordingly to have 4 args (1 of which is optional).

sorry. I was blinded by the hiding of large changes done by github.

@ptomato ptomato marked this pull request as ready for review May 25, 2021 22:46
@ptomato
Copy link
Collaborator Author

ptomato commented May 25, 2021

Achieved consensus in today's TC39 meeting.

ptomato added a commit that referenced this pull request May 29, 2021
This is the implementation of the normative changes in #1509 in the
polyfill, accompanied by test262 tests to ensure that passing plural and
singular values for largestUnit, smallestUnit, and unit behaves the same;
and also that Calendar.dateUntil() is only ever called with options bags
that contain singular values for largestUnit.

See: #1491
@ptomato
Copy link
Collaborator Author

ptomato commented May 31, 2021

I don't think we have to wait on #1519 to merge this, so I'll go ahead.

@ptomato ptomato merged commit 304246e into main May 31, 2021
@ptomato ptomato deleted the 1491-singular-unit-names branch May 31, 2021 19:41
ptomato added a commit that referenced this pull request May 31, 2021
This is the implementation of the normative changes in #1509 in the
polyfill, accompanied by test262 tests to ensure that passing plural and
singular values for largestUnit, smallestUnit, and unit behaves the same;
and also that Calendar.dateUntil() is only ever called with options bags
that contain singular values for largestUnit.

See: #1491
Ms2ger pushed a commit that referenced this pull request Jun 1, 2021
This is the implementation of the normative changes in #1509 in the
polyfill, accompanied by test262 tests to ensure that passing plural and
singular values for largestUnit, smallestUnit, and unit behaves the same;
and also that Calendar.dateUntil() is only ever called with options bags
that contain singular values for largestUnit.

See: #1491
ptomato added a commit that referenced this pull request Jun 1, 2021
This is the implementation of the normative changes in #1509 in the
polyfill, accompanied by test262 tests to ensure that passing plural and
singular values for largestUnit, smallestUnit, and unit behaves the same;
and also that Calendar.dateUntil() is only ever called with options bags
that contain singular values for largestUnit.

See: #1491
@justingrant
Copy link
Collaborator

Whoo-hoo! Sorry I haven't gotten to the Node 14 failures yet... was away camping with the family last weekend. Will take a look at it this week.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow 'week' synonym for 'weeks' for smallestUnit/largestUnit/unit option values
4 participants