Skip to content

Commit

Permalink
Normative: Fix sign in PlainYearMonth.subtract
Browse files Browse the repository at this point in the history
The duration has to be negated up front, otherwise the _sign_ < 0 test is
wrong.

No change in functionality in the polyfill, which already handled this
correctly. This is already covered by tests.

Closes: #1863
  • Loading branch information
ptomato committed Mar 29, 2022
1 parent 4cb192d commit 6cf421b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spec/plainyearmonth.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ <h1>Temporal.PlainYearMonth.prototype.subtract ( _temporalDurationLike_ [ , _opt
1. Let _yearMonth_ be the *this* value.
1. Perform ? RequireInternalSlot(_yearMonth_, [[InitializedTemporalYearMonth]]).
1. Let _duration_ be ? ToTemporalDurationRecord(_temporalDurationLike_).
1. Set _duration_ to ! CreateNegatedTemporalDuration(_duration_).
1. Let _balanceResult_ be ? BalanceDuration(_duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]], *"day"*).
1. Set _options_ to ? GetOptionsObject(_options_).
1. Let _calendar_ be _yearMonth_.[[Calendar]].
Expand All @@ -295,7 +296,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

0 comments on commit 6cf421b

Please sign in to comment.