generated from tc39/template-for-proposals
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathspec.emu
464 lines (456 loc) · 17.8 KB
/
spec.emu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<!doctype html>
<meta charset="utf8">
<link rel="stylesheet" href="./spec.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<script src="./spec.js"></script>
<pre class="metadata">
title: Intl era and monthCode Proposal
stage: 2
location: https://frankyftang.github.io/proposal-intl-era-monthcode/
copyright: true
contributors: Google, Ecma International
</pre>
<emu-clause id="sup-temporal-calendar-abstract-ops">
<h1>Abstract Operations for Temporal.Calendar Objects</h1>
<emu-clause id="sec-temporal-iscalendarsupportera" type="abstract operation">
<h1>
IsCalendarSupportEra (
_calendar_: a String,
): a Boolean
</h1>
<dl class="header">
<dt>description</dt>
<dd>
The following algorithm refers to the era data from <a href="https://unicode.org/reports/tr35/tr35-dates.html#Calendar_Data">UTS 35's Supplemental Calendar Data</a>.
</dd>
</dl>
<emu-alg>
1. If _calendar_ is listed in the Calendar column of <emu-xref href="#table-eras"></emu-xref>, return *true*.
1. Return *false*.
</emu-alg>
<emu-table id="table-eras">
<emu-caption>era aliases and range of eraYear</emu-caption>
<table class="real-table">
<thead>
<tr>
<th>Calendar</th>
<th>Era</th>
<th>Aliases</th>
<th>Minimum eraYear</th>
<th>Maximum eraYear</th>
</tr>
</thead>
<tr>
<td>*"buddhist"*</td>
<td>*"buddhist"*</td>
<td>*"be"*</td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"chinese"*</td>
<td>*"chinese"*</td>
<td></td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"coptic"*</td>
<td>*"coptic"*</td>
<td></td>
<td>*1*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"coptic"*</td>
<td>*"coptic-inverse"*</td>
<td></td>
<td>*1*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"dangi"*</td>
<td>*"dangi"*</td>
<td></td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"ethiopic"*</td>
<td>*"ethiopic"*</td>
<td>*"incar"*</td>
<td>*1*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"ethiopic"*</td>
<td>*"ethioaa"*</td>
<td>*"ethiopic-amete-alem"*, *"mundi"*</td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*5500*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"ethioaa"*</td>
<td>*"ethioaa"*</td>
<td>*"ethiopic-amete-alem"*, *"mundi"*</td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"gregory"*</td>
<td>*"gregory"*</td>
<td>*"ce"*, *"ad"*</td>
<td>*1*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"gregory"*</td>
<td>*"gregory-inverse"*</td>
<td>*"bc"*, *"bce"*</td>
<td>*1*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"hebrew"*</td>
<td>*"hebrew"*</td>
<td>*"am"*</td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"indian"*</td>
<td>*"indian"*</td>
<td>*"saka"*</td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"islamic"*</td>
<td>*"islamic"*</td>
<td>*"ah"*</td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"islamic-civil"*</td>
<td>*"islamic-civil"*</td>
<td>*"islamicc"*, *"ah"*</td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"islamic-rgsa"*</td>
<td>*"islamic-rgsa"*</td>
<td>*"ah"*</td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"islamic-tbla"*</td>
<td>*"islamic-tbla"*</td>
<td>*"ah"*</td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"islamic-umalqura"*</td>
<td>*"islamic-umalqura"*</td>
<td>*"ah"*</td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"japanese"*</td>
<td>*"heisei"*</td>
<td></td>
<td>*1*<sub>𝔽</sub></td>
<td>*31*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"japanese"*</td>
<td>*"japanese"*</td>
<td>*"gregory"*, *"ad"*, *"ce"*</td>
<td>*1*<sub>𝔽</sub></td>
<td>*1868*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"japanese"*</td>
<td>*"japanese-inverse"*</td>
<td>*"gregory-inverse"*, *"bc"*, *"bce"*</td>
<td>*1*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"japanese"*</td>
<td>*"meiji"*</td>
<td></td>
<td>*1*<sub>𝔽</sub></td>
<td>*45*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"japanese"*</td>
<td>*"reiwa"*</td>
<td></td>
<td>*1*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"japanese"*</td>
<td>*"showa"*</td>
<td></td>
<td>*1*<sub>𝔽</sub></td>
<td>*64*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"japanese"*</td>
<td>*"taisho"*</td>
<td></td>
<td>*1*<sub>𝔽</sub></td>
<td>*15*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"persian"*</td>
<td>*"persian"*</td>
<td>*"ap"*</td>
<td>*-∞*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"roc"*</td>
<td>*"roc"*</td>
<td>*"minguo"**</td>
<td>*1*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
<tr>
<td>*"roc"*</td>
<td>*"roc-inverse"*</td>
<td>*"before-roc"*</td>
<td>*1*<sub>𝔽</sub></td>
<td>*+∞*<sub>𝔽</sub></td>
</tr>
</table>
</emu-table>
<emu-note>
The content in this table is proposed by Era Code WG to CLDR TC in <a href="https://github.com/unicode-org/cldr/pull/2665">PR 2665</a> and under review. It is targeted to be part of CLDR 43, scheduled to be released in April 2023.
</emu-note>
</emu-clause>
<emu-clause id="sec-temporal-canonicalizeeraincalendar" type="abstract operation">
<h1>
CanonicalizeEraInCalendar (
_calendar_: a String,
_era_: a String,
): a String or *undefined*
</h1>
<dl class="header">
<dt>description</dt>
<dd>
The following algorithm refers to the era data from <a href="https://unicode.org/reports/tr35/tr35-dates.html#Calendar_Data">UTS 35's Supplemental Calendar Data</a>.
</dd>
</dl>
<emu-alg>
1. For each row of <emu-xref href="#table-eras"></emu-xref>, do
1. Let _cal_ be the Calendar value of the current row.
1. If _cal_ is equal to _calendar_, then
1. Let _e_ be the Era value of the current row.
1. If _e_ is equal to _era_, return _era_.
1. Let _aliases_ be a List whose elements are the strings given in the Aliases column of the row.
1. If _aliases_ contains _era_, return _era_.
1. Return *undefined*.
</emu-alg>
</emu-clause>
<emu-clause id="sec-temporal-isvalidmonthecodeforcalendar" type="abstract operation">
<h1>
IsValidMonthCodeForCalendar (
_calendar_: a String,
_monthCode_: a String,
): a Boolean
</h1>
<dl class="header">
</dl>
<emu-alg>
1. Let _commonMonthCodes_ be « *"M01"*, *"M02"*, *"M03"*, *"M04"*, *"M05"*, *"M06"*, *"M07"*, *"M08"*, *"M09"*, *"M10"*, *"M11"*, *"M12"* ».
1. If _commonMonthCodes_ contains _monthCode_, return *true*.
1. If _calendar_ is not listed in the Calendar column of <emu-xref href="#table-additional-month-codes"></emu-xref>, return *false*.
1. Let _r_ be the row in <emu-xref href="#table-additional-month-codes"></emu-xref> which the _clendar_ is in the Calendar column.
1. Let _specialMonthCodes_ be a List whose elements are the strings given in the *"Additional Month Codes"* column of _r_.
1. If _specialMonthCodes_ contains _monthCode_, return *true*.
1. Return *false*.
</emu-alg>
<emu-table id="table-additional-month-codes">
<emu-caption>Additional Month Codes in Calendars</emu-caption>
<table class="real-table">
<thead>
<tr>
<th>Calendar</th>
<th>Additional Month Codes</th>
</tr>
</thead>
<tr>
<td>*"chinese"*</td>
<td>*"M01L"*, *"M02L"*, *"M03L"*, *"M04L"*, *"M05L"*, *"M06L"*, *"M07L"*, *"M08L"*, *"M09L"*, *"M10L"*, *"M11L"*, *"M12L"*</td>
</tr>
<tr>
<td>*"coptic"*</td>
<td>*"M13"*</td>
</tr>
<tr>
<td>*"dangi"*</td>
<td>*"M01L"*, *"M02L"*, *"M03L"*, *"M04L"*, *"M05L"*, *"M06L"*, *"M07L"*, *"M08L"*, *"M09L"*, *"M10L"*, *"M11L"*, *"M12L"*</td>
</tr>
<tr>
<td>*"ethiopic"*</td>
<td>*"M13"*</td>
</tr>
<tr>
<td>*"ethioaa"*</td>
<td>*"M13"*</td>
</tr>
<tr>
<td>*"hebrew"*</td>
<td>*"M05L"*</td>
</tr>
</table>
</emu-table>
</emu-clause>
<emu-clause id="sec-temporal-isvaliderayearforcalendar" type="abstract operation">
<h1>
IsValidEraYearForCalendar (
_calendar_: a String,
_era_: a String,
_eraYear_: a integer,
): a Boolean
</h1>
<dl class="header">
<dt>description</dt>
<dd>
The following algorithm refers to the era data from <a href="https://unicode.org/reports/tr35/tr35-dates.html#Calendar_Data">UTS 35's Supplemental Calendar Data</a>.
</dd>
</dl>
<emu-alg>
1. Let _era_ be CanonicalizeEraInCalendar(_calendar_, _era_).
1. If _era_ is *undefined*, return *false*.
1. Let _r_ be the row in <emu-xref href="#table-eras"></emu-xref> which the _calendar_ is in the Calendar column and the _era_ is in the Era column.
1. Let _min_ be the value given in the *"Minimum eraYear"* column of _r_.
1. Let _max_ be the value given in the *"Maximum eraYear"* column of _r_.
1. If _eraYear_ < _min_, return *false*.
1. If _eraYear_ > _max_, return *false*.
1. Return *true*.
</emu-alg>
</emu-clause>
<emu-clause id="sup-temporal-calendardateera" type="abstract operation">
<h1>
CalendarDateEra (
_calendar_: a String,
_date_: a Temporal.PlainDateTime, Temporal.PlainDate, or Temporal.PlainYearMonth,
): a String or *undefined*
</h1>
<dl class="header">
<dt>description</dt>
<dd>It performs implementation-defined processing to find the era for the date corresponding to _date_ in the context of the calendar represented by _calendar_ and returns a lowercase String value representing that era, or *undefined* for calendars that do not have eras.</dd>
</dl>
<p>
This definition supersedes the definition provided in "Temporal proposal", #sec-temporal-calendardateera.
</p>
<emu-alg>
1. If IsCalendarSupportEra(_calendar_) is *false*, return *undefined*.
1. Let _era_ be the String to indicate the era corresponding to _date_ in the context of the calendar represented by _calendar_ from an implementation-defined processing.
1. Return CanonicalizeEraInCalendar(_calendar_, _era_).
</emu-alg>
</emu-clause>
<emu-clause id="sup-temporal-calendardateerayear" type="abstract operation">
<h1>
CalendarDateEraYear (
_calendar_: a String,
_date_: a Temporal.PlainDateTime, Temporal.PlainDate, or Temporal.PlainYearMonth,
): an integer or *undefined*
</h1>
<dl class="header">
<dt>description</dt>
<dd>It performs implementation-defined processing to find the era for the date corresponding to _date_ in the context of the calendar represented by _calendar_ and returns an integer representing the ordinal position of the year of _date_ in that era, or *undefined* for calendars that do not have eras.</dd>
</dl>
</dl>
<p>
This definition supersedes the definition provided in "Temporal proposal", #sec-temporal-calendardateerayear.
</p>
<emu-alg>
1. If IsCalendarSupportEra(_calendar_) is *false*, return *undefined*.
1. Let _eraYear_ be the integer to indicate the era year corresponding to _date_ in the context of the calendar represented by _calendar_ from an implementation-defined processing.
1. Assert: _eraYear_ is an integer.
1. Return _eraYear_.
</emu-alg>
<emu-note>
Era years are 1-indexed for many calendars, but not all (e.g., the eras of the Burmese calendar each start with a year 0). Years can also advance opposite the flow of time (as for BCE years in the Gregorian calendar).
</emu-note>
</emu-clause>
<emu-clause id="sup-temporal-calendardatefields" type="abstract operation">
<h1>
CalendarDateFields (
_calendar_: a String,
_fields_: a List of Strings,
): a List of Strings
</h1>
<dl class="header">
<dt>description</dt>
<dd>It takes a list of standard fields in _fields_ that are necessary for a given operation and returns a new list by adding relevant calendar-specific fields for the calendar represented by _calendar_. This is relevant for calendars which accept fields other than the standard set of built-in calendar fields.</dd>
</dl>
</dl>
<p>
This definition supersedes the definition provided in "Temporal proposal", #sec-temporal-calendardatefields.
</p>
<emu-alg>
1. If _fields_ contains an element equal to *"year"* and IsCalendarSupportEra(_calendar_) is *true*, then
1. Append *"era"* to _fields_.
1. Append *"eraYear"* to _fields_.
1. Return _fields_.
</emu-alg>
</emu-clause>
<emu-clause id="sup-temporal-calendardatemergefields" type="abstract operation">
<h1>
CalendarDateMergeFields (
_calendar_: a String,
_fields_: an Object,
_additionalFields_: an Object,
): either a normal completion containing an Object or an abrupt completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It takes two Objects of calendar-specific fields for the calendar represented by _calendar_ in _fields_ and _additionalFields_ and returns a new Object that includes both sets of fields. The values in _additionalFields_ should supersede the values in _fields_. Also, the returned Object must be free of ambiguity or conflicts. This is relevant for calendars which accept fields other than the standard set of built-in calendar fields.</dd>
</dl>
<p>
This definition supersedes the definition provided in "Temporal proposal", #sec-temporal-calendardatemergefields.
</p>
<emu-note>
For example, if _fields_ contains *"year"* but _additionalFields_ contains *"era"* and *"eraYear"*, then the returned list must not include *"year"* in order to avoid ambiguity or conflict between different ways of specifying the year.
</emu-note>
<emu-alg>
1. Let _handleEra_ be IsCalendarSupportEra(_calendar_).
1. Let _merged_ be OrdinaryObjectCreate(%Object.prototype%).
1. Let _fieldsKeys_ be ? EnumerableOwnPropertyNames(_fields_, ~key~).
1. For each element _key_ of _fieldsKeys_, do
1. If _key_ is not *"month"* or *"monthCode"*, then
1. If _handlEra_ is *false* or _key_ is not *"era"*, *"eraYear"* or *"year"*, then
1. Let _propValue_ be ? Get(_fields_, _key_).
1. If _propValue_ is not *undefined*, then
1. Perform ! CreateDataPropertyOrThrow(_merged_, _key_, _propValue_).
1. Let _additionalFieldsKeys_ be ? EnumerableOwnPropertyNames(_additionalFields_, ~key~).
1. For each element _key_ of _additionalFieldsKeys_, do
1. Let _propValue_ be ? Get(_additionalFields_, _key_).
1. If _propValue_ is not *undefined*, then
1. Perform ! CreateDataPropertyOrThrow(_merged_, _key_, _propValue_).
1. If _additionalFieldsKeys_ does not contain either *"month"* or *"monthCode"*, then
1. Let _month_ be ? Get(_fields_, *"month"*).
1. If _month_ is not *undefined*, then
1. Perform ! CreateDataPropertyOrThrow(_merged_, *"month"*, _month_).
1. Let _monthCode_ be ? Get(_fields_, *"monthCode"*).
1. If _monthCode_ is not *undefined*, then
1. Perform ! CreateDataPropertyOrThrow(_merged_, *"monthCode"*, _monthCode_).
1. If _handleEra_ is *true*, then
1. If _additionalFieldsKeys_ does not contain *"era"*, *"eraYear"*, or *"year"*, then
1. Let _year_ be ? Get(_fields_, *"year"*).
1. If _year_ is not *undefined*, then
1. Perform ! CreateDataPropertyOrThrow(_merged_, *"year"*, _year_).
1. Return _merged_.
</emu-alg>
</emu-clause>
</emu-clause>