Skip to content

Commit

Permalink
Editorial: Simplify calculation of time duration in AdjustRounded...Days
Browse files Browse the repository at this point in the history
As pointed out by Anba, in this call to RoundDuration the years...days
parameters are not used within RoundDuration because unit is less than
days. They are returned unchanged and discarded, so we may as well not
pass them in. This change isn't observable by userland code.

Closes: #2617
  • Loading branch information
ptomato committed Oct 11, 2023
1 parent cad78f3 commit f35608b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5571,10 +5571,10 @@ export function AdjustRoundedDurationDays(
precalculatedPlainDateTime
));
({ hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = RoundDuration(
years,
months,
weeks,
days,
0,
0,
0,
0,
0,
0,
0,
Expand Down
2 changes: 1 addition & 1 deletion spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@ <h1>
1. If _oneDayLess_ &times; _direction_ &lt; 0, then
1. Return ! CreateDurationRecord(_years_, _months_, _weeks_, _days_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_).
1. Let _adjustedDateDuration_ be ? AddDuration(_years_, _months_, _weeks_, _days_, 0, 0, 0, 0, 0, 0, 0, 0, 0, _direction_, 0, 0, 0, 0, 0, 0, *undefined*, _zonedRelativeTo_, _precalculatedPlainDateTime_).
1. Let _adjustedTimeDuration_ be ! RoundDuration(_adjustedDateDuration_.[[Years]], _adjustedDateDuration_.[[Months]], _adjustedDateDuration_.[[Weeks]], _adjustedDateDuration_.[[Days]], 0, 0, 0, 0, 0, _oneDayLess_, _increment_, _unit_, _roundingMode_).
1. Let _adjustedTimeDuration_ be ! RoundDuration(0, 0, 0, 0, 0, 0, 0, 0, 0, _oneDayLess_, _increment_, _unit_, _roundingMode_).
1. Set _adjustedTimeDuration_ to ? BalanceTimeDuration(0, _adjustedTimeDuration_.[[Hours]], _adjustedTimeDuration_.[[Minutes]], _adjustedTimeDuration_.[[Seconds]], _adjustedTimeDuration_.[[Milliseconds]], _adjustedTimeDuration_.[[Microseconds]], _adjustedTimeDuration_.[[Nanoseconds]], *"hour"*).
1. Return ! CreateDurationRecord(_adjustedDateDuration_.[[Years]], _adjustedDateDuration_.[[Months]], _adjustedDateDuration_.[[Weeks]], _adjustedDateDuration_.[[Days]], _adjustedTimeDuration_.[[Hours]], _adjustedTimeDuration_.[[Minutes]], _adjustedTimeDuration_.[[Seconds]], _adjustedTimeDuration_.[[Milliseconds]], _adjustedTimeDuration_.[[Microseconds]], _adjustedTimeDuration_.[[Nanoseconds]]).
</emu-alg>
Expand Down

0 comments on commit f35608b

Please sign in to comment.