From c4eaa9a478dd7bf1a7f1caa79e33682ec422097f Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Wed, 11 Oct 2023 18:31:13 -0400 Subject: [PATCH] to math: MakeTime, MakeDay, DateString, TimeZoneString, Date.prototype.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. --- spec.html | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/spec.html b/spec.html index 3643b5d4fc1..f63299470e3 100644 --- a/spec.html +++ b/spec.html @@ -32922,11 +32922,11 @@

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_).

The arithmetic in MakeTime is floating-point arithmetic, which is not associative, so the operations must be performed in the correct order.

@@ -32947,14 +32947,14 @@

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*𝔽; but if this is not possible (because some argument is out of range), return *NaN*. - 1. Return 𝔽(Day(_t_)) + _dt_ - *1*𝔽. + 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*𝔽. @@ -34095,9 +34095,9 @@

1. Let _weekday_ be the Name of the entry in whose WeekDay Index = WeekDay(_tv_). 1. Let _month_ be the Name of the entry in whose Month Index = MonthFromTime(_tv_). 1. Let _day_ be ToZeroPaddedDecimalString(DateFromTime(_tv_), 2). - 1. Let _yv_ be 𝔽(YearFromTime(_tv_)). - 1. If _yv_ is *+0*𝔽 or _yv_ > *+0*𝔽, 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_. @@ -34292,15 +34292,15 @@

1. Let _offsetNs_ be ParseTimeZoneOffsetString(_systemTimeZoneIdentifier_). 1. Else, 1. Let _offsetNs_ be GetNamedTimeZoneOffsetNanoseconds(_systemTimeZoneIdentifier_, ℤ(ℝ(_tv_) × 106)). - 1. Let _offset_ be 𝔽(truncate(_offsetNs_ / 106)). - 1. If _offset_ is *+0*𝔽 or _offset_ > *+0*𝔽, then + 1. Let _offset_ be truncate(_offsetNs_ / 106). + 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_. @@ -34347,9 +34347,9 @@

Date.prototype.toUTCString ( )

1. Let _weekday_ be the Name of the entry in whose WeekDay Index = WeekDay(_tv_). 1. Let _month_ be the Name of the entry in whose Month Index = MonthFromTime(_tv_). 1. Let _day_ be ToZeroPaddedDecimalString(DateFromTime(_tv_), 2). - 1. Let _yv_ be 𝔽(YearFromTime(_tv_)). - 1. If _yv_ is *+0*𝔽 or _yv_ > *+0*𝔽, 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_).