Skip to content

Commit 896b72d

Browse files
ptomatoMs2ger
authored andcommitted
Editorial: Define IsBuiltinCalendar in terms of AvailableCalendars
AvailableCalendars is an abstract operation defined in the Intl.Enumeration proposal. Sharing AvailableCalendars between ECMA-262 and ECMA-402 should allow us to stipulate that if an implementation supports any calendar for formatting in Intl.DateTimeFormat, it must support it for Temporal as well. The operation in the ECMA-402 part may change when it is resolved at some point whether AvailableCalendars should return only canonicalized names or also names like `islamicc` (instead of the canonical `islamic-civil`): tc39/proposal-intl-enumeration#37 Closes: #541
1 parent 8b8a9c3 commit 896b72d

File tree

2 files changed

+90
-27
lines changed

2 files changed

+90
-27
lines changed

spec/calendar.html

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,83 @@
55
<h1>Temporal.Calendar Objects</h1>
66
<p>A Temporal.Calendar object is an Object representing a calendar.</p>
77

8+
<emu-clause id="sec-calendar-types">
9+
<h1>Calendar Types</h1>
10+
11+
<emu-note type="editor">
12+
<p>
13+
This section shares some text with the <a href="https://tc39.es/proposal-intl-enumeration/">Intl.Enumeration proposal</a>.
14+
</p>
15+
</emu-note>
16+
17+
<p>
18+
At a minimum, ECMAScript implementations must support a built-in calendar named *"iso8601"*, representing the ISO 8601 calendar.
19+
In addition, implementations may support any number of other built-in calendars.
20+
</p>
21+
<p>
22+
ECMAScript implementations identify built-in calendars using a <dfn variants="calendar types">calendar type</dfn> as defined by <a href="https://unicode.org/reports/tr35/tr35-dates.html#Calendar_Elements">Unicode Technical Standard #35, Part 4, Section 2</a>.
23+
Their canonical form is a string containing all lower case letters with zero or more hyphens.
24+
</p>
25+
<p>
26+
<emu-xref href="#sec-temporal-calendar-constructor">The `Temporal.Calendar` constructor</emu-xref>, when called with the name of a built-in calendar as the argument, will return a valid `Temporal.Calendar` object.
27+
When called with any other string, it will throw a *RangeError* exception.
28+
</p>
29+
30+
<emu-clause id="sec-temporal-isbuiltincalendar" type="abstract operation">
31+
<h1>
32+
IsBuiltinCalendar (
33+
_id_: a String,
34+
): a Boolean
35+
</h1>
36+
<dl class="header">
37+
<dt>description</dt>
38+
<dd>The returned value is *true* if _id_ is a calendar type denoting a built-in calendar, and *false* otherwise.</dd>
39+
</dl>
40+
<emu-alg>
41+
1. Let _calendars_ be AvailableCalendars().
42+
1. If _calendars_ contains _id_, return *true*.
43+
1. Return *false*.
44+
</emu-alg>
45+
</emu-clause>
46+
47+
<emu-clause id="sec-temporal-availablecalendars" type="abstract operation">
48+
<h1>
49+
AvailableCalendars (
50+
): a List of Strings
51+
</h1>
52+
<dl class="header">
53+
<dt>description</dt>
54+
<dd>The returned List contains a single calendar type, *"iso8601"*.</dd>
55+
</dl>
56+
57+
<p>
58+
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the AvailableCalendars abstract operation as specified in the ECMA-402 specification.
59+
If an ECMAScript implementation does not include the ECMA-402 API the following specification of the AvailableCalendars abstract operation is used.
60+
</p>
61+
<emu-alg>
62+
1. Return « *"iso8601"* ».
63+
</emu-alg>
64+
</emu-clause>
65+
</emu-clause>
66+
867
<emu-clause id="sec-temporal-calendar-abstract-ops">
968
<h1>Abstract Operations for Temporal.Calendar Objects</h1>
1069

1170
<emu-clause id="sec-temporal-createtemporalcalendar" aoid="CreateTemporalCalendar">
1271
<h1>CreateTemporalCalendar ( _identifier_ [ , _newTarget_ ] )</h1>
1372
<emu-alg>
14-
1. Assert: ! IsBuiltinCalendar(_identifier_) is *true*.
73+
1. Assert: IsBuiltinCalendar(_identifier_) is *true*.
1574
1. If _newTarget_ is not provided, set _newTarget_ to %Temporal.Calendar%.
1675
1. Let _object_ be ? OrdinaryCreateFromConstructor(_newTarget_, *"%Temporal.Calendar.prototype%"*, « [[InitializedTemporalCalendar]], [[Identifier]] »).
1776
1. Set _object_.[[Identifier]] to _identifier_.
1877
1. Return _object_.
1978
</emu-alg>
2079
</emu-clause>
2180

22-
<emu-clause id="sec-temporal-isbuiltincalendar" aoid="IsBuiltinCalendar">
23-
<h1>IsBuiltinCalendar ( _id_ )</h1>
24-
<p>
25-
An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement the *IsBuiltinCalendar* abstract operation as specified in the ECMA-402 specification.
26-
If an ECMAScript implementation does not include the ECMA-402 API the following specification of the *IsBuiltinCalendar* abstract operation is used.
27-
</p>
28-
<emu-alg>
29-
1. If _id_ is not *"iso8601"*, return *false*.
30-
1. Return *true*.
31-
</emu-alg>
32-
</emu-clause>
33-
3481
<emu-clause id="sec-temporal-getbuiltincalendar" aoid="GetBuiltinCalendar">
3582
<h1>GetBuiltinCalendar ( _id_ )</h1>
3683
<emu-alg>
37-
1. If ! IsBuiltinCalendar(_id_) is *false*, throw a *RangeError* exception.
84+
1. If IsBuiltinCalendar(_id_) is *false*, throw a *RangeError* exception.
3885
1. Return ! CreateTemporalCalendar(_id_).
3986
</emu-alg>
4087
</emu-clause>
@@ -249,9 +296,9 @@ <h1>ToTemporalCalendar ( _temporalCalendarLike_ )</h1>
249296
1. Set _temporalCalendarLike_ to ? Get(_temporalCalendarLike_, *"calendar"*).
250297
1. If Type(_temporalCalendarLike_) is Object and ? HasProperty(_temporalCalendarLike_, *"calendar"*) is *false*, return _temporalCalendarLike_.
251298
1. Let _identifier_ be ? ToString(_temporalCalendarLike_).
252-
1. If ! IsBuiltinCalendar(_identifier_) is *false*, then
299+
1. If IsBuiltinCalendar(_identifier_) is *false*, then
253300
1. Set _identifier_ to ? ParseTemporalCalendarString(_identifier_).
254-
1. If ! IsBuiltinCalendar(_identifier_) is *false*, throw a *RangeError* exception.
301+
1. If IsBuiltinCalendar(_identifier_) is *false*, throw a *RangeError* exception.
255302
1. Return ! CreateTemporalCalendar(_identifier_).
256303
</emu-alg>
257304
</emu-clause>
@@ -671,7 +718,7 @@ <h1>Temporal.Calendar ( _id_ )</h1>
671718
1. If NewTarget is *undefined*, then
672719
1. Throw a *TypeError* exception.
673720
1. Set _id_ to ? ToString(_id_).
674-
1. If ! IsBuiltinCalendar(_id_) is *false*, then
721+
1. If IsBuiltinCalendar(_id_) is *false*, then
675722
1. Throw a *RangeError* exception.
676723
1. Return ? CreateTemporalCalendar(_id_, NewTarget).
677724
</emu-alg>

spec/intl.html

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,32 @@ <h1><a href="https://tc39.es/ecma402/#sec-defaulttimezone">DefaultTimeZone</a> (
8484
The DefaultTimeZone abstract operation returns a String value representing the valid (<emu-xref href="#sec-isvalidtimezonename"></emu-xref>) and canonicalized (<emu-xref href="#sec-canonicalizetimezonename"></emu-xref>) time zone name for the host environment's current time zone.
8585
</p>
8686
</emu-clause>
87+
88+
<ins class="block">
89+
<emu-clause id="sup-calendar-types">
90+
<h1>Calendar Types</h1>
91+
92+
<p>
93+
The ECMAScript 2022 Internationalization API Specification identifies calendars using a <em>calendar type</em> as defined by <a href="https://unicode.org/reports/tr35/tr35-dates.html#Calendar_Elements">Unicode Technical Standard #35, Part 4, Section 2</a>. Their canonical form is a string containing all lower case letters with zero or more hyphens.
94+
</p>
95+
96+
<emu-clause id="sup-availablecalendars" type="abstract operation">
97+
<h1>
98+
AvailableCalendars (
99+
): a List of Strings
100+
</h1>
101+
<dl class="header">
102+
<dt>description</dt>
103+
<dd>The returned List is ordered as if an Array of the same values had been sorted using %Array.prototype.sort% using *undefined* as _comparefn_, and contains unique calendar types identifying the calendars for which the implementation provides the functionality of Intl.DateTimeFormat objects.
104+
The list must include *"iso8601"*.</dd>
105+
<dt>redefinition</dt>
106+
<dd>true</dd>
107+
</dl>
108+
109+
<p>This definition supersedes the definition provided in <emu-xref href="#sec-temporal-availablecalendars"></emu-xref>.</p>
110+
</emu-clause>
111+
</emu-clause>
112+
</ins>
87113
</emu-clause>
88114

89115
<emu-clause id="sec-abstract-operations">
@@ -1301,16 +1327,6 @@ <h1><a href="https://tc39.es/ecma402/#locale-sensitive-functions">Locale Sensiti
13011327
<emu-clause id="sup-temporal-calendar-abstract-ops">
13021328
<h1>Abstract Operations for Temporal.Calendar Objects</h1>
13031329

1304-
<emu-clause id="sup-temporal-isbuiltincalendar" aoid="IsBuiltinCalendar402">
1305-
<h1>IsBuiltinCalendar ( _id_ )</h1>
1306-
<p>This definition supersedes the definition provided in <emu-xref href="#sec-temporal-isbuiltincalendar"></emu-xref>.</p>
1307-
<emu-alg>
1308-
1. Let _builtinCalendars_ be a List of Unicode BCP 47 calendar identifiers identifying the calendars for which the implementation provides the functionality of the constructed `Temporal.Calendar` objects. The list must include *"iso8601"*. The ordering is irrelevant.
1309-
1. If _builtinCalendars_ contains _id_, return *true*.
1310-
1. Return *false*.
1311-
</emu-alg>
1312-
</emu-clause>
1313-
13141330
<emu-clause id="sec-temporal-calendarera" aoid="CalendarEra">
13151331
<h1>CalendarEra ( _calendar_, _dateLike_ )</h1>
13161332
<p>

0 commit comments

Comments
 (0)