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: CombineDateAndTimeDuration is infallible
We now have proven that all of the call sites cannot provide a date
duration and time duration with mixed signs. So we change the exception to
an assertion.
h/t Anba
Closes: #3023
1. Let _dateDuration_ be ! CreateDateDurationRecord(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _duration_.[[Days]]).
885
885
1. Let _timeDuration_ be TimeDurationFromComponents(_duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]]).
1. Let _timeDuration_ be TimeDurationFromComponents(_duration_.[[Hours]], _duration_.[[Minutes]], _duration_.[[Seconds]], _duration_.[[Milliseconds]], _duration_.[[Microseconds]], _duration_.[[Nanoseconds]]).
902
902
1. Set _timeDuration_ to ! Add24HourDaysToTimeDuration(_timeDuration_, _duration_.[[Days]]).
903
903
1. Let _dateDuration_ be ! CreateDateDurationRecord(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], 0).
): either a normal completion containing an Internal Duration Record or a throw completion
1050
+
): an Internal Duration Record
1051
1051
</h1>
1052
1052
<dlclass="header">
1053
1053
<dt>description</dt>
@@ -1056,7 +1056,7 @@ <h1>
1056
1056
<emu-alg>
1057
1057
1. Let _dateSign_ be DateDurationSign(_dateDuration_).
1058
1058
1. Let _timeSign_ be TimeDurationSign(_timeDuration_).
1059
-
1. If _dateSign_ ≠ 0 and _timeSign_ ≠ 0 and _dateSign_≠_timeSign_, throw a *RangeError* exception.
1059
+
1.Assert:If _dateSign_ ≠ 0 and _timeSign_ ≠ 0, _dateSign_=_timeSign_.
1060
1060
1. Return Internal Duration Record {
1061
1061
[[Date]]: _dateDuration_,
1062
1062
[[Time]]: _timeDuration_
@@ -1648,7 +1648,7 @@ <h1>
1648
1648
1. Let _didExpandCalendarUnit_ be *false*.
1649
1649
1. Let _resultDuration_ be _startDuration_.
1650
1650
1. Let _nudgedEpochNs_ be _startEpochNs_.
1651
-
1. Set _resultDuration_ to ! CombineDateAndTimeDuration(_resultDuration_, 0).
1651
+
1. Set _resultDuration_ to CombineDateAndTimeDuration(_resultDuration_, 0).
1652
1652
1. Let _nudgeResult_ be Duration Nudge Result Record { [[Duration]]: _resultDuration_, [[NudgedEpochNs]]: _nudgedEpochNs_, [[DidExpandCalendarUnit]]: _didExpandCalendarUnit_ }.
1653
1653
1. Return the Record { [[NudgeResult]]: _nudgeResult_, [[Total]]: _total_ }.
1654
1654
</emu-alg>
@@ -1695,7 +1695,7 @@ <h1>
1695
1695
1. Let _dayDelta_ be 0.
1696
1696
1. Let _nudgedEpochNs_ be AddTimeDurationToEpochNanoseconds(_roundedTimeDuration_, _startEpochNs_).
1697
1697
1. Let _dateDuration_ be ! AdjustDateDurationRecord(_duration_.[[Date]], _duration_.[[Date]].[[Days]] + _dayDelta_).
1698
-
1. Let _resultDuration_ be ! CombineDateAndTimeDuration(_dateDuration_, _roundedTimeDuration_).
1698
+
1. Let _resultDuration_ be CombineDateAndTimeDuration(_dateDuration_, _roundedTimeDuration_).
1699
1699
1. Return Duration Nudge Result Record { [[Duration]]: _resultDuration_, [[NudgedEpochNs]]: _nudgedEpochNs_, [[DidExpandCalendarUnit]]: _didRoundBeyondDay_ }.
1700
1700
</emu-alg>
1701
1701
</emu-clause>
@@ -1734,7 +1734,7 @@ <h1>
1734
1734
1. Set _days_ to _roundedWholeDays_.
1735
1735
1. Set _remainder_ to ! AddTimeDuration(_roundedTime_, TimeDurationFromComponents(-_roundedWholeDays_ * HoursPerDay, 0, 0, 0, 0, 0)).
1736
1736
1. Let _dateDuration_ be ! AdjustDateDurationRecord(_duration_.[[Date]], _days_).
1737
-
1. Let _resultDuration_ be ! CombineDateAndTimeDuration(_dateDuration_, _remainder_).
1737
+
1. Let _resultDuration_ be CombineDateAndTimeDuration(_dateDuration_, _remainder_).
1738
1738
1. Return Duration Nudge Result Record { [[Duration]]: _resultDuration_, [[NudgedEpochNs]]: _nudgedEpochNs_, [[DidExpandCalendarUnit]]: _didExpandDays_ }.
1739
1739
</emu-alg>
1740
1740
</emu-clause>
@@ -1786,7 +1786,7 @@ <h1>
1786
1786
1. Let _beyondEnd_ be _nudgedEpochNs_ - _endEpochNs_.
1787
1787
1. If _beyondEnd_< 0, let _beyondEndSign_ be -1; else if _beyondEnd_ > 0, let _beyondEndSign_ be 1; else let _beyondEndSign_ be 0.
1788
1788
1. If _beyondEndSign_ ≠ -_sign_, then
1789
-
1. Set _duration_ to ! CombineDateAndTimeDuration(_endDuration_, 0).
1789
+
1. Set _duration_ to CombineDateAndTimeDuration(_endDuration_, 0).
1790
1790
1. Else,
1791
1791
1. Set _done_ to *true*.
1792
1792
1. Set _unitIndex_ to _unitIndex_ - 1.
@@ -1926,7 +1926,7 @@ <h1>
1926
1926
1. Let _d1_ be ToInternalDurationRecordWith24HourDays(_duration_).
1927
1927
1. Let _d2_ be ToInternalDurationRecordWith24HourDays(_other_).
1928
1928
1. Let _timeResult_ be ? AddTimeDuration(_d1_.[[Time]], _d2_.[[Time]]).
1929
-
1. Let _result_ be ! CombineDateAndTimeDuration(ZeroDateDuration(), _timeResult_).
1929
+
1. Let _result_ be CombineDateAndTimeDuration(ZeroDateDuration(), _timeResult_).
1. Let _dateDifference_ be CalendarDateUntil(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]], _other_.[[ISODate]], _settings_.[[LargestUnit]]).
901
-
1. Let _duration_ be ! CombineDateAndTimeDuration(_dateDifference_, 0).
901
+
1. Let _duration_ be CombineDateAndTimeDuration(_dateDifference_, 0).
902
902
1. If _settings_.[[SmallestUnit]] is not ~day~ or _settings_.[[RoundingIncrement]] ≠ 1, then
903
903
1. Let _isoDateTime_ be CombineISODateAndTimeRecord(_temporalDate_.[[ISODate]], MidnightTimeRecord()).
904
904
1. Let _isoDateTimeOther_ be CombineISODateAndTimeRecord(_other_.[[ISODate]], MidnightTimeRecord()).
Copy file name to clipboardExpand all lines: spec/plaintime.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -932,7 +932,7 @@ <h1>
932
932
1. Let _settings_ be ? GetDifferenceSettings(_operation_, _resolvedOptions_, ~time~, « », ~nanosecond~, ~hour~).
933
933
1. Let _timeDuration_ be DifferenceTime(_temporalTime_.[[Time]], _other_.[[Time]]).
934
934
1. Set _timeDuration_ to ! RoundTimeDuration(_timeDuration_, _settings_.[[RoundingIncrement]], _settings_.[[SmallestUnit]], _settings_.[[RoundingMode]]).
935
-
1. Let _duration_ be ! CombineDateAndTimeDuration(ZeroDateDuration(), _timeDuration_).
935
+
1. Let _duration_ be CombineDateAndTimeDuration(ZeroDateDuration(), _timeDuration_).
936
936
1. Let _result_ be ! TemporalDurationFromInternal(_duration_, _settings_.[[LargestUnit]]).
937
937
1. If _operation_ is ~since~, set _result_ to CreateNegatedTemporalDuration(_result_).
0 commit comments