Skip to content

Commit 3dc06e1

Browse files
ryzokukenMs2ger
authored andcommitted
spec: rebase intl spec on fractionalSecondDigits
1 parent 04dc86c commit 3dc06e1

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

spec/intl.html

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ <h1>InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )</h1>
154154
1. Let _opt_ be a new Record.
155155
1. For each row of <emu-xref href="#table-datetimeformat-components"></emu-xref>, except the header row, in table order, do
156156
1. Let _prop_ be the name given in the Property column of the row.
157-
1. Let _value_ be ? GetOption(_options_, _prop_, *"string"*, « the strings given in the Values column of the row », *undefined*).
157+
1. If _prop_ is *"fractionalSecondDigits"*, then
158+
1. Let _value_ be ? GetNumberOption(options, *"fractionalSecondDigits"*, 1, 3, *undefined*).
159+
1. Else,
160+
1. Let _value_ be ? GetOption(_options_, _prop_, *"string"*, « the strings given in the Values column of the row », *undefined*).
158161
1. Set _opt_.[[&lt;_prop_&gt;]] to _value_.
159162
1. <del>Let _dataLocaleData_ be _localeData_.[[&lt;_dataLocale_&gt;]].</del>
160163
1. Let _formats_ be _dataLocaleData_.[[formats]].[[&lt;_calendar_&gt;]].
@@ -379,13 +382,24 @@ <h1>PartitionDateTimePattern ( _dateTimeFormat_, _x_ )</h1>
379382
1. Perform ! CreateDataPropertyOrThrow(_nf2Options_, *"minimumIntegerDigits"*, 2).
380383
1. Perform ! CreateDataPropertyOrThrow(_nf2Options_, *"useGrouping"*, *false*).
381384
1. Let _nf2_ be ? Construct(%NumberFormat%, « _locale_, _nf2Options_ »).
385+
1. Let _fractionalSecondDigits_ be _dateTimeFormat_.[[FractionalSecondDigits]].
386+
1. If _fractionalSecondDigits_ is not *undefined*, then
387+
1. Let _nf3Options_ be ObjectCreate(*null*).
388+
1. Perform ! CreateDataPropertyOrThrow(_nf3Options_, *"minimumIntegerDigits"*, _fractionalSecondDigits_).
389+
1. Perform ! CreateDataPropertyOrThrow(_nf3Options_, *"useGrouping"*, *false*).
390+
1. Let _nf3_ be ? Construct(%NumberFormat%, « _locale_, _nf3Options_ »).
382391
1. Let _tm_ be ToLocalTime(<del>_x_</del><ins>_epochNanoseconds_</ins>, _dateTimeFormat_.[[Calendar]], _dateTimeFormat_.[[TimeZone]]).
383392
1. Let _result_ be a new empty List.
384393
1. Let _patternParts_ be PartitionPattern(<del>_dateTimeFormat_.[[Pattern]]</del><ins>_pattern_</ins>).
385394
1. For each element _patternPart_ of _patternParts_, in List order, do
386395
1. Let _p_ be _patternPart_.[[Type]].
387396
1. If _p_ is *"literal"*, then
388397
1. Append a new Record { [[Type]]: *"literal"*, [[Value]]: _patternPart_.[[Value]] } as the last element of the list _result_.
398+
1. Else if _p_ is equal to *"fractionalSecondDigits"*, then
399+
1. Let _v_ be _tm_.[[Millisecond]].
400+
1. Let _v_ be floor(_v_ × 10<sup>( _fractionalSecondDigits_ - 3 )</sup>).
401+
1. Let _fv_ be FormatNumeric(_nf3_, _v_).
402+
1. Append a new Record { [[Type]]: *"fractionalSecond"*, [[Value]]: _fv_ } as the last element of _result_.
389403
1. Else if _p_ matches a Property column of the row in <emu-xref href="#table-datetimeformat-components"></emu-xref>, then
390404
1. Let _f_ be <del>the value of _dateTimeFormat_'s internal slot whose name is the Internal Slot column of the matching row</del><ins>_pattern_.[[&lt;_p_&gt;]]</ins>.
391405
1. Let _v_ be the value of _tm_'s field whose name is the Internal Slot column of the matching row.
@@ -608,6 +622,13 @@ <h1>ToLocalTime ( _t_, _calendar_, _timeZone_ )</h1>
608622
<ins>! SecFromTime(_tz_ / 10<sup>6</sup>)</ins>
609623
</td>
610624
</tr>
625+
<tr>
626+
<td>[[Millisecond]]</td>
627+
<td>
628+
<del>`msFromTime(tz)` specified in ES2021's <emu-xref href="#sec-hours-minutes-second-and-milliseconds">Hours, Minutes, Second, and Milliseconds</emu-xref></del>
629+
<ins>! msFromTime(_tz_ / 10<sup>6</sup>)</ins>
630+
</td>
631+
</tr>
611632
<tr>
612633
<td><ins>[[Nanosecond]]</td>
613634
<td><ins>_tz_ modulo 10<sup>9</sup></td>
@@ -763,6 +784,11 @@ <h1>Intl.DateTimeFormat.prototype.resolvedOptions ( )</h1>
763784
<td>*"second"*</td>
764785
<td><ins>~pattern~</ins></td>
765786
</tr>
787+
<tr>
788+
<td><del>[[FractionalSecondDigits]]</del><ins>[[fractionalSecondDigits]]</td>
789+
<td>*"fractionalSecondDigits"*</td>
790+
<td><ins>~pattern~</ins></td>
791+
</tr>
766792
<tr>
767793
<td><del>[[TimeZoneName]]</del><ins>[[timeZoneName]]</ins></td>
768794
<td>*"timeZoneName"*</td>
@@ -806,6 +832,7 @@ <h1><a href="https://tc39.es/ecma402/#sec-properties-of-intl-datetimeformat-inst
806832
<li>[[NumberingSystem]] is a String value with the *"type"* given in Unicode Technical Standard 35 for the numbering system used for formatting.</li>
807833
<li>[[TimeZone]] is a String value with the IANA time zone name of the time zone used for formatting.</li>
808834
<li><del>[[Weekday]], [[Era]], [[Year]], [[Month]], [[Day]], [[Hour]], [[Minute]], [[Second]], [[TimeZoneName]] are each either *undefined*, indicating that the component is not used for formatting, or one of the String values given in <emu-xref href="#table-datetimeformat-components"></emu-xref>, indicating how the component should be presented in the formatted output.</del></li>
835+
<li><del>[[FractionalSecondDigits]] is either *undefined* or a positive, non-negative integer Number value indicating the fraction digits to be used for fractional seconds. Numbers will be rounded or padded with trailing zeroes if necessary.</del></li>
809836
<li><del>[[HourCycle]] is a String value indicating whether the 12-hour format (*"h11"*, *"h12"*) or the 24-hour format (*"h23"*, *"h24"*) should be used. *"h11"* and *"h23"* start with hour 0 and go up to 11 and 23 respectively. *"h12"* and *"h24"* start with hour 1 and go up to 12 and 24. [[HourCycle]] is only used when [[Hour]] is not *undefined*.</del></li>
810837
<li>[[Pattern]]<ins>, [[TemporalPlainDatePattern]], [[TemporalPlainYearMonthPattern]], [[TemporalPlainMonthDayPattern]], [[TemporalPlainTimePattern]], [[TemporalPlainDateTimePattern]], [[TemporalInstantPattern]], and [[TemporalZonedDateTimePattern]] are</ins> <del>is a String value</del><ins>records containing at least a [[pattern]] field</ins> as described in <emu-xref href="#sec-intl.datetimeformat-internal-slots"></emu-xref>.</li>
811838
</ul>

0 commit comments

Comments
 (0)