@@ -123,15 +123,33 @@ <h1>InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )</h1>
123
123
1. Throw a *RangeError* exception.
124
124
1. Let _timeZone_ be CanonicalizeTimeZoneName(_timeZone_ ).
125
125
1. Set _dateTimeFormat_ .[[TimeZone]] to _timeZone_ .
126
- 1. Let _opt_ be a new Record.
126
+ 1. Let _formatOptions_ be a new Record.
127
127
1. For each row of <emu-xref href =" #table-datetimeformat-components" ></emu-xref >, except the header row, in table order, do
128
128
1. Let _prop_ be the name given in the Property column of the row.
129
129
1. If _prop_ is *"fractionalSecondDigits"* , then
130
130
1. Let _value_ be ? GetNumberOption(options, *"fractionalSecondDigits"* , 1, 3, *undefined* ).
131
131
1. Else,
132
132
1. Let _value_ be ? GetOption(_options_ , _prop_ , *"string"* , « ; the strings given in the Values column of the row » ; , *undefined* ).
133
- 1. Set _opt_ .[[< ; _prop_ > ; ]] to _value_ .
133
+ 1. Set _formatOptions_ .[[< ; _prop_ > ; ]] to _value_ .
134
134
1. Let _dataLocaleData_ be _localeData_ .[[< ; _dataLocale_ > ; ]].
135
+ 1. Let _hcDefault_ be _dataLocaleData_ .[[hourCycle]].
136
+ 1. Let _hc_ be _dateTimeFormat_ .[[HourCycle]].
137
+ 1. If _hc_ is *null* , then
138
+ 1. Set _hc_ to _hcDefault_ .
139
+ 1. If _hour12_ is *true* , then
140
+ 1. If _hcDefault_ is *"h11"* or *"h23"* , then
141
+ 1. Set _hc_ to *"h11"* .
142
+ 1. Else,
143
+ 1. Set _hc_ to *"h12"* .
144
+ 1. Else if _hour12_ is *false* , then
145
+ 1. If _hcDefault_ is *"h11"* or *"h23"* , then
146
+ 1. Set _hc_ to *"h23"* .
147
+ 1. Else,
148
+ 1. Set _hc_ to *"h24"* .
149
+ 1. Else,
150
+ 1. Assert: _hour12_ is *undefined* .
151
+ 1. Set _dateTimeFormat_ .[[HourCycle]] to _hc_ .
152
+ 1. Set _formatOptions_ .[[hourCycle]] to _hc_ .
135
153
1. Let _matcher_ be ? GetOption(_options_ , *"formatMatcher"* , *"string"* , « ; *"basic"* , *"best fit"* » ; , *"best fit"* ).
136
154
1. Let _dateStyle_ be ? GetOption(_options_ , *"dateStyle"* , *"string"* , « ; *"full"* , *"long"* , *"medium"* , *"short"* » ; , *undefined* ).
137
155
1. Set _dateTimeFormat_ .[[DateStyle]] to _dateStyle_ .
@@ -140,50 +158,30 @@ <h1>InitializeDateTimeFormat ( _dateTimeFormat_, _locales_, _options_ )</h1>
140
158
1. If _dateStyle_ is not *undefined* or _timeStyle_ is not *undefined* , then
141
159
1. For each row in <emu-xref href =" #table-datetimeformat-components" ></emu-xref >, except the header row, do
142
160
1. Let _prop_ be the name given in the Property column of the row.
143
- 1. Let _p_ be _opt_ .[[< ; _prop_ > ; ]].
161
+ 1. Let _p_ be _formatOptions_ .[[< ; _prop_ > ; ]].
144
162
1. If _p_ is not *undefined* , then
145
163
1. Throw a *TypeError* exception.
146
164
1. Let _styles_ be _dataLocaleData_ .[[styles]].[[< ; _calendar_ > ; ]].
147
165
1. Let _bestFormat_ be DateTimeStyleFormat(_dateStyle_ , _timeStyle_ , _styles_ ).
148
166
1. Else,
149
167
1. Let _formats_ be _dataLocaleData_ .[[formats]].[[< ; _calendar_ > ; ]].
150
168
1. If _matcher_ is *"basic"* , then
151
- 1. Let _bestFormat_ be BasicFormatMatcher(_opt_ , _formats_ ).
169
+ 1. Let _bestFormat_ be BasicFormatMatcher(_formatOptions_ , _formats_ ).
152
170
1. Else,
153
- 1. Let _bestFormat_ be BestFitFormatMatcher(_opt_ , _formats_ ).
171
+ 1. Let _bestFormat_ be BestFitFormatMatcher(_formatOptions_ , _formats_ ).
154
172
1. For each row in <emu-xref href =" #table-datetimeformat-components" ></emu-xref >, except the header row, in table order, do
155
173
1. Let _prop_ be the name given in the Property column of the row.
156
174
1. If _bestFormat_ has a field [[< ; _prop_ > ; ]], then
157
175
1. Let _p_ be _bestFormat_ .[[< ; _prop_ > ; ]].
158
176
1. Set _dateTimeFormat_ 's internal slot whose name is the Internal Slot column of the row to _p_ .
159
177
1. If _dateTimeFormat_ .[[Hour]] is *undefined* , then
160
178
1. Set _dateTimeFormat_ .[[HourCycle]] to *undefined* .
179
+ 1. If _dateTimeformat_ .[[HourCycle]] is *"h11"* or *"h12"* , then
180
+ 1. Let _pattern_ be _bestFormat_ .[[pattern12]].
181
+ 1. Let _rangePatterns_ be _bestFormat_ .[[rangePatterns12]].
182
+ 1. Else,
161
183
1. Let _pattern_ be _bestFormat_ .[[pattern]].
162
184
1. Let _rangePatterns_ be _bestFormat_ .[[rangePatterns]].
163
- 1. Else,
164
- 1. Let _hcDefault_ be _dataLocaleData_ .[[hourCycle]].
165
- 1. Let _hc_ be _dateTimeFormat_ .[[HourCycle]].
166
- 1. If _hc_ is *null* , then
167
- 1. Set _hc_ to _hcDefault_ .
168
- 1. If _hour12_ is not *undefined* , then
169
- 1. If _hour12_ is *true* , then
170
- 1. If _hcDefault_ is *"h11"* or *"h23"* , then
171
- 1. Set _hc_ to *"h11"* .
172
- 1. Else,
173
- 1. Set _hc_ to *"h12"* .
174
- 1. Else,
175
- 1. Assert: _hour12_ is *false* .
176
- 1. If _hcDefault_ is *"h11"* or *"h23"* , then
177
- 1. Set _hc_ to *"h23"* .
178
- 1. Else,
179
- 1. Set _hc_ to *"h24"* .
180
- 1. Set _dateTimeFormat_ .[[HourCycle]] to _hc_ .
181
- 1. If _dateTimeformat_ .[[HourCycle]] is *"h11"* or *"h12"* , then
182
- 1. Let _pattern_ be _bestFormat_ .[[pattern12]].
183
- 1. Let _rangePatterns_ be _bestFormat_ .[[rangePatterns12]].
184
- 1. Else,
185
- 1. Let _pattern_ be _bestFormat_ .[[pattern]].
186
- 1. Let _rangePatterns_ be _bestFormat_ .[[rangePatterns]].
187
185
1. Set _dateTimeFormat_ .[[Pattern]] to _pattern_ .
188
186
1. Set _dateTimeFormat_ .[[RangePatterns]] to _rangePatterns_ .
189
187
1. Return _dateTimeFormat_ .
0 commit comments