From 8cb249048acaa9dc42f6f8213818d6e302aef6c2 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Mon, 10 Aug 2020 15:14:57 -0700 Subject: [PATCH] Split out SubtractTime as an abstract operation It's odd that we have AddTime but not SubtractTime. Regardless, we'll need to have it as a separate operation since it will be used from two places for negative duration support. --- spec/time.html | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/spec/time.html b/spec/time.html index 0019bd480e..79f79617de 100644 --- a/spec/time.html +++ b/spec/time.html @@ -212,7 +212,6 @@

Temporal.Time.prototype.plus ( _temporalDurationLike_ [ , _options_ ] )

1. Let _duration_ be ? ToLimitedTemporalDuration(_temporalDurationLike_, « »). 1. Perform ? ToTemporalDisambiguation(_options_). 1. Let _result_ be ? AddTime(_temporalTime_.[[Hour]], _temporalTime_.[[Minute]], _temporalTime_.[[Second]], _temporalTime_.[[Millisecond]], _temporalTime_.[[Microsecond]], _temporalTime_.[[Nanosecond]], _duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]]). - 1. Let _result_ be ? BalanceTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_). 1. Return ? CreateTemporalTimeFromInstance(_temporalTime_, _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]]). @@ -228,13 +227,7 @@

Temporal.Time.prototype.minus ( _temporalDurationLike_ [ , _options_ ] )

@@ -717,5 +710,19 @@

AddTime ( _hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosec 1. Return ? BalanceTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_). + + +

SubtractTime ( _hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_ )

+ + 1. Assert: _hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, and _nanoseconds_ are integer Number values. + 1. Let _hour_ be _temporalTime_.[[Hour]] - _duration_.[[Hour]]. + 1. Let _minute_ be _temporalTime_.[[Minute]] - _duration_.[[Minute]]. + 1. Let _second_ be _temporalTime_.[[Second]] - _duration_.[[Second]]. + 1. Let _millisecond_ be _temporalTime_.[[Millisecond]] - _duration_.[[Millisecond]]. + 1. Let _microsecond_ be _temporalTime_.[[Microsecond]] - _duration_.[[Microsecond]]. + 1. Let _nanosecond_ be _temporalTime_.[[Nanosecond]] - _duration_.[[Nanosecond]]. + 1. Return ? BalanceTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_). + +