Skip to content

Commit d3199c6

Browse files
ptomatogibson042
andauthored
Editorial: Address high-priority points from TG2 editor review (#97)
* Editorial: Add definitions for "arithmetic year" and "epoch year" The definitions link to the description of the [[Year]] field in Calendar Date Records, where arithmetic year and epoch year are explained. Also adjusts the text in a few places to avoid repetition now that we have linked definitions, and adds a cross-reference to the table of epoch years. See: #51 * Editorial: Clarify that calendars not in Table 1 are implementation-defined Implementations should not be constrained to just the calendar types in Table 1, for future extensibility. In any abstract operations that seem to assume that all calendar types are listed in Table 1, add language clarifying what happens if they are not. See: #51 Closes: #94 * Editorial: Clarify that eras in Table 2 are the currently known ones Refer to UTS 35 as the canonical source for this data. Add Part 4: Dates to the list of normative references, in order to clarify that implementations do not have to omit newly added eras in order to be conformant, as well as for the note below about updating on a best- effort basis. * Editorial: Update table-eras caption Suggestion from code review. Co-Authored-By: Richard Gibson <[email protected]> --------- Co-authored-by: Richard Gibson <[email protected]>
1 parent 49c32e2 commit d3199c6

File tree

1 file changed

+93
-19
lines changed

1 file changed

+93
-19
lines changed

spec.emu

Lines changed: 93 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ contributors: Google, Ecma International
199199
<p>The value of the [[LocaleData]] internal slot is implementation-defined within the constraints described in <emu-xref href="#sec-internal-slots"></emu-xref> and the following additional constraints, for all locale values _locale_:</p>
200200

201201
<ul>
202-
<li><ins>[[LocaleData]].[[&lt;_locale_>]].[[ca]] must be a List consisting of values from the Calendar Type column of <emu-xref href="#table-calendar-types"></emu-xref>. The list may also include *"islamic"* and *"islamic-rgsa"*.</ins></li>
202+
<li><ins>[[LocaleData]].[[&lt;_locale_>]].[[ca]] must be a List consisting of calendar types. Specifically, even if supporting only the calendars from <emu-xref href="#table-calendar-types"></emu-xref>, the list may also include *"islamic"* and *"islamic-rgsa"*.</ins></li>
203203
<li>
204204
[[LocaleData]].[[&lt;_locale_>]].[[nu]] must be a List that does not include the values *"native"*, *"traditio"*, or *"finance"*.
205205
</li>
@@ -227,20 +227,24 @@ contributors: Google, Ecma International
227227
<dl class="header">
228228
<dt>description</dt>
229229
<dd>
230-
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>.
230+
The following algorithm refers (via <emu-xref href="#table-eras"></emu-xref>) to the era data from <a href="https://unicode.org/reports/tr35/tr35-dates.html#Calendar_Data">UTS 35's Supplemental Calendar Data</a>.
231231
</dd>
232232
</dl>
233233
<emu-alg>
234234
1. If _calendar_ is listed in the Calendar column of <emu-xref href="#table-eras"></emu-xref>, return *true*.
235-
1. Return *false*.
235+
1. If _calendar_ is listed in the Calendar Type column of <emu-xref href="#table-calendar-types"></emu-xref>, return *false*.
236+
1. Return an implementation-defined value.
236237
</emu-alg>
237-
<p><emu-xref href="#table-eras"></emu-xref> lists all possible eras for the current set of calendars, including their aliases, ranges and kinds.
238-
The era kind is used by <emu-xref href="#sec-temporal-calendardatearithmeticyearforerayear">CalendarDateArithmeticYearForEraYear</emu-xref> to calculate arithmetic year ([[Year]]):
238+
<p>
239+
<emu-xref href="#table-eras"></emu-xref> lists all currently known eras for the current set of calendars, including their aliases, ranges and kinds.
240+
The canonical source for this table is the data described in <a href="https://unicode.org/reports/tr35/tr35-dates.html#Calendar_Data">Unicode Technical Standard #35 Part 4 Dates, Calendar Data</a>.
241+
</p>
242+
<p>The era kind is used by <emu-xref href="#sec-temporal-calendardatearithmeticyearforerayear">CalendarDateArithmeticYearForEraYear</emu-xref> to calculate arithmetic year ([[Year]]):
239243
An *Era kind* ~epoch~ means that the era is the epoch era, so 1 Era has an arithmetic year of 1. An *Era kind* ~negative~ means that the era is a "negative" era growing
240244
from the epoch, so 1 Era is an arithmetic year of 0, and larger [[EraYear]] values produce smaller, negative arithmetic years. An *Era kind* of
241245
~offset~ means that the era is "offset" by a given number (in the *Offset* column), so 1 Era has an arithmetic year of *Offset*.</p>
242246
<emu-table id="table-eras">
243-
<emu-caption>era aliases, range of eraYear, and era kinds</emu-caption>
247+
<emu-caption>Eras</emu-caption>
244248
<table class="real-table">
245249
<thead>
246250
<tr>
@@ -503,7 +507,8 @@ contributors: Google, Ecma International
503507
1. If _canonicalName_ is equal to _era_, return _canonicalName_.
504508
1. Let _aliases_ be a List whose elements are the strings given in the Aliases column of the row.
505509
1. If _aliases_ contains _era_, return _canonicalName_.
506-
1. Return *undefined*.
510+
1. If _calendar_ is listed in the Calendar Type column of <emu-xref href="#table-calendar-types"></emu-xref>, return *undefined*.
511+
1. Return an implementation-defined value.
507512
</emu-alg>
508513
</emu-clause>
509514

@@ -519,7 +524,8 @@ contributors: Google, Ecma International
519524
</dl>
520525
<emu-alg>
521526
1. If _calendar_ is *"japanese"*, return *true*.
522-
1. Return *false*.
527+
1. If _calendar_ is listed in the Calendar Type column of <emu-xref href="#table-calendar-types"></emu-xref>, return *false*.
528+
1. Return an implementation-defined value.
523529
</emu-alg>
524530
</emu-clause>
525531

@@ -535,11 +541,13 @@ contributors: Google, Ecma International
535541
<emu-alg>
536542
1. Let _commonMonthCodes_ be « *"M01"*, *"M02"*, *"M03"*, *"M04"*, *"M05"*, *"M06"*, *"M07"*, *"M08"*, *"M09"*, *"M10"*, *"M11"*, *"M12"* ».
537543
1. If _commonMonthCodes_ contains _monthCode_, return *true*.
538-
1. If _calendar_ is not listed in the Calendar column of <emu-xref href="#table-additional-month-codes"></emu-xref>, return *false*.
539-
1. Let _r_ be the row in <emu-xref href="#table-additional-month-codes"></emu-xref> which the _calendar_ is in the Calendar column.
540-
1. Let _specialMonthCodes_ be a List whose elements are the strings given in the *"Additional Month Codes"* column of _r_.
541-
1. If _specialMonthCodes_ contains _monthCode_, return *true*.
542-
1. Return *false*.
544+
1. If _calendar_ is listed in the Calendar column of <emu-xref href="#table-additional-month-codes"></emu-xref>, then
545+
1. Let _r_ be the row in <emu-xref href="#table-additional-month-codes"></emu-xref> which the _calendar_ is in the Calendar column.
546+
1. Let _specialMonthCodes_ be a List whose elements are the strings given in the *"Additional Month Codes"* column of _r_.
547+
1. If _specialMonthCodes_ contains _monthCode_, return *true*.
548+
1. Return *false*.
549+
1. If _calendar_ is listed in the Calendar Type column of <emu-xref href="#table-calendar-types"></emu-xref>, return *false*.
550+
1. Return an implementation-defined value.
543551
</emu-alg>
544552

545553
<emu-table id="table-additional-month-codes">
@@ -628,6 +636,7 @@ contributors: Google, Ecma International
628636
1. Assert: IsValidMonthCodeForCalendar(_calendar_, _monthCode_) is *true*.
629637
1. If YearContainsMonthCode(_calendar_, _arithmeticYear_, _monthCode_) is *true*, return _monthCode_.
630638
1. If _overflow_ is ~reject~, throw a *RangeError* exception.
639+
1. If _calendar_ is not listed in the Calendar Type column of <emu-xref href="#table-calendar-types"></emu-xref>, return an implementation-defined value.
631640
1. Assert: _calendar_ is listed in the Calendar column of <emu-xref href="#table-additional-month-codes"></emu-xref>.
632641
1. Let _r_ be the row in <emu-xref href="#table-additional-month-codes"></emu-xref> which the _calendar_ is in the Calendar column.
633642
1. Let _shiftType_ be the value given in the *"Leap to Common Month Transformation"* column of _r_.
@@ -659,6 +668,7 @@ contributors: Google, Ecma International
659668
1. Let _monthsBefore_ be 0.
660669
1. Let _number_ be 1.
661670
1. Let _isLeap_ be *false*.
671+
1. If _calendar_ is not listed in the Calendar Type column of <emu-xref href="#table-calendar-types"></emu-xref>, return an implementation-defined value.
662672
1. Let _r_ be the row in <emu-xref href="#table-additional-month-codes"></emu-xref> which the _calendar_ is in the Calendar column.
663673
1. If the *"Leap to Common Month Transformation"* column of _r_ is empty, then
664674
1. Return ! ParseMonthCode(_monthCode_).[[MonthNumber]].
@@ -745,9 +755,10 @@ contributors: Google, Ecma International
745755
</h1>
746756
<dl class="header">
747757
<dt>description</dt>
748-
<dd>It performs implementation-defined processing to find the year for the date corresponding to _date_ in the context of the calendar represented by _calendar_ relative to a well-defined epoch year for that calendar.</dd>
758+
<dd>It performs implementation-defined processing to find the arithmetic year for the date corresponding to _date_ in the context of the calendar represented by _calendar_.</dd>
749759
</dl>
750760
<emu-alg>
761+
1. If _calendar_ is not listed in the Calendar Type column of <emu-xref href="#table-calendar-types"></emu-xref>, return an implementation-defined value.
751762
1. Let _r_ be the row in <emu-xref href="#table-epoch-years"></emu-xref> which the value of the Calendar column is _calendar_.
752763
1. Let _epochYear_ be the value given in the *"Epoch ISO Year"* column of _r_.
753764
1. Let _epochDate_ be the first day of the calendar year starting in ISO year _epochYear_ in the calendar represented by _calendar_, according to implementation-defined processing.
@@ -757,7 +768,7 @@ contributors: Google, Ecma International
757768
</emu-alg>
758769

759770
<emu-table id="table-epoch-years">
760-
<emu-caption>epoch years</emu-caption>
771+
<emu-caption>Epoch years</emu-caption>
761772
<table class="real-table">
762773
<thead>
763774
<tr>
@@ -828,6 +839,7 @@ contributors: Google, Ecma International
828839
</table>
829840
</emu-table>
830841
</emu-clause>
842+
831843
<emu-clause id="sec-temporal-calendardatearithmeticyearforerayear" type="abstract operation">
832844
<h1>
833845
CalendarDateArithmeticYearForEraYear (
@@ -838,11 +850,12 @@ contributors: Google, Ecma International
838850
</h1>
839851
<dl class="header">
840852
<dt>description</dt>
841-
<dd>It produces the year relative to the epoch year (the arithmetic year) for a given set of _era_, _eraYear_ in _calendar_, a calendar that includes an era named _era_.</dd>
853+
<dd>It produces the arithmetic year for a given set of _era_, _eraYear_ in _calendar_, a calendar that includes an era named _era_.</dd>
842854
</dl>
843855
<emu-alg>
844856
1. Let _era_ be CanonicalizeEraInCalendar(_calendar_, _era_).
845857
1. Assert: _era_ is not *undefined*.
858+
1. If _calendar_ is not listed in the Calendar Type column of <emu-xref href="#table-calendar-types"></emu-xref>, return an implementation-defined value.
846859
1. Let _r_ be the row in <emu-xref href="#table-eras"></emu-xref> in which _calendar_ is in the Calendar column and _era_ is in the Era column.
847860
1. Let _eraKind_ be the value given in the *"Era kind"* column of _r_.
848861
1. Let _offset_ be the value given in the *"Offset"* column of _r_.
@@ -915,9 +928,9 @@ contributors: Google, Ecma International
915928
<td>[[Year]]</td>
916929
<td>an integer</td>
917930
<td>
918-
The date's year relative to the first day of a calendar-specific "epoch year".<br>
931+
The date's <dfn>arithmetic year</dfn>, which is the year relative to the first day of a calendar-specific <dfn>epoch year</dfn>, given in <emu-xref href="#table-epoch-years"></emu-xref>.<br>
919932
The value of this field for a calendar type _calendar_ should be the result of calling CalendarDateArithmeticYear(_calendar_, _date_), where _date_ is the [[ISODate]] field of a Temporal.PlainDateTime, Temporal.PlainDate, or Temporal.PlainYearMonth value corresponding to the date.
920-
<emu-note>The year is relative to the first day of the calendar's epoch year, so if the epoch era starts in the middle of the year, the year will be the same value before and after the start date of the era.</emu-note>
933+
<emu-note>The arithmetic year is relative to the first day of the calendar's epoch year, so if the epoch era starts in the middle of the year, the year will be the same value before and after the start date of the era.</emu-note>
921934
</td>
922935
</tr>
923936
<tr>
@@ -967,7 +980,7 @@ contributors: Google, Ecma International
967980
<td>
968981
<p>The date's <em>calendar week of year</em>, and the corresponding <em>week calendar year</em>.</p>
969982
<p>The Year-Week Record's [[Week]] field should be 1-based.</p>
970-
<p>The Year-Week Record's [[Year]] field is relative to the first day of a calendar-specific "epoch year", as in the Calendar Date Record's [[Year]] field, not relative to an era as in [[EraYear]].</p>
983+
<p>The Year-Week Record's [[Year]] field is an arithmetic year as in the Calendar Date Record's [[Year]] field, not relative to an era as in [[EraYear]].</p>
971984
<p>
972985
Usually the Year-Week Record's [[Year]] field will contain the same value as the Calendar Date Record's [[Year]] field, but may contain the previous or next year if the week number in the Year-Week Record's [[Week]] field overlaps two different years.
973986
See also ISOWeekOfYear.
@@ -1288,6 +1301,7 @@ contributors: Google, Ecma International
12881301
<p>This definition supersedes the definition provided in <emu-xref href="#sec-temporal-calendarextrafields"></emu-xref>.</p>
12891302
<p>It performs the following steps when called:</p>
12901303
<emu-alg>
1304+
1. If _calendar_ is not listed in the Calendar Type column of <emu-xref href="#table-calendar-types"></emu-xref>, return an implementation-defined value.
12911305
1. If _fields_ contains an element equal to ~year~ and CalendarSupportsEra(_calendar_) is *true*, then
12921306
1. Append ~era~ and ~era-year~ to _fields_.
12931307
1. Return _fields_.
@@ -1311,6 +1325,7 @@ contributors: Google, Ecma International
13111325
<p>This definition supersedes the definition provided in <emu-xref href="#sec-temporal-nonisofieldkeystoignore"></emu-xref>.</p>
13121326
<p>It performs the following steps when called:</p>
13131327
<emu-alg>
1328+
1. If _calendar_ is not listed in the Calendar Type column of <emu-xref href="#table-calendar-types"></emu-xref>, return an implementation-defined value.
13141329
1. Let _ignoredKeys_ be an empty List.
13151330
1. For each element _key_ of _keys_, do
13161331
1. If _key_ is ~month~, append ~month-code~ to _ignoredKeys_.
@@ -1327,3 +1342,62 @@ contributors: Google, Ecma International
13271342
</emu-clause>
13281343
</emu-clause>
13291344
</emu-clause>
1345+
1346+
<emu-clause id="normative-references">
1347+
<h1>Normative References</h1>
1348+
<p>The following referenced documents are required for the application of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
1349+
1350+
<p>
1351+
ECMAScript 2026 Language Specification (<dfn id="ecma262">ECMA-262</dfn> 17<sup>th</sup> Edition, or successor).<br>
1352+
<a href="https://www.ecma-international.org/publications/standards/Ecma-262.htm">https://www.ecma-international.org/publications/standards/Ecma-262.htm</a>
1353+
</p>
1354+
1355+
<ul>
1356+
<li>
1357+
ISO/IEC 10646:2014: Information Technology – Universal Multiple-Octet Coded Character Set (UCS) plus Amendment 1:2015 and Amendment 2, plus additional amendments and corrigenda, or successor
1358+
<ul>
1359+
<li><a href="https://www.iso.org/iso/catalogue_detail.htm?csnumber=63182">https://www.iso.org/iso/catalogue_detail.htm?csnumber=63182</a></li>
1360+
<li><a href="https://www.iso.org/iso/catalogue_detail.htm?csnumber=65047">https://www.iso.org/iso/catalogue_detail.htm?csnumber=65047</a></li>
1361+
<li><a href="https://www.iso.org/iso/catalogue_detail.htm?csnumber=66791">https://www.iso.org/iso/catalogue_detail.htm?csnumber=66791</a></li>
1362+
</ul>
1363+
</li>
1364+
<li>
1365+
<a href="https://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=64758">ISO 4217:2015, Codes for the representation of currencies and funds, or successor</a>
1366+
</li>
1367+
<li>
1368+
<a href="https://tools.ietf.org/html/rfc4647">IETF RFC 4647, Matching of Language Tags, or successor</a>
1369+
</li>
1370+
<li>
1371+
<a href="https://www.iana.org/time-zones/">IANA Time Zone Database</a>
1372+
</li>
1373+
<li>
1374+
<a href="https://unicode.org/versions/latest">The Unicode Standard</a>
1375+
</li>
1376+
<li>
1377+
<a href="https://unicode.org/reports/tr29/">Unicode Standard Annex #29: Unicode Text Segmentation</a>
1378+
</li>
1379+
<li>
1380+
<a href="https://unicode.org/reports/tr10/">Unicode Technical Standard #10: Unicode Collation Algorithm</a>
1381+
</li>
1382+
<li>
1383+
<a href="https://unicode.org/reports/tr35/">Unicode Technical Standard #35: Unicode Locale Data Markup Language (LDML)</a>
1384+
<ul>
1385+
<li>
1386+
<a href="https://unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers">Part 1 Core, Section 3 Unicode Language and Locale Identifiers</a>
1387+
</li>
1388+
<li>
1389+
<a href="https://unicode.org/reports/tr35/tr35-general.html#Unit_Identifiers">Part 2 General, Section 6.2 Unit Identifiers</a>
1390+
</li>
1391+
<li>
1392+
<a href="https://unicode.org/reports/tr35/tr35-numbers.html#Operands">Part 3 Numbers, Section 5.1.1 Operands</a>
1393+
</li>
1394+
<li>
1395+
<ins><a href="https://unicode.org/reports/tr35/tr35-dates.html#Calendar_Data">Part 4 Dates, Calendar Data</a></ins>
1396+
</li>
1397+
</ul>
1398+
</li>
1399+
</ul>
1400+
<emu-note>
1401+
Sections of this specification that depend on these references are updated on a best-effort basis, but are not guaranteed to be up-to-date with those standards.
1402+
</emu-note>
1403+
</emu-clause>

0 commit comments

Comments
 (0)