Skip to content

Commit

Permalink
to math: MakeTime, MakeDay, DateString, TimeZoneString, Date.prototyp…
Browse files Browse the repository at this point in the history
…e.toUTCString (some internals only)

Generally, this just delays invocations of overstruck-F.
In some cases, this causes some comparisons (but not arithmetic)
to shift from Number to mathematical.
  • Loading branch information
jmdyck committed Feb 25, 2024
1 parent 5627876 commit 642d237
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -32835,11 +32835,11 @@ <h1>
</dl>
<emu-alg>
1. If _hour_ is not finite, _min_ is not finite, _sec_ is not finite, or _ms_ is not finite, return *NaN*.
1. Let _h_ be 𝔽(! ToIntegerOrInfinity(_hour_)).
1. Let _m_ be 𝔽(! ToIntegerOrInfinity(_min_)).
1. Let _s_ be 𝔽(! ToIntegerOrInfinity(_sec_)).
1. Let _milli_ be 𝔽(! ToIntegerOrInfinity(_ms_)).
1. Return ((_h_ × 𝔽(msPerHour) + _m_ × 𝔽(msPerMinute)) + _s_ × 𝔽(msPerSecond)) + _milli_.
1. Let _h_ be ! ToIntegerOrInfinity(_hour_).
1. Let _m_ be ! ToIntegerOrInfinity(_min_).
1. Let _s_ be ! ToIntegerOrInfinity(_sec_).
1. Let _milli_ be ! ToIntegerOrInfinity(_ms_).
1. Return ((𝔽(_h_) × 𝔽(msPerHour) + 𝔽(_m_) × 𝔽(msPerMinute)) + 𝔽(_s_) × 𝔽(msPerSecond)) + 𝔽(_milli_).
</emu-alg>
<emu-note>
<p>The arithmetic in MakeTime is floating-point arithmetic, which is not associative, so the operations must be performed in the correct order.</p>
Expand All @@ -32860,14 +32860,14 @@ <h1>
</dl>
<emu-alg>
1. If _year_ is not finite, _month_ is not finite, or _date_ is not finite, return *NaN*.
1. Let _y_ be 𝔽(! ToIntegerOrInfinity(_year_)).
1. Let _m_ be 𝔽(! ToIntegerOrInfinity(_month_)).
1. Let _dt_ be 𝔽(! ToIntegerOrInfinity(_date_)).
1. Let _ym_ be _y_ + 𝔽(floor(ℝ(_m_) / 12)).
1. Let _y_ be ! ToIntegerOrInfinity(_year_).
1. Let _m_ be ! ToIntegerOrInfinity(_month_).
1. Let _dt_ be ! ToIntegerOrInfinity(_date_).
1. Let _ym_ be 𝔽(_y_) + 𝔽(floor(_m_ / 12)).
1. If _ym_ is not finite, return *NaN*.
1. Let _mn_ be 𝔽(ℝ(_m_) modulo 12).
1. Find a finite time value _t_ such that 𝔽(YearFromTime(_t_)) is _ym_, 𝔽(MonthFromTime(_t_)) is _mn_, and 𝔽(DateFromTime(_t_)) is *1*<sub>𝔽</sub>; but if this is not possible (because some argument is out of range), return *NaN*.
1. Return 𝔽(Day(_t_)) + _dt_ - *1*<sub>𝔽</sub>.
1. Let _mn_ be _m_ modulo 12.
1. Find a finite time value _t_ such that YearFromTime(_t_) is ℝ(_ym_), MonthFromTime(_t_) is _mn_, and DateFromTime(_t_) is 1; but if this is not possible (because some argument is out of range), return *NaN*.
1. Return 𝔽(Day(_t_)) + 𝔽(_dt_) - *1*<sub>𝔽</sub>.
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -34009,9 +34009,9 @@ <h1>
1. Let _weekday_ be the Name of the entry in <emu-xref href="#sec-todatestring-day-names"></emu-xref> whose WeekDay Index = WeekDay(_tv_).
1. Let _month_ be the Name of the entry in <emu-xref href="#sec-todatestring-month-names"></emu-xref> whose Month Index = MonthFromTime(_tv_).
1. Let _day_ be ToZeroPaddedDecimalString(DateFromTime(_tv_), 2).
1. Let _yv_ be 𝔽(YearFromTime(_tv_)).
1. If _yv_ is *+0*<sub>𝔽</sub> or _yv_ > *+0*<sub>𝔽</sub>, let _yearSign_ be the empty String; otherwise, let _yearSign_ be *"-"*.
1. Let _paddedYear_ be ToZeroPaddedDecimalString(abs(ℝ(_yv_)), 4).
1. Let _yv_ be YearFromTime(_tv_).
1. If _yv_ ≥ 0, let _yearSign_ be the empty String; otherwise, let _yearSign_ be *"-"*.
1. Let _paddedYear_ be ToZeroPaddedDecimalString(abs(_yv_), 4).
1. Return the string-concatenation of _weekday_, the code unit 0x0020 (SPACE), _month_, the code unit 0x0020 (SPACE), _day_, the code unit 0x0020 (SPACE), _yearSign_, and _paddedYear_.
</emu-alg>
<emu-table id="sec-todatestring-day-names" caption="Names of days of the week">
Expand Down Expand Up @@ -34206,15 +34206,15 @@ <h1>
1. Let _offsetNs_ be ParseTimeZoneOffsetString(_systemTimeZoneIdentifier_).
1. Else,
1. Let _offsetNs_ be GetNamedTimeZoneOffsetNanoseconds(_systemTimeZoneIdentifier_, ℤ(ℝ(_tv_) × 10<sup>6</sup>)).
1. Let _offset_ be 𝔽(truncate(_offsetNs_ / 10<sup>6</sup>)).
1. If _offset_ is *+0*<sub>𝔽</sub> or _offset_ > *+0*<sub>𝔽</sub>, then
1. Let _offset_ be truncate(_offsetNs_ / 10<sup>6</sup>).
1. If _offset_ ≥ 0, then
1. Let _offsetSign_ be *"+"*.
1. Let _absOffset_ be _offset_.
1. Else,
1. Let _offsetSign_ be *"-"*.
1. Let _absOffset_ be -_offset_.
1. Let _offsetMin_ be ToZeroPaddedDecimalString(MinFromTime(_absOffset_), 2).
1. Let _offsetHour_ be ToZeroPaddedDecimalString(HourFromTime(_absOffset_), 2).
1. Let _offsetMin_ be ToZeroPaddedDecimalString(MinFromTime(𝔽(_absOffset_)), 2).
1. Let _offsetHour_ be ToZeroPaddedDecimalString(HourFromTime(𝔽(_absOffset_)), 2).
1. Let _tzName_ be an implementation-defined string that is either the empty String or the string-concatenation of the code unit 0x0020 (SPACE), the code unit 0x0028 (LEFT PARENTHESIS), an implementation-defined timezone name, and the code unit 0x0029 (RIGHT PARENTHESIS).
1. Return the string-concatenation of _offsetSign_, _offsetHour_, _offsetMin_, and _tzName_.
</emu-alg>
Expand Down Expand Up @@ -34261,9 +34261,9 @@ <h1>Date.prototype.toUTCString ( )</h1>
1. Let _weekday_ be the Name of the entry in <emu-xref href="#sec-todatestring-day-names"></emu-xref> whose WeekDay Index = WeekDay(_tv_).
1. Let _month_ be the Name of the entry in <emu-xref href="#sec-todatestring-month-names"></emu-xref> whose Month Index = MonthFromTime(_tv_).
1. Let _day_ be ToZeroPaddedDecimalString(DateFromTime(_tv_), 2).
1. Let _yv_ be 𝔽(YearFromTime(_tv_)).
1. If _yv_ is *+0*<sub>𝔽</sub> or _yv_ > *+0*<sub>𝔽</sub>, let _yearSign_ be the empty String; otherwise, let _yearSign_ be *"-"*.
1. Let _paddedYear_ be ToZeroPaddedDecimalString(abs(ℝ(_yv_)), 4).
1. Let _yv_ be YearFromTime(_tv_).
1. If _yv_ ≥ 0, let _yearSign_ be the empty String; otherwise, let _yearSign_ be *"-"*.
1. Let _paddedYear_ be ToZeroPaddedDecimalString(abs(_yv_), 4).
1. Return the string-concatenation of _weekday_, *","*, the code unit 0x0020 (SPACE), _day_, the code unit 0x0020 (SPACE), _month_, the code unit 0x0020 (SPACE), _yearSign_, _paddedYear_, the code unit 0x0020 (SPACE), and TimeString(_tv_).
</emu-alg>
</emu-clause>
Expand Down

0 comments on commit 642d237

Please sign in to comment.