Skip to content

Commit

Permalink
Editorial: Algorithmic approach for early returns in UnbalanceDateDur…
Browse files Browse the repository at this point in the history
…ationRelative
  • Loading branch information
anba committed Sep 27, 2023
1 parent c4f291f commit 74cfd4e
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -1363,14 +1363,9 @@ <h1>
<dd>It converts the calendar units of a duration into a form where no unit is larger than _largestUnit_, and returns the result as a Date Duration Record.</dd>
</dl>
<emu-alg>
1. If _largestUnit_ is *"year"*, then
1. Let _defaultLargestUnit_ be DefaultTemporalLargestUnit(_years_, _months_, _weeks_, _days_, 0, 0, 0, 0, 0).
1. If _largestUnit_ is LargerOfTwoTemporalUnits(_defaultLargestUnit_, _largestUnit_), then
1. Return ! CreateDateDurationRecord(_years_, _months_, _weeks_, _days_).
1. Else if _largestUnit_ is *"month"* and _years_ = 0, then
1. Return ! CreateDateDurationRecord(0, _months_, _weeks_, _days_).
1. Else if _largestUnit_ is *"week"* and _years_ = 0 and _months_ = 0, then
1. Return ! CreateDateDurationRecord(0, 0, _weeks_, _days_).
1. Else if _largestUnit_ is *"day"* and _years_ = 0 and _months_ = 0 and _weeks_ = 0, then
1. Return ! CreateDateDurationRecord(0, 0, 0, _days_).
1. Let _sign_ be ! DurationSign(_years_, _months_, _weeks_, _days_, 0, 0, 0, 0, 0, 0).
1. Assert: _sign_ &ne; 0.
1. Let _oneYear_ be ! CreateTemporalDuration(_sign_, 0, 0, 0, 0, 0, 0, 0, 0, 0).
Expand Down

0 comments on commit 74cfd4e

Please sign in to comment.