You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Editorial: Merge SubtractTimeDuration into AddTimeDuration
This previously needed to be a separate operation because you can't just
negate a record. Now that time durations are a number, you can negate
them, so no need for a subtraction operation when we already have an
addition operation.
): either a normal completion containing a time duration or a throw completion
1484
-
</h1>
1485
-
<dlclass="header">
1486
-
<dt>description</dt>
1487
-
<dd>It returns a time duration that is the difference between _one_ and _two_, throwing an exception if the result is greater than the maximum time duration.</dd>
1488
-
</dl>
1489
-
<emu-alg>
1490
-
1. Let _result_ be _one_ - _two_.
1491
-
1. If abs(_result_) > maxTimeDuration, throw a *RangeError* exception.
1. Let _unitLength_ be the value in the "Length in Nanoseconds" column of the row of <emu-xrefhref="#table-temporal-units"></emu-xref> whose "Value" column contains _unit_.
1731
1713
1. Let _roundedTimeDuration_ be ? RoundTimeDurationToIncrement(_duration_.[[Time]], _increment_ × _unitLength_, _roundingMode_).
1732
-
1. Let _beyondDaySpan_ be ? SubtractTimeDuration(_roundedTimeDuration_, _daySpan_).
1714
+
1. Let _beyondDaySpan_ be ? AddTimeDuration(_roundedTimeDuration_, -_daySpan_).
1733
1715
1. If TimeDurationSign(_beyondDaySpan_) ≠ -_sign_, then
1734
1716
1. Let _didRoundBeyondDay_ be *true*.
1735
1717
1. Let _dayDelta_ be _sign_.
@@ -1766,7 +1748,7 @@ <h1>
1766
1748
1. Let _timeDuration_ be ! Add24HourDaysToTimeDuration(_duration_.[[Time]], _duration_.[[Date]].[[Days]]).
1767
1749
1. Let _unitLength_ be the value in the "Length in Nanoseconds" column of the row of <emu-xrefhref="#table-temporal-units"></emu-xref> whose "Value" column contains _smallestUnit_.
1768
1750
1. Let _roundedNorm_ be ? RoundTimeDurationToIncrement(_timeDuration_, _unitLength_ × _increment_, _roundingMode_).
1769
-
1. Let _diffNorm_ be ! SubtractTimeDuration(_roundedNorm_, _timeDuration_).
1751
+
1. Let _diffNorm_ be ! AddTimeDuration(_roundedNorm_, -_timeDuration_).
1770
1752
1. Let _wholeDays_ be truncate(DivideTimeDuration(_timeDuration_, nsPerDay)).
1771
1753
1. Let _roundedWholeDays_ be truncate(DivideTimeDuration(_roundedNorm_, nsPerDay)).
1772
1754
1. Let _dayDelta_ be _roundedWholeDays_ - _wholeDays_.
@@ -1777,7 +1759,7 @@ <h1>
1777
1759
1. Let _remainder_ be _roundedNorm_.
1778
1760
1. If TemporalUnitCategory(_largestUnit_) is ~date~, then
1779
1761
1. Set _days_ to _roundedWholeDays_.
1780
-
1. Set _remainder_ to ! SubtractTimeDuration(_roundedNorm_, TimeDurationFromComponents(_roundedWholeDays_ * HoursPerDay, 0, 0, 0, 0, 0)).
1762
+
1. Set _remainder_ to ! AddTimeDuration(_roundedNorm_, TimeDurationFromComponents(-_roundedWholeDays_ * HoursPerDay, 0, 0, 0, 0, 0)).
1781
1763
1. Let _dateDuration_ be ? AdjustDateDurationRecord(_duration_.[[Date]], _days_).
1782
1764
1. Let _resultDuration_ be ? CombineDateAndTimeDuration(_dateDuration_, _remainder_).
1783
1765
1. Return Duration Nudge Result Record { [[Duration]]: _resultDuration_, [[NudgedEpochNs]]: _nudgedEpochNs_, [[DidExpandCalendarUnit]]: _didExpandDays_ }.
0 commit comments