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

Editorial: Tweaks to UnbalanceDateDurationRelative #2678

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 28 additions & 26 deletions spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ <h1>
1. Else,
1. Let _calendar_ be *undefined*.
1. If _largestUnit_ is *"month"*, then
1. If _years_ = 0, return ? CreateDateDurationRecord(0, _months_, _weeks_, _days_).
1. If _years_ = 0, return ! CreateDateDurationRecord(0, _months_, _weeks_, _days_).
1. If _calendar_ is *undefined*, then
1. Throw a *RangeError* exception.
1. If _calendar_ is an Object, then
Expand All @@ -1395,8 +1395,9 @@ <h1>
1. Set _plainRelativeTo_ to _newRelativeTo_.
1. Set _years_ to _years_ - _sign_.
1. Set _months_ to _months_ + _oneYearMonths_.
1. Else if _largestUnit_ is *"week"*, then
1. If _years_ = 0 and _months_ = 0, return ? CreateDateDurationRecord(0, 0, _weeks_, _days_).
1. Return ? CreateDateDurationRecord(0, _months_, _weeks_, _days_).
1. If _largestUnit_ is *"week"*, then
1. If _years_ = 0 and _months_ = 0, return ! CreateDateDurationRecord(0, 0, _weeks_, _days_).
1. If _calendar_ is *undefined*, then
1. Throw a *RangeError* exception.
1. If _calendar_ is an Object, then
Expand All @@ -1413,30 +1414,31 @@ <h1>
1. Set _plainRelativeTo_ to _moveResult_.[[RelativeTo]].
1. Set _days_ to _days_ + _moveResult_.[[Days]].
1. Set _months_ to _months_ - _sign_.
1. Return ? CreateDateDurationRecord(0, 0, _weeks_, _days_).
1. Assert: _largestUnit_ is *"day"*.
1. If _years_ = 0, and _months_ = 0, and _weeks_ = 0, return ! CreateDateDurationRecord(0, 0, 0, _days_).
1. If _calendar_ is *undefined*, then
1. Throw a *RangeError* exception.
1. If _calendar_ is an Object, then
1. Let _dateAdd_ be ? GetMethod(_calendar_, *"dateAdd"*).
1. Else,
1. If _years_ &ne; 0, or _months_ &ne; 0, or _weeks_ &ne; zero, then
1. If _calendar_ is *undefined*, then
1. Throw a *RangeError* exception.
1. If _calendar_ is an Object, then
1. Let _dateAdd_ be ? GetMethod(_calendar_, *"dateAdd"*).
1. Else,
1. Let _dateAdd_ be ~unused~.
1. Repeat, while _years_ &ne; 0,
1. Let _moveResult_ be ? MoveRelativeDate(_calendar_, _plainRelativeTo_, _oneYear_, _dateAdd_).
1. Set _plainRelativeTo_ to _moveResult_.[[RelativeTo]].
1. Set _days_ to _days_ + _moveResult_.[[Days]].
1. Set _years_ to _years_ - _sign_.
1. Repeat, while _months_ &ne; 0,
1. Let _moveResult_ be ? MoveRelativeDate(_calendar_, _plainRelativeTo_, _oneMonth_, _dateAdd_).
1. Set _plainRelativeTo_ to _moveResult_.[[RelativeTo]].
1. Set _days_ to _days_ +_moveResult_.[[Days]].
1. Set _months_ to _months_ - _sign_.
1. Repeat, while _weeks_ &ne; 0,
1. Let _moveResult_ be ? MoveRelativeDate(_calendar_, _plainRelativeTo_, _oneWeek_, _dateAdd_).
1. Set _plainRelativeTo_ to _moveResult_.[[RelativeTo]].
1. Set _days_ to _days_ + _moveResult_.[[Days]].
1. Set _weeks_ to _weeks_ - _sign_.
1. Return ? CreateDateDurationRecord(_years_, _months_, _weeks_, _days_).
1. Let _dateAdd_ be ~unused~.
1. Repeat, while _years_ &ne; 0,
1. Let _moveResult_ be ? MoveRelativeDate(_calendar_, _plainRelativeTo_, _oneYear_, _dateAdd_).
1. Set _plainRelativeTo_ to _moveResult_.[[RelativeTo]].
1. Set _days_ to _days_ + _moveResult_.[[Days]].
1. Set _years_ to _years_ - _sign_.
1. Repeat, while _months_ &ne; 0,
1. Let _moveResult_ be ? MoveRelativeDate(_calendar_, _plainRelativeTo_, _oneMonth_, _dateAdd_).
1. Set _plainRelativeTo_ to _moveResult_.[[RelativeTo]].
1. Set _days_ to _days_ +_moveResult_.[[Days]].
1. Set _months_ to _months_ - _sign_.
1. Repeat, while _weeks_ &ne; 0,
1. Let _moveResult_ be ? MoveRelativeDate(_calendar_, _plainRelativeTo_, _oneWeek_, _dateAdd_).
1. Set _plainRelativeTo_ to _moveResult_.[[RelativeTo]].
1. Set _days_ to _days_ + _moveResult_.[[Days]].
1. Set _weeks_ to _weeks_ - _sign_.
1. Return ? CreateDateDurationRecord(0, 0, 0, _days_).
</emu-alg>
</emu-clause>

Expand Down