Skip to content

Commit

Permalink
Editorial: Move AddISODate into CalendarDateAdd
Browse files Browse the repository at this point in the history
This is the only place it's called from. This refactor is part of
consolidating the many calendar AOs.

See: #2948
  • Loading branch information
ptomato committed Oct 4, 2024
1 parent 5428c87 commit 2bd89f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 29 deletions.
8 changes: 7 additions & 1 deletion spec/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,17 @@ <h1>
<dt>description</dt>
<dd>
It adds _dateDuration_ to _isoDate_ using the years, months, and weeks reckoning of _calendar_.
If addition of years or months results in a nonexistent date, depending on _overflow_ it will be coerced to an existing date or the operation will throw.
</dd>
</dl>
<emu-alg>
1. If _calendar_ is *"iso8601"*, then
1. Return ? AddISODate(_isoDate_.[[Year]], _isoDate_.[[Month]], _isoDate_.[[Day]], _duration_, _overflow_).
1. Let _intermediate_ be BalanceISOYearMonth(_isoDate_.[[Year]] + _duration_.[[Years]], _isoDate_.[[Month]] + _duration_.[[Months]]).
1. Set _intermediate_ to ? RegulateISODate(_intermediate_.[[Year]], _intermediate_.[[Month]], _isoDate_.[[Day]], _overflow_).
1. Let _d_ be _intermediate_.[[Day]] + _duration_.[[Days]] + 7 × _duration_.[[Weeks]].
1. Let _result_ be BalanceISODate(_intermediate_.[[Year]], _intermediate_.[[Month]], _d_).
1. If ISODateWithinLimits(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]]) is *false*, throw a *RangeError* exception.
1. Return _result_.
1. Return ? CalendarDateAddition(_calendar_, _isoDate_, _duration_, _overflow_).
</emu-alg>
</emu-clause>
Expand Down
28 changes: 0 additions & 28 deletions spec/plaindate.html
Original file line number Diff line number Diff line change
Expand Up @@ -982,34 +982,6 @@ <h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal-addisodate" type="abstract operation">
<h1>
AddISODate (
_year_: an integer,
_month_: an integer,
_day_: an integer,
_dateDuration_: a Date Duration Record,
_overflow_: ~constrain~ or ~reject~,
): either a normal completion containing an ISO Date Record or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>
It adds the duration denoted by _dateDuration_ to the date denoted by _year_, _month_, _day_, according to ISO 8601 calendar arithmetic.
If addition of years or months results in a nonexistent date, depending on _overflow_ it will be coerced to an existing date or the operation will throw.
</dd>
</dl>
<emu-alg>
1. Assert: IsValidISODate(_year_, _month_, _day_) is *true*.
1. Let _intermediate_ be BalanceISOYearMonth(_year_ + _dateDuration_.[[Years]], _month_ + _dateDuration_.[[Months]]).
1. Set _intermediate_ to ? RegulateISODate(_intermediate_.[[Year]], _intermediate_.[[Month]], _day_, _overflow_).
1. Let _d_ be _intermediate_.[[Day]] + _dateDuration_.[[Days]] + 7 × _dateDuration_.[[Weeks]].
1. Let _result_ be BalanceISODate(_intermediate_.[[Year]], _intermediate_.[[Month]], _d_).
1. If ISODateWithinLimits(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]]) is *false*, throw a *RangeError* exception.
1. Return _result_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal-compareisodate" type="abstract operation">
<h1>
CompareISODate (
Expand Down

0 comments on commit 2bd89f8

Please sign in to comment.