-
Notifications
You must be signed in to change notification settings - Fork 156
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: Correctly respect largestUnit option in duration rounding #2571
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2571 +/- ##
==========================================
+ Coverage 96.36% 96.38% +0.02%
==========================================
Files 21 21
Lines 12535 12615 +80
Branches 2345 2356 +11
==========================================
+ Hits 12079 12159 +80
Misses 401 401
Partials 55 55 ☔ View full report in Codecov by Sentry. |
4460151
to
f631d18
Compare
83ccaf4
to
282dd60
Compare
This change achieved consensus today at the May 2023 TC39 plenary meeting. Due to the PR being stacked on top of #2519, though, it would be better to merge this after merging that one first. |
282dd60
to
e1699bc
Compare
e1699bc
to
799f08a
Compare
799f08a
to
7dc976d
Compare
7dc976d
to
ff9c35d
Compare
Is this PR now part of #2645? |
6292c14
to
a3ab84f
Compare
a3ab84f
to
000d29d
Compare
fc7b251
to
1f43a9b
Compare
1f43a9b
to
cfd717a
Compare
cfd717a
to
545e6e0
Compare
545e6e0
to
aa93fa6
Compare
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.
Looks to me like it correctly does what it says on the tin - with one potential bug to address, see comment.
aa93fa6
to
9dcf322
Compare
Did you mean to say "we need to call BalanceDateDurationRelative" here? PR looks good to me, I've spoken offline about potentially merging some logic into roundDuration but that will need some big changes including more parameters so may not be worth it for now. |
Indeed, thanks! Fixed. |
…ng() In cases where a number rounded up to the next unit, we would previously return a result that didn't respect the `largestUnit` option in the same way that Duration.prototype.round() would. To fix this, we need to call BalanceDateDurationRelative after RoundDuration in the until()/since() methods that deal with date units (time units already behaved correctly). In Duration.prototype.toString() where time units did not already behave correctly, we need to call BalanceTimeDuration. I was not sure whether it was intentional that we didn't call this, but as far as I can determine from the previous discussions, `toString()` was "controls rounding, works same as `round()`", but the status quo was that it worked differently from `round()`.) Closes: #2563
9dcf322
to
652788d
Compare
Tests are merged now, so this can be merged. |
Note: this PR is stacked on top of #2567 and #2519. The only relevant commit for this issue is the topmost one, "Normative: Balance durations after rounding in until()/since()/toString()".In cases where a number rounded up to the next unit, we would previously return a result that didn't respect the
largestUnit
option in the same way that Duration.prototype.round() would.To fix this, we need to call BalanceDateDurationRelative after RoundDuration in the until()/since() methods that deal with date units (time units already behaved correctly).
In Duration.prototype.toString() where time units did not already behave correctly, we need to call BalanceDuration. I was not sure whether it was intentional that we didn't call this, but as far as I can determine from in
toString()
was "controls rounding, works same asround()
", but the status quo was that it worked differently fromround()
.)Test262 tests are in a branch which is also stacked on top of tests for #2519. I will make it into a PR after we have merged #2519.Tests are in tc39/test262#3956Closes: #2563