Skip to content

Commit 2a59eac

Browse files
ptomatoMs2ger
authored andcommitted
Editorial: Fix numeric type confusion in return value of GetEpochFromISOParts
Some existing algorithms treated this as a BigInt and some as a mathematical value. It's really six of one, half a dozen of the other, which is more convenient. I chose BigInt because that fits with the internal EpochNanoseconds slot of Instant and ZonedDateTime being a BigInt.
1 parent e6a15a5 commit 2a59eac

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

spec/instant.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,11 +545,11 @@ <h1>ParseTemporalInstant ( _isoString_ )</h1>
545545
1. Let _offsetString_ be _result_.[[TimeZoneOffsetString]].
546546
1. Assert: _offsetString_ is not *undefined*.
547547
1. Let _utc_ be GetEpochFromISOParts(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]]).
548-
1. If _utc_ &lt; −8.64 × 10<sup>21</sup> or _utc_ &gt; 8.64 × 10<sup>21</sup>, then
548+
1. If ℝ(_utc_) &lt; −8.64 × 10<sup>21</sup> or ℝ(_utc_) &gt; 8.64 × 10<sup>21</sup>, then
549549
1. Throw a *RangeError* exception.
550550
1. Let _offsetNanoseconds_ be ? ParseTimeZoneOffsetString(_offsetString_).
551-
1. Let _result_ be _utc__offsetNanoseconds_.
552-
1. If ! IsValidEpochNanoseconds(ℤ(_result_)) is *false*, then
551+
1. Let _result_ be _utc_ℤ(_offsetNanoseconds_).
552+
1. If ! IsValidEpochNanoseconds(_result_) is *false*, then
553553
1. Throw a *RangeError* exception.
554554
1. Return _result_.
555555
</emu-alg>

spec/plaindatetime.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ <h1>
864864
1. Let _time_ be MakeTime(𝔽(_hour_), 𝔽(_minute_), 𝔽(_second_), 𝔽(_millisecond_)).
865865
1. Let _ms_ be MakeDate(_date_, _time_).
866866
1. Assert: _ms_ is finite.
867-
1. Return ℝ(_ms_) × 10<sup>6</sup> + _microsecond_ × 10<sup>3</sup> + _nanosecond_.
867+
1. Return ℤ(ℝ(_ms_) × 10<sup>6</sup> + _microsecond_ × 10<sup>3</sup> + _nanosecond_).
868868
</emu-alg>
869869
</emu-clause>
870870

@@ -893,7 +893,7 @@ <h1>
893893
</p>
894894
</emu-note>
895895
<emu-alg>
896-
1. Let _ns_ be GetEpochFromISOParts(_year_, _month_, _day_, _hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_).
896+
1. Let _ns_ be ℝ(GetEpochFromISOParts(_year_, _month_, _day_, _hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_)).
897897
1. If _ns_ ≤ -8.64 × 10<sup>21</sup> - 8.64 × 10<sup>13</sup>, then
898898
1. Return *false*.
899899
1. If _ns_ ≥ 8.64 × 10<sup>21</sup> + 8.64 × 10<sup>13</sup>, then

spec/timezone.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ <h1>Temporal.TimeZone.prototype.getPossibleInstantsFor ( _dateTime_ )</h1>
281281
1. Set _dateTime_ to ? ToTemporalDateTime(_dateTime_).
282282
1. If _timeZone_.[[OffsetNanoseconds]] is not *undefined*, then
283283
1. Let _epochNanoseconds_ be GetEpochFromISOParts(_dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]]).
284-
1. Let _instant_ be ! CreateTemporalInstant(ℤ(_epochNanoseconds__timeZone_.[[OffsetNanoseconds]])).
284+
1. Let _instant_ be ! CreateTemporalInstant(_epochNanoseconds_ℤ(_timeZone_.[[OffsetNanoseconds]])).
285285
1. Return CreateArrayFromList(« _instant_ »).
286286
1. Let _possibleEpochNanoseconds_ be GetIANATimeZoneEpochValue(_timeZone_.[[Identifier]], _dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]]).
287287
1. Let _possibleInstants_ be a new empty List.
@@ -698,8 +698,8 @@ <h1>DisambiguatePossibleInstants ( _possibleInstants_, _timeZone_, _dateTime_, _
698698
1. If _disambiguation_ is *"reject"*, then
699699
1. Throw a *RangeError* exception.
700700
1. Let _epochNanoseconds_ be GetEpochFromISOParts(_dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]]).
701-
1. Let _dayBefore_ be ! CreateTemporalInstant(_epochNanoseconds_ − 8.64 × 10<sup>13</sup>).
702-
1. Let _dayAfter_ be ! CreateTemporalInstant(_epochNanoseconds_ + 8.64 × 10<sup>13</sup>).
701+
1. Let _dayBefore_ be ! CreateTemporalInstant(_epochNanoseconds_*8.64 × 10<sup>13</sup>*<sub>ℤ</sub>).
702+
1. Let _dayAfter_ be ! CreateTemporalInstant(_epochNanoseconds_ + *8.64 × 10<sup>13</sup>*<sub>ℤ</sub>).
703703
1. Let _offsetBefore_ be ? GetOffsetNanosecondsFor(_timeZone_, _dayBefore_).
704704
1. Let _offsetAfter_ be ? GetOffsetNanosecondsFor(_timeZone_, _dayAfter_).
705705
1. Let _nanoseconds_ be _offsetAfter__offsetBefore_.

spec/zoneddatetime.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ <h1>
11191119
1. Return _instant_.[[Nanoseconds]].
11201120
1. If _offsetBehaviour_ is ~exact~, or _offsetOption_ is *"use"*, then
11211121
1. Let _epochNanoseconds_ be GetEpochFromISOParts(_year_, _month_, _day_, _hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_).
1122-
1. Return _epochNanoseconds__offsetNanoseconds_.
1122+
1. Return _epochNanoseconds_ℤ(_offsetNanoseconds_).
11231123
1. Assert: _offsetBehaviour_ is ~option~.
11241124
1. Assert: _offsetOption_ is *"prefer"* or *"reject"*.
11251125
1. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_).

0 commit comments

Comments
 (0)