Skip to content

Commit

Permalink
Editorial: Inline ZeroTimeDuration
Browse files Browse the repository at this point in the history
It now just returns 0. No need to have an operation for that.

See: #2953
  • Loading branch information
ptomato committed Oct 9, 2024
1 parent 36f1baa commit 68fe496
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 18 deletions.
17 changes: 3 additions & 14 deletions spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -1475,17 +1475,6 @@ <h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-zerotimeduration" type="abstract operation">
<h1>ZeroTimeDuration ( ): a time duration</h1>
<dl class="header">
<dt>description</dt>
<dd>It returns a time duration of zero length.</dd>
</dl>
<emu-alg>
1. Return 0.
</emu-alg>
</emu-clause>

<emu-clause id="sec-temporal-datedurationdays" type="abstract operation">
<h1>
DateDurationDays (
Expand Down Expand Up @@ -1528,7 +1517,7 @@ <h1>
1. Let _fractionalDays_ be _duration_.[[Date]].[[Days]] + DivideTimeDuration(_duration_.[[Time]], nsPerDay).
1. Let _days_ be RoundNumberToIncrement(_fractionalDays_, _increment_, _roundingMode_).
1. Let _dateDuration_ be ? AdjustDateDurationRecord(_duration_.[[Date]], _days_).
1. Return ! CombineDateAndTimeDuration(_dateDuration_, ZeroTimeDuration()).
1. Return ! CombineDateAndTimeDuration(_dateDuration_, 0).
1. Assert: TemporalUnitCategory(_unit_) is ~time~.
1. Let _divisor_ be the value in the "Length in Nanoseconds" column of the row of <emu-xref href="#table-temporal-units"></emu-xref> whose "Value" column contains _unit_.
1. Let _rounded_ be ? RoundTimeDurationToIncrement(_duration_.[[Time]], _divisor_ × _increment_, _roundingMode_).
Expand Down Expand Up @@ -1675,7 +1664,7 @@ <h1>
1. Let _didExpandCalendarUnit_ be *false*.
1. Let _resultDuration_ be _startDuration_.
1. Let _nudgedEpochNs_ be _startEpochNs_.
1. Set _resultDuration_ to ! CombineDateAndTimeDuration(_resultDuration_, ZeroTimeDuration()).
1. Set _resultDuration_ to ! CombineDateAndTimeDuration(_resultDuration_, 0).
1. Let _nudgeResult_ be Duration Nudge Result Record { [[Duration]]: _resultDuration_, [[NudgedEpochNs]]: _nudgedEpochNs_, [[DidExpandCalendarUnit]]: _didExpandCalendarUnit_ }.
1. Return the Record { [[NudgeResult]]: _nudgeResult_, [[Total]]: _total_ }.
</emu-alg>
Expand Down Expand Up @@ -1813,7 +1802,7 @@ <h1>
1. Let _beyondEnd_ be _nudgedEpochNs_ - _endEpochNs_.
1. If _beyondEnd_ &lt; 0, let _beyondEndSign_ be -1; else if _beyondEnd_ > 0, let _beyondEndSign_ be 1; else let _beyondEndSign_ be 0.
1. If _beyondEndSign_ ≠ -_sign_, then
1. Set _duration_ to ! CombineDateAndTimeDuration(_endDuration_, ZeroTimeDuration()).
1. Set _duration_ to ! CombineDateAndTimeDuration(_endDuration_, 0).
1. Else,
1. Set _done_ to *true*.
1. Set _unitIndex_ to _unitIndex_ - 1.
Expand Down
2 changes: 1 addition & 1 deletion spec/plaindate.html
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ <h1>
1. If CompareISODate(_temporalDate_.[[ISODate]], _other_.[[ISODate]]) = 0, then
1. Return ! CreateTemporalDuration(0, 0, 0, 0, 0, 0, 0, 0, 0, 0).
1. Let _dateDifference_ be CalendarDateUntil(_temporalDate_.[[Calendar]], _temporalDate_.[[ISODate]], _other_.[[ISODate]], _settings_.[[LargestUnit]]).
1. Let _duration_ be ! CombineDateAndTimeDuration(_dateDifference_, ZeroTimeDuration()).
1. Let _duration_ be ! CombineDateAndTimeDuration(_dateDifference_, 0).
1. If _settings_.[[SmallestUnit]] is not ~day~ or _settings_.[[RoundingIncrement]] ≠ 1, then
1. Let _isoDateTime_ be CombineISODateAndTimeRecord(_temporalDate_.[[ISODate]], MidnightTimeRecord()).
1. Let _isoDateTimeOther_ be CombineISODateAndTimeRecord(_other_.[[ISODate]], MidnightTimeRecord()).
Expand Down
2 changes: 1 addition & 1 deletion spec/plaindatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ <h1>
</dl>
<emu-alg>
1. If CompareISODateTime(_isoDateTime1_, _isoDateTime2_) = 0, then
1. Return ! CombineDateAndTimeDuration(ZeroDateDuration(), ZeroTimeDuration()).
1. Return ! CombineDateAndTimeDuration(ZeroDateDuration(), 0).
1. Let _diff_ be ? DifferenceISODateTime(_isoDateTime1_, _isoDateTime2_, _calendar_, _largestUnit_).
1. If _smallestUnit_ is ~nanosecond~ and _roundingIncrement_ = 1, return _diff_.
1. Let _destEpochNs_ be GetUTCEpochNanoseconds(_isoDateTime2_).
Expand Down
2 changes: 1 addition & 1 deletion spec/plainyearmonth.html
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ <h1>
1. Let _otherDate_ be ? CalendarDateFromFields(_calendar_, _otherFields_, ~constrain~).
1. Let _dateDifference_ be CalendarDateUntil(_calendar_, _thisDate_, _otherDate_, _settings_.[[LargestUnit]]).
1. Let _yearsMonthsDifference_ be ! AdjustDateDurationRecord(_dateDifference_, 0, 0).
1. Let _duration_ be ! CombineDateAndTimeDuration(_yearsMonthsDifference_, ZeroTimeDuration()).
1. Let _duration_ be ! CombineDateAndTimeDuration(_yearsMonthsDifference_, 0).
1. If _settings_.[[SmallestUnit]] is not ~month~ or _settings_.[[RoundingIncrement]] ≠ 1, then
1. Let _isoDateTime_ be CombineISODateAndTimeRecord(_thisDate_, MidnightTimeRecord()).
1. Let _isoDateTimeOther_ be CombineISODateAndTimeRecord(_otherDate_, MidnightTimeRecord()).
Expand Down
2 changes: 1 addition & 1 deletion spec/zoneddatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ <h1>
</dd>
</dl>
<emu-alg>
1. If _ns1_ = _ns2_, return ! CombineDateAndTimeDuration(ZeroDateDuration(), ZeroTimeDuration()).
1. If _ns1_ = _ns2_, return ! CombineDateAndTimeDuration(ZeroDateDuration(), 0).
1. Let _startDateTime_ be GetISODateTimeFor(_timeZone_, _ns1_).
1. Let _endDateTime_ be GetISODateTimeFor(_timeZone_, _ns2_).
1. If _ns2_ - _ns1_ &lt; 0, let _sign_ be -1; else let _sign_ be 1.
Expand Down

0 comments on commit 68fe496

Please sign in to comment.