Skip to content

Commit

Permalink
Editorial: Inline CheckISODaysRange
Browse files Browse the repository at this point in the history
  • Loading branch information
anba committed Oct 17, 2024
1 parent c20450b commit 15f103a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 35 deletions.
21 changes: 0 additions & 21 deletions spec/abstractops.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,6 @@ <h1>Date Equations</h1>
<emu-note type="editor"> Note that the operation EpochTimeToMonthInYear(_t_) uses 0-based months unlike rest of Temporal since it's intended to be unified with MonthFromTime(_t_) when the above mentioned issue is fixed.</emu-note>
</emu-clause>

<emu-clause id="sec-checkisodaysrange" type="abstract operation">
<h1>
CheckISODaysRange (
_isoDateTime_: an ISO Date-Time Record,
): either a normal completion containing ~unused~ or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It checks that the given date-time is within the range of 10<sup>8</sup> days from the epoch.</dd>
</dl>
<emu-alg>
1. If ISODateTimeWithinLimits(_isoDateTime_) is *false*, then
1. Throw a *RangeError* exception.
1. Return ~unused~.
</emu-alg>
<emu-note type="editor">
This operation is solely present to ensure that GetUTCEpochNanoseconds is not called with numbers that are too large.
This operation can be removed with no observable effect when https://github.com/tc39/ecma262/issues/1087 is fixed.
</emu-note>
</emu-clause>

<emu-clause id="sec-temporal-units">
<h1>Units</h1>
<p>
Expand Down
10 changes: 5 additions & 5 deletions spec/duration.html
Original file line number Diff line number Diff line change
Expand Up @@ -1638,8 +1638,8 @@ <h1>
1. Let _startEpochNs_ be GetUTCEpochNanoseconds(_startDateTime_).
1. Let _endEpochNs_ be GetUTCEpochNanoseconds(_endDateTime_).
1. Else,
1. Perform ? CheckISODaysRange(_startDateTime_).
1. Perform ? CheckISODaysRange(_endDateTime_).
1. If ISODateTimeWithinLimits(_startDateTime_) is *false*, throw a *RangeError* exception.
1. If ISODateTimeWithinLimits(_endDateTime_) is *false*, throw a *RangeError* exception.
1. Let _startEpochNs_ be ? GetEpochNanosecondsFor(_timeZone_, _startDateTime_, ~compatible~).
1. Let _endEpochNs_ be ? GetEpochNanosecondsFor(_timeZone_, _endDateTime_, ~compatible~).
1. If _sign_ is 1, then
Expand Down Expand Up @@ -1694,10 +1694,10 @@ <h1>
<emu-alg>
1. Let _start_ be ? CalendarDateAdd(_calendar_, _isoDateTime_.[[ISODate]], _duration_.[[Date]], ~constrain~).
1. Let _startDateTime_ be CombineISODateAndTimeRecord(_start_, _isoDateTime_.[[Time]]).
1. Perform ? CheckISODaysRange(_startDateTime_).
1. If ISODateTimeWithinLimits(_startDateTime_) is *false*, throw a *RangeError* exception.
1. Let _endDate_ be AddDaysToISODate(_start_, _sign_).
1. Let _endDateTime_ be CombineISODateAndTimeRecord(_endDate_, _isoDateTime_.[[Time]]).
1. Perform ? CheckISODaysRange(_endDateTime_).
1. If ISODateTimeWithinLimits(_endDateTime_) is *false*, throw a *RangeError* exception.
1. Let _startEpochNs_ be ? GetEpochNanosecondsFor(_timeZone_, _startDateTime_, ~compatible~).
1. Let _endEpochNs_ be ? GetEpochNanosecondsFor(_timeZone_, _endDateTime_, ~compatible~).
1. Let _daySpan_ be TimeDurationFromEpochNanosecondsDifference(_endEpochNs_, _startEpochNs_).
Expand Down Expand Up @@ -1802,7 +1802,7 @@ <h1>
1. If _timeZone_ is ~unset~, then
1. Let _endEpochNs_ be GetUTCEpochNanoseconds(_endDateTime_).
1. Else,
1. Perform ? CheckISODaysRange(_endDateTime_).
1. If ISODateTimeWithinLimits(_endDateTime_) is *false*, throw a *RangeError* exception.
1. Let _endEpochNs_ be ? GetEpochNanosecondsFor(_timeZone_, _endDateTime_, ~compatible~).
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.
Expand Down
2 changes: 1 addition & 1 deletion spec/instant.html
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ <h1>
1. If _parsed_.[[Time]] is ~start-of-day~, let _time_ be MidnightTimeRecord(); else let _time_ be _parsed_.[[Time]].
1. Let _isoDate_ be CreateISODateRecord(_parsed_.[[Year]], _parsed_.[[Month]], _parsed_.[[Day]]).
1. Let _isoDateTime_ be CombineISODateAndTimeRecord(_isoDate_, _time_).
1. Perform ? CheckISODaysRange(_isoDateTime_).
1. If ISODateTimeWithinLimits(_isoDateTime_) is *false*, throw a *RangeError* exception.
1. Let _epochNanoseconds_ be GetUTCEpochNanoseconds(_isoDateTime_) - _offsetNanoseconds_.
1. If IsValidEpochNanoseconds(_epochNanoseconds_) is *false*, throw a *RangeError* exception.
1. Return ! CreateTemporalInstant(_epochNanoseconds_).
Expand Down
2 changes: 1 addition & 1 deletion spec/plaindate.html
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ <h1>Temporal.PlainDate.prototype.toZonedDateTime ( _item_ )</h1>
1. Else,
1. Set _temporalTime_ to ? ToTemporalTime(_temporalTime_).
1. Let _isoDateTime_ be CombineISODateAndTimeRecord(_temporalDate_.[[ISODate]], _temporalTime_.[[Time]]).
1. Perform ? CheckISODaysRange(_isoDateTime_).
1. If ISODateTimeWithinLimits(_isoDateTime_) is *false*, throw a *RangeError* exception.
1. Let _epochNs_ be ? GetEpochNanosecondsFor(_timeZone_, _isoDateTime_, ~compatible~).
1. Return ! CreateTemporalZonedDateTime(_epochNs_, _timeZone_, _temporalDate_.[[Calendar]]).
</emu-alg>
Expand Down
6 changes: 3 additions & 3 deletions spec/timezone.html
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ <h1>
1. Let _earlierTime_ be AddTime(_isoDateTime_.[[Time]], _timeDuration_).
1. Let _earlierDate_ be AddDaysToISODate(_isoDateTime_.[[ISODate]], _earlierTime_.[[Days]]).
1. Let _earlierDateTime_ be CombineISODateAndTimeRecord(_earlierDate_, _earlierTime_).
1. Perform ? CheckISODaysRange(_earlierDateTime_).
1. If ISODateTimeWithinLimits(_earlierDateTime_) is *false*, throw a *RangeError* exception.
1. Set _possibleEpochNs_ to ? GetPossibleEpochNanoseconds(_timeZone_, _earlierDateTime_).
1. Assert: _possibleEpochNs_ is not empty.
1. Return _possibleEpochNs_[0].
Expand All @@ -332,7 +332,7 @@ <h1>
1. Let _laterTime_ be AddTime(_isoDateTime_.[[Time]], _timeDuration_).
1. Let _laterDate_ be AddDaysToISODate(_isoDateTime_.[[ISODate]], _laterTime_.[[Days]]).
1. Let _laterDateTime_ be CombineISODateAndTimeRecord(_laterDate_, _laterTime_).
1. Perform ? CheckISODaysRange(_laterDateTime_).
1. If ISODateTimeWithinLimits(_laterDateTime_) is *false*, throw a *RangeError* exception.
1. Set _possibleEpochNs_ to ? GetPossibleEpochNanoseconds(_timeZone_, _laterDateTime_).
1. Set _n_ to _possibleEpochNs_'s length.
1. Assert: _n_ ≠ 0.
Expand Down Expand Up @@ -381,7 +381,7 @@ <h1>
</dl>
<emu-alg>
1. Let _isoDateTime_ be CombineISODateAndTimeRecord(_isoDate_, MidnightTimeRecord()).
1. Perform ? CheckISODaysRange(_isoDateTime_).
1. If ISODateTimeWithinLimits(_isoDateTime_) is *false*, throw a *RangeError* exception.
1. Let _possibleEpochNs_ be ? GetPossibleEpochNanoseconds(_timeZone_, _isoDateTime_).
1. If _possibleEpochNs_ is not empty, return _possibleEpochNs_[0].
1. Assert: IsOffsetTimeZoneIdentifier(_timeZone_) is *false*.
Expand Down
8 changes: 4 additions & 4 deletions spec/zoneddatetime.html
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ <h1>Temporal.ZonedDateTime.prototype.withPlainTime ( [ _plainTimeLike_ ] )</h1>
1. Else,
1. Let _plainTime_ be ? ToTemporalTime(_plainTimeLike_).
1. Let _resultISODateTime_ be CombineISODateAndTimeRecord(_isoDateTime_.[[ISODate]], _plainTime_.[[Time]]).
1. Perform ? CheckISODaysRange(_resultISODateTime_).
1. If ISODateTimeWithinLimits(_resultISODateTime_) is *false*, throw a *RangeError* exception.
1. Let _epochNs_ be ? GetEpochNanosecondsFor(_timeZone_, _resultISODateTime_, ~compatible~).
1. Return ! CreateTemporalZonedDateTime(_epochNs_, _timeZone_, _calendar_).
</emu-alg>
Expand Down Expand Up @@ -907,7 +907,7 @@ <h1>
</dd>
</dl>
<emu-alg>
1. Perform ? CheckISODaysRange(_isoDateTime_).
1. If ISODateTimeWithinLimits(_isoDateTime_) is *false*, throw a *RangeError* exception.
1. If _offsetBehaviour_ is ~wall~, or _offsetBehaviour_ is ~option~ and _offsetOption_ is ~ignore~, then
1. Return ? GetEpochNanosecondsFor(_timeZone_, _isoDateTime_, _disambiguation_).
1. If _offsetBehaviour_ is ~exact~, or _offsetBehaviour_ is ~option~ and _offsetOption_ is ~use~, then
Expand Down Expand Up @@ -1091,7 +1091,7 @@ <h1>
1. Let _isoDateTime_ be GetISODateTimeFor(_timeZone_, _epochNanoseconds_).
1. Let _addedDate_ be ? CalendarDateAdd(_calendar_, _isoDateTime_.[[ISODate]], _duration_.[[Date]], _overflow_).
1. Let _intermediateDateTime_ be CombineISODateAndTimeRecord(_addedDate_, _isoDateTime_.[[Time]]).
1. Perform ? CheckISODaysRange(_intermediateDateTime_).
1. If ISODateTimeWithinLimits(_intermediateDateTime_) is *false*, throw a *RangeError* exception.
1. Let _intermediateNs_ be ! GetEpochNanosecondsFor(_timeZone_, _intermediateDateTime_, ~compatible~).
1. Return ? AddInstant(_intermediateNs_, _duration_.[[Time]]).
</emu-alg>
Expand Down Expand Up @@ -1128,7 +1128,7 @@ <h1>
1. Repeat, while _dayCorrection__maxDayCorrection_ and _success_ is *false*,
1. Let _intermediateDate_ be AddDaysToISODate(_endDateTime_.[[ISODate]], _dayCorrection_ × _sign_).
1. Let _intermediateDateTime_ be CombineISODateAndTimeRecord(_intermediateDate_, _startDateTime_.[[Time]]).
1. Perform ? CheckISODaysRange(_intermediateDateTime_).
1. If ISODateTimeWithinLimits(_intermediateDateTime_) is *false*, throw a *RangeError* exception.
1. Let _intermediateNs_ be ? GetEpochNanosecondsFor(_timeZone_, _intermediateDateTime_, ~compatible~).
1. Set _timeDuration_ to TimeDurationFromEpochNanosecondsDifference(_ns2_, _intermediateNs_).
1. Let _timeSign_ be TimeDurationSign(_timeDuration_).
Expand Down

0 comments on commit 15f103a

Please sign in to comment.