Skip to content

Commit 8fe9323

Browse files
ryzokukenMs2ger
authored andcommitted
spec: rebase intl spec on dateStyle/timeStyle
1 parent 3dc06e1 commit 8fe9323

File tree

2 files changed

+47
-17
lines changed

2 files changed

+47
-17
lines changed

spec/biblio.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@
111111
"type": "clause",
112112
"number": "Table 8",
113113
"id": "table-datetimeformat-tolocaltime-record"
114+
},
115+
{
116+
"type": "op",
117+
"aoid": "DateTimeStyleFormat",
118+
"id": "sec-date-time-style-format"
114119
}
115120
],
116121
"https://tc39.es/proposal-intl-duration-format/": [

spec/intl.html

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,34 @@ <h1>InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )</h1>
160160
1. Let _value_ be ? GetOption(_options_, _prop_, *"string"*, « the strings given in the Values column of the row », *undefined*).
161161
1. Set _opt_.[[&lt;_prop_&gt;]] to _value_.
162162
1. <del>Let _dataLocaleData_ be _localeData_.[[&lt;_dataLocale_&gt;]].</del>
163-
1. Let _formats_ be _dataLocaleData_.[[formats]].[[&lt;_calendar_&gt;]].
164163
1. Let _matcher_ be ? GetOption(_options_, *"formatMatcher"*, *"string"*, « *"basic"*, *"best fit"* », *"best fit"*).
165-
1. <del>If _matcher_ is *"basic"*, then</del>
166-
1. <del>Let _bestFormat_ be BasicFormatMatcher(_opt_, _formats_).</del>
167-
1. <del>Else,</del>
168-
1. <del>Let _bestFormat_ be BestFitFormatMatcher(_opt_, _formats_).</del>
164+
1. Let _dateStyle_ be ? GetOption(_options_, *"dateStyle"*, *"string"*, « *"full"*, *"long"*, *"medium"*, *"short"* », *undefined*).
165+
1. Set _dateTimeFormat_.[[DateStyle]] to _dateStyle_.
166+
1. Let _timeStyle_ be ? GetOption(_options_, *"timeStyle"*, *"string"*, « *"full"*, *"long"*, *"medium"*, *"short"* », *undefined*).
167+
1. Set _dateTimeFormat_.[[TimeStyle]] to _timeStyle_.
168+
1. If _dateStyle_ is not *undefined* or _timeStyle_ is not *undefined*, then
169+
1. For each row in <emu-xref href="#table-datetimeformat-components"></emu-xref>, except the header row, do
170+
1. Let _prop_ be the name given in the Property column of the row.
171+
1. Let _p_ be _opt_.[[&lt;_prop_&gt;]].
172+
1. If _p_ is not *undefined*, then
173+
1. Throw a *TypeError* exception.
174+
1. Let _bestFormat_ be DateTimeStyleFormat(_dateStyle_, _timeStyle_, _dataLocaleData_).
175+
1. <mark>TODO: figure out how to deal with Temporal objects here.</mark>
176+
1. Else,
177+
1. Let _formats_ be _dataLocaleData_.[[formats]].[[&lt;_calendar_&gt;]].
178+
1. <del>If _matcher_ is *"basic"*, then</del>
179+
1. <del>Let _bestFormat_ be BasicFormatMatcher(_opt_, _formats_).</del>
180+
1. <del>Else,</del>
181+
1. <del>Let _bestFormat_ be BestFitFormatMatcher(_opt_, _formats_).</del>
182+
1. <ins>Let _expandedOptions_ be a copy of _opt_.</ins>
183+
1. <ins>Let _needDefaults_ be *true*.</ins>
184+
1. <ins>For each element _field_ of « *"weekday"*, *"year"*, *"month"*, *"day"*, *"hour"*, *"minute"*, *"second"* » in List order, do</ins>
185+
1. <ins>If _expandedOptions_.[[&lt;_field_&gt;]] is not *undefined*, then</ins>
186+
1. <ins>Set _needDefaults_ to *false*.</ins>
187+
1. <ins>If _needDefaults_ is *true*, then</ins>
188+
1. <ins>For each element _field_ of « *"year"*, *"month"*, *"day"*, *"hour"*, *"minute"*, *"second"* » in List order, do</ins>
189+
1. <ins>Set _expandedOptions_.[[&lt;_field_&gt;]] to *"numeric"*.</ins>
190+
1. <ins>Let _bestFormat_ be GetDateTimeFormatPattern(_matcher_, _expandedOptions_, _formats_, _hc_).</ins>
169191
1. <del>For each row in <emu-xref href="#table-datetimeformat-components"></emu-xref>, except the header row, in table order, do</del>
170192
1. <del>Let _prop_ be the name given in the Property column of the row.</del>
171193
1. <del>Let _p_ be _bestFormat_.[[&lt;_prop_&gt;]].</del>
@@ -196,18 +218,7 @@ <h1>InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )</h1>
196218
1. <del>Let _pattern_ be _bestFormat_.[[pattern12]].</del>
197219
1. <del>Else,</del>
198220
1. <del>Let _pattern_ be _bestFormat_.[[pattern]].</del>
199-
1. <del>Else,</del>
200-
1. <del>Set _dateTimeFormat_.[[HourCycle]] to *undefined*.</del>
201-
1. <del>Let _pattern_ be _bestFormat_.[[pattern]].</del>
202-
1. <ins>Let _expandedOptions_ be a copy of _opt_.</ins>
203-
1. <ins>Let _needDefaults_ be *true*.</ins>
204-
1. <ins>For each element _field_ of « *"weekday"*, *"year"*, *"month"*, *"day"*, *"hour"*, *"minute"*, *"second"* » in List order, do</ins>
205-
1. <ins>If _expandedOptions_.[[&lt;_field_&gt;]] is not *undefined*, then</ins>
206-
1. <ins>Set _needDefaults_ to *false*.</ins>
207-
1. <ins>If _needDefaults_ is *true*, then</ins>
208-
1. <ins>For each element _field_ of « *"year"*, *"month"*, *"day"*, *"hour"*, *"minute"*, *"second"* » in List order, do</ins>
209-
1. <ins>Set _expandedOptions_.[[&lt;_field_&gt;]] to *"numeric"*.</ins>
210-
1. Set _dateTimeFormat_.[[Pattern]] to <del>_pattern_</del><ins>GetDateTimeFormatPattern(_matcher_, _expandedOptions_, _formats_, _hc_)</ins>.
221+
1. Set _dateTimeFormat_.[[Pattern]] to <del>_pattern_</del><ins>_bestFormat_.[[pattern]]</ins>.
211222
1. <ins>For each row in <emu-xref href="#table-temporal-patterns"></emu-xref>, except the header row, in table order, do</ins>
212223
1. <ins>Let _limitedOptions_ be a new Record.</ins>
213224
1. <ins>Let _needDefaults_ be *true*.</ins>
@@ -699,6 +710,9 @@ <h1>Intl.DateTimeFormat.prototype.resolvedOptions ( )</h1>
699710
1. <ins>Else,</ins>
700711
1. <ins>Assert: the Location value of the current row is ~pattern~.</ins>
701712
1. <ins>Let _v_ be the value of _dtf_.[[Pattern]]'s internal slot whose name is the Internal Slot value of the current row.</ins>
713+
1. If the Internal Slot value of the current row is an Internal Slot value in <emu-xref href="#table-datetimeformat-components"></emu-xref>, then
714+
1. If _dtf_.[[DateStyle]] is not *undefined* or _dtf_.[[TimeStyle]] is not *undefined*, then
715+
1. Let _v_ be *undefined*.
702716
1. If _v_ is not *undefined*, then
703717
1. Perform ! CreateDataPropertyOrThrow(_options_, _p_, _v_).
704718
1. Return _options_.
@@ -793,6 +807,16 @@ <h1>Intl.DateTimeFormat.prototype.resolvedOptions ( )</h1>
793807
<td><del>[[TimeZoneName]]</del><ins>[[timeZoneName]]</ins></td>
794808
<td>*"timeZoneName"*</td>
795809
<td><ins>~pattern~</ins></td>
810+
<tr>
811+
<td>[[DateStyle]]</td>
812+
<td>*"dateStyle"*</td>
813+
<td><ins>~object~</ins></td>
814+
</tr>
815+
<tr>
816+
<td>[[TimeStyle]]</td>
817+
<td>*"timeStyle"*</td>
818+
<td><ins>~object~</ins></td>
819+
</tr>
796820
</tr>
797821
</table>
798822
</emu-table>
@@ -834,6 +858,7 @@ <h1><a href="https://tc39.es/ecma402/#sec-properties-of-intl-datetimeformat-inst
834858
<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>
835859
<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>
836860
<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>
861+
<li>[[DateStyle]], [[TimeStyle]] are each either *undefined*, or a String value with values *"full"*, *"long"*, *"medium"*, or *"short"*.</li>
837862
<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>
838863
</ul>
839864

0 commit comments

Comments
 (0)