Skip to content

Commit

Permalink
Editorial: Make CreateTemporalDuration infallible in PlainYearMonth a…
Browse files Browse the repository at this point in the history
…rithmetic

These operations cannot fail because they values they use as input already
come from valid durations (sometimes negated).
  • Loading branch information
ptomato committed Jan 18, 2022
1 parent c0a3824 commit 8d1685d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions spec/plainyearmonth.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ <h1>Temporal.PlainYearMonth.prototype.add ( _temporalDurationLike_ [ , _options_
1. Else,
1. Let _day_ be 1.
1. Let _date_ be ? CreateTemporalDate(_yearMonth_.[[ISOYear]], _yearMonth_.[[ISOMonth]], _day_, _calendar_).
1. Let _durationToAdd_ be ? CreateTemporalDuration(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _balanceResult_.[[Days]], 0, 0, 0, 0, 0, 0).
1. Let _durationToAdd_ be ! CreateTemporalDuration(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _balanceResult_.[[Days]], 0, 0, 0, 0, 0, 0).
1. Let _optionsCopy_ be ! OrdinaryObjectCreate(%Object.prototype%).
1. Let _entries_ be ? EnumerableOwnPropertyNames(_options_, ~key+value~).
1. For each element _nextEntry_ of _entries_, do
Expand Down Expand Up @@ -295,7 +295,7 @@ <h1>Temporal.PlainYearMonth.prototype.subtract ( _temporalDurationLike_ [ , _opt
1. Else,
1. Let _day_ be 1.
1. Let _date_ be ? CreateTemporalDate(_yearMonth_.[[ISOYear]], _yearMonth_.[[ISOMonth]], _day_, _calendar_).
1. Let _durationToAdd_ be ? CreateTemporalDuration(−_duration_.[[Years]], −_duration_.[[Months]], −_duration_.[[Weeks]], −_balanceResult_.[[Days]], 0, 0, 0, 0, 0, 0).
1. Let _durationToAdd_ be ! CreateTemporalDuration(−_duration_.[[Years]], −_duration_.[[Months]], −_duration_.[[Weeks]], −_balanceResult_.[[Days]], 0, 0, 0, 0, 0, 0).
1. Let _optionsCopy_ be ! OrdinaryObjectCreate(%Object.prototype%).
1. Let _entries_ be ? EnumerableOwnPropertyNames(_options_, ~key+value~).
1. For each element _nextEntry_ of _entries_, do
Expand Down Expand Up @@ -335,9 +335,9 @@ <h1>Temporal.PlainYearMonth.prototype.until ( _other_ [ , _options_ ] )</h1>
1. Let _untilOptions_ be ? MergeLargestUnitOption(_options_, _largestUnit_).
1. Let _result_ be ? CalendarDateUntil(_calendar_, _thisDate_, _otherDate_, _untilOptions_).
1. If _smallestUnit_ is *"month"* and _roundingIncrement_ = 1, then
1. Return ? CreateTemporalDuration(_result_.[[Years]], _result_.[[Months]], 0, 0, 0, 0, 0, 0, 0, 0).
1. Return ! CreateTemporalDuration(_result_.[[Years]], _result_.[[Months]], 0, 0, 0, 0, 0, 0, 0, 0).
1. Let _result_ be ? RoundDuration(_result_.[[Years]], _result_.[[Months]], 0, 0, 0, 0, 0, 0, 0, 0, _roundingIncrement_, _smallestUnit_, _roundingMode_, _thisDate_).
1. Return ? CreateTemporalDuration(_result_.[[Years]], _result_.[[Months]], 0, 0, 0, 0, 0, 0, 0, 0).
1. Return ! CreateTemporalDuration(_result_.[[Years]], _result_.[[Months]], 0, 0, 0, 0, 0, 0, 0, 0).
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -371,9 +371,9 @@ <h1>Temporal.PlainYearMonth.prototype.since ( _other_ [ , _options_ ] )</h1>
1. Let _untilOptions_ be ? MergeLargestUnitOption(_options_, _largestUnit_).
1. Let _result_ be ? CalendarDateUntil(_calendar_, _thisDate_, _otherDate_, _untilOptions_).
1. If _smallestUnit_ is *"month"* and _roundingIncrement_ = 1, then
1. Return ? CreateTemporalDuration(−_result_.[[Years]], −_result_.[[Months]], 0, 0, 0, 0, 0, 0, 0, 0).
1. Return ! CreateTemporalDuration(−_result_.[[Years]], −_result_.[[Months]], 0, 0, 0, 0, 0, 0, 0, 0).
1. Let _result_ be ? RoundDuration(_result_.[[Years]], _result_.[[Months]], 0, 0, 0, 0, 0, 0, 0, 0, _roundingIncrement_, _smallestUnit_, _roundingMode_, _thisDate_).
1. Return ? CreateTemporalDuration(−_result_.[[Years]], −_result_.[[Months]], 0, 0, 0, 0, 0, 0, 0, 0).
1. Return ! CreateTemporalDuration(−_result_.[[Years]], −_result_.[[Months]], 0, 0, 0, 0, 0, 0, 0, 0).
</emu-alg>
</emu-clause>

Expand Down

0 comments on commit 8d1685d

Please sign in to comment.