Skip to content

Commit

Permalink
Update the spec for PlainDate.add/subtract. (#1269)
Browse files Browse the repository at this point in the history
* Update the spec for PlainDate.add/subtract.

Fixes #1251.

* Address code review comment

dateSubtract no longer exists.

Co-authored-by: Philip Chimento <pchimento@igalia.com>
  • Loading branch information
Ms2ger and ptomato authored Jan 13, 2021
1 parent b097828 commit 9f3a4cc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions spec/plaindate.html
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,11 @@ <h1>Temporal.PlainDate.prototype.add ( _temporalDurationLike_ [ , _options_ ] )<
1. Let _balanceResult_ be ? BalanceDuration(_duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]], *"days"*).
1. Set _options_ to ? NormalizeOptionsObject(_options_).
1. Let _overflow_ be ? ToTemporalOverflow(_options_).
1. Let _result_ be ? AddDate(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]], _duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _balanceResult_.[[Days]], _overflow_).
1. Assert: ! ValidateDate(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]]) is *true*.
1. Return ? CreateTemporalDateFromInstance(_temporalDate_, _result_.[[Year]], _result_.[[Month]], _result_.[[Day]]).
1. Let _dateAddOptions_ be ! OrdinaryObjectCreate(%Object.prototype%).
1. Perform ! CreateDataPropertyOrThrow(_dateAddOptions_, *"overflow"*, _overflow_).
1. Let _constructor_ be ? SpeciesConstructor(_temporalDate_, %Temporal.PlainDate%).
1. Let _dateAdd_ be ? Get(_calendar_, *"dateAdd"*).
1. Return ? Call(_dateAdd_, _calendar_, « _temporalDate_, _duration_, _dateAddOptions_, _constructor_ »).
</emu-alg>
</emu-clause>

Expand All @@ -391,9 +393,12 @@ <h1>Temporal.PlainDate.prototype.subtract ( _temporalDurationLike_ [ , _options_
1. Let _balanceResult_ be ? BalanceDuration(_duration_.[[Days]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]], *"days"*).
1. Set _options_ to ? NormalizeOptionsObject(_options_).
1. Let _overflow_ be ? ToTemporalOverflow(_options_).
1. Let _result_ be ? SubtractDate(_temporalDate_.[[ISOYear]], _temporalDate_.[[ISOMonth]], _temporalDate_.[[ISODay]], _duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _balanceResult_.[[Days]], _overflow_).
1. Assert: ! ValidateDate(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]]) is *true*.
1. Return ? CreateTemporalDateFromInstance(_temporalDate_, _result_.[[Year]], _result_.[[Month]], _result_.[[Day]]).
1. Let _negatedDuration_ be ? CreateTemporalDuration(−_duration_.[[Years]], −_duration_.[[Months]], −_duration_.[[Weeks]], −_duration_.[[Days]], −_duration_.[[Hours]], −_duration_.[[Minutes]], −_duration_.[[Seconds]], −_duration_.[[Milliseconds]], −_duration_.[[Microseconds]], −_duration_.[[Nanoseconds]]).
1. Let _dateAddOptions_ be ! OrdinaryObjectCreate(%Object.prototype%).
1. Perform ! CreateDataPropertyOrThrow(_dateAddOptions_, *"overflow"*, _overflow_).
1. Let _constructor_ be ? SpeciesConstructor(_temporalDate_, %Temporal.PlainDate%).
1. Let _dateAdd_ be ? Get(_calendar_, *"dateAdd"*).
1. Return ? Call(_dateAdd_, _calendar_, « _temporalDate_, _negatedDuration_, _dateAddOptions_, _constructor_ »).
</emu-alg>
</emu-clause>

Expand Down

0 comments on commit 9f3a4cc

Please sign in to comment.