From 178006951f8555c9f088fceaceb874fb3509d38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Mon, 1 Jul 2024 08:10:34 +0200 Subject: [PATCH] Editorial: Pass epoch nanoseconds to FormatDateTimePattern This simplifies the Temporal integration and makes FormatDateTimePattern an infallible operation. --- spec/datetimeformat.html | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/spec/datetimeformat.html b/spec/datetimeformat.html index 52e82efd..51752134 100644 --- a/spec/datetimeformat.html +++ b/spec/datetimeformat.html @@ -1394,16 +1394,14 @@

_dateTimeFormat_: an Intl.DateTimeFormat, _format_: a DateTime Format Record or a DateTime Range Pattern Format Record, _pattern_: a Pattern String, - _x_: a Number, - ): either a normal completion containing a List of Records with fields [[Type]] (a String) and [[Value]] (a String), or a throw completion + _epochNanoseconds_: a BigInt, + ): a List of Records with fields [[Type]] (a String) and [[Value]] (a String)

description
-
It interprets _x_ as a time value as specified in es2024, , and creates the corresponding parts according to _pattern_ and to the effective locale and the formatting options of _dateTimeFormat_ and _format_.
+
It creates the corresponding parts for the epoch time _epochNanoseconds_ according to _pattern_ and to the effective locale and the formatting options of _dateTimeFormat_ and _format_.
- 1. Let _x_ be TimeClip(_x_). - 1. If _x_ is *NaN*, throw a *RangeError* exception. 1. Let _locale_ be _dateTimeFormat_.[[Locale]]. 1. Let _nfOptions_ be OrdinaryObjectCreate(*null*). 1. Perform ! CreateDataPropertyOrThrow(_nfOptions_, *"useGrouping"*, *false*). @@ -1418,7 +1416,7 @@

1. Perform ! CreateDataPropertyOrThrow(_nf3Options_, *"minimumIntegerDigits"*, 𝔽(_fractionalSecondDigits_)). 1. Perform ! CreateDataPropertyOrThrow(_nf3Options_, *"useGrouping"*, *false*). 1. Let _nf3_ be ! Construct(%Intl.NumberFormat%, « _locale_, _nf3Options_ »). - 1. Let _tm_ be ToLocalTime(ℤ(ℝ(_x_) × 106), _dateTimeFormat_.[[Calendar]], _dateTimeFormat_.[[TimeZone]]). + 1. Let _tm_ be ToLocalTime(_epochNanoseconds_, _dateTimeFormat_.[[Calendar]], _dateTimeFormat_.[[TimeZone]]). 1. Let _patternParts_ be PartitionPattern(_pattern_). 1. Let _result_ be a new empty List. 1. For each Record { [[Type]], [[Value]] } _patternPart_ of _patternParts_, do @@ -1482,7 +1480,7 @@

1. Let _fv_ be an implementation and locale dependent String value representing _v_. 1. Append the Record { [[Type]]: *"yearName"*, [[Value]]: _fv_ } to _result_. 1. Else, - 1. Let _unknown_ be an implementation-, locale-, and numbering system-dependent String based on _x_ and _p_. + 1. Let _unknown_ be an implementation-, locale-, and numbering system-dependent String based on _epochNanoseconds_ and _p_. 1. Append the Record { [[Type]]: *"unknown"*, [[Value]]: _unknown_ } to _result_. 1. Return _result_. @@ -1504,12 +1502,15 @@

It interprets _x_ as a time value as specified in es2024, , and creates the corresponding parts according to the effective locale and the formatting options of _dateTimeFormat_.
+ 1. Let _x_ be TimeClip(_x_). + 1. If _x_ is *NaN*, throw a *RangeError* exception. + 1. Let _epochNanoseconds_ be ℤ(ℝ(_x_) × 106). 1. Let _format_ be _dateTimeFormat_.[[DateTimeFormat]]. 1. If _dateTimeFormat_.[[HourCycle]] is *"h11"* or *"h12"*, then 1. Let _pattern_ be _format_.[[pattern12]]. 1. Else, 1. Let _pattern_ be _format_.[[pattern]]. - 1. Let _result_ be ? FormatDateTimePattern(_dateTimeFormat_, _format_, _pattern_, _x_). + 1. Let _result_ be FormatDateTimePattern(_dateTimeFormat_, _format_, _pattern_, _epochNanoseconds_). 1. Return _result_. @@ -1572,8 +1573,10 @@

1. If _x_ is *NaN*, throw a *RangeError* exception. 1. Set _y_ to TimeClip(_y_). 1. If _y_ is *NaN*, throw a *RangeError* exception. - 1. Let _tm1_ be ToLocalTime(ℤ(ℝ(_x_) × 106), _dateTimeFormat_.[[Calendar]], _dateTimeFormat_.[[TimeZone]]). - 1. Let _tm2_ be ToLocalTime(ℤ(ℝ(_y_) × 106), _dateTimeFormat_.[[Calendar]], _dateTimeFormat_.[[TimeZone]]). + 1. Let _xEpochNanoseconds_ be ℤ(ℝ(_x_) × 106). + 1. Let _yEpochNanoseconds_ be ℤ(ℝ(_y_) × 106). + 1. Let _tm1_ be ToLocalTime(_xEpochNanoseconds_, _dateTimeFormat_.[[Calendar]], _dateTimeFormat_.[[TimeZone]]). + 1. Let _tm2_ be ToLocalTime(_yEpochNanoseconds_, _dateTimeFormat_.[[Calendar]], _dateTimeFormat_.[[TimeZone]]). 1. Let _format_ be _dateTimeFormat_.[[DateTimeFormat]]. 1. If _dateTimeFormat_.[[HourCycle]] is *"h11"* or *"h12"*, then 1. Let _pattern_ be _format_.[[pattern12]]. @@ -1613,7 +1616,7 @@

1. Set _relevantFieldsEqual_ to *false*. 1. If _relevantFieldsEqual_ is *true*, then 1. Let _collapsedResult_ be a new empty List. - 1. Let _resultParts_ be ! FormatDateTimePattern(_dateTimeFormat_, _format_, _pattern_, _x_). + 1. Let _resultParts_ be FormatDateTimePattern(_dateTimeFormat_, _format_, _pattern_, _xEpochNanoseconds_). 1. For each Record { [[Type]], [[Value]] } _r_ of _resultParts_, do 1. Append the Record { [[Type]]: _r_.[[Type]], [[Value]]: _r_.[[Value]], [[Source]]: *"shared"* } to _collapsedResult_. 1. Return _collapsedResult_. @@ -1624,10 +1627,10 @@

1. Let _pattern_ be _rangePatternPart_.[[Pattern]]. 1. Let _source_ be _rangePatternPart_.[[Source]]. 1. If _source_ is *"startRange"* or *"shared"*, then - 1. Let _z_ be _x_. + 1. Let _z_ be _xEpochNanoseconds_. 1. Else, - 1. Let _z_ be _y_. - 1. Let _resultParts_ be ! FormatDateTimePattern(_dateTimeFormat_, _selectedRangePattern_, _pattern_, _z_). + 1. Let _z_ be _yEpochNanoseconds_. + 1. Let _resultParts_ be FormatDateTimePattern(_dateTimeFormat_, _selectedRangePattern_, _pattern_, _z_). 1. For each Record { [[Type]], [[Value]] } _r_ of _resultParts_, do 1. Append the Record { [[Type]]: _r_.[[Type]], [[Value]]: _r_.[[Value]], [[Source]]: _source_ } to _rangeResult_. 1. Return _rangeResult_.