Skip to content

Commit cf586bc

Browse files
committed
Editorial: Refactor calendar formatting operations
The repeated normative change in the previous commit goes into its own abstract operation, MaybeFormatCalendarAnnotation. While we are at it, updates FormatCalendarAnnotation to use a structured header, and updates the link in the editor's note.
1 parent 6122f4e commit cf586bc

File tree

6 files changed

+45
-25
lines changed

6 files changed

+45
-25
lines changed

spec/calendar.html

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -389,21 +389,53 @@ <h1>
389389
</emu-alg>
390390
</emu-clause>
391391

392-
<emu-clause id="sec-temporal-formatcalendarannotation" aoid="FormatCalendarAnnotation">
393-
<h1>FormatCalendarAnnotation ( _id_, _showCalendar_ )</h1>
394-
<p>
395-
The abstract operation FormatCalendarAnnotation returns a string with a calendar annotation suitable for concatenating to the end of an ISO 8601 string.
396-
Depending on the given _id_ and value of _showCalendar_, the string may be empty if no calendar annotation need be included.
397-
</p>
392+
<emu-clause id="sec-temporal-maybeformatcalendarannotation" type="abstract operation">
393+
<h1>
394+
MaybeFormatCalendarAnnotation (
395+
_calendarObject_: an Object,
396+
_showCalendar_: one of *"auto"*, *"always"*, or *"never"*,
397+
): either a normal completion containing a String, or an abrupt completion
398+
</h1>
399+
<dl class="header">
400+
<dt>description</dt>
401+
<dd>
402+
It returns a string with a calendar annotation suitable for concatenating to the end of an ISO 8601 string.
403+
Depending on the given _calendarObject_ and the value of _showCalendar_, the string may be empty if no calendar annotation need be included.
404+
This operation may invoke an observable ToString operation on _calendarObject_, but not if _showCalendar_ is *"never"*.
405+
</dd>
406+
</dl>
407+
<emu-alg>
408+
1. If _showCalendar_ is *"never"*, return the empty String.
409+
1. Let _calendarID_ be ? ToString(_calendarObject_).
410+
1. Return FormatCalendarAnnotation(_calendarID_, _showCalendar_).
411+
</emu-alg>
398412
<emu-note type="editor">
399-
The exact form this annotation will take is undergoing a standardization process in the IETF; it is being discussed in the Internet Draft <a href="https://ryzokuken.dev/draft-ryzokuken-datetime-extended/documents/rfc-3339.html#name-internet-date-time-format">Date and Time on the Internet: Timestamps with additional information</a>.
413+
The exact form this annotation will take is undergoing a standardization process in the IETF; it is being discussed in the Internet Draft <a href="https://datatracker.ietf.org/doc/html/draft-ietf-sedate-datetime-extended">Date and Time on the Internet: Timestamps with additional information</a>.
400414
</emu-note>
415+
</emu-clause>
416+
417+
<emu-clause id="sec-temporal-formatcalendarannotation" type="abstract operation">
418+
<h1>
419+
FormatCalendarAnnotation (
420+
_id_: a String,
421+
_showCalendar_: one of *"auto"*, *"always"*, or *"never"*,
422+
): a String
423+
</h1>
424+
<dl class="header">
425+
<dt>description</dt>
426+
<dd>
427+
It returns a string with a calendar annotation suitable for concatenating to the end of an ISO 8601 string.
428+
Depending on the given _id_ and value of _showCalendar_, the string may be empty if no calendar annotation need be included.
429+
</dd>
430+
</dl>
401431
<emu-alg>
402-
1. Assert: _showCalendar_ is *"auto"*, *"always"*, or *"never"*.
403432
1. If _showCalendar_ is *"never"*, return the empty String.
404433
1. If _showCalendar_ is *"auto"* and _id_ is *"iso8601"*, return the empty String.
405434
1. Return the string-concatenation of *"[u-ca="*, _id_, and *"]"*.
406435
</emu-alg>
436+
<emu-note type="editor">
437+
The exact form this annotation will take is undergoing a standardization process in the IETF; it is being discussed in the Internet Draft <a href="https://datatracker.ietf.org/doc/html/draft-ietf-sedate-datetime-extended">Date and Time on the Internet: Timestamps with additional information</a>.
438+
</emu-note>
407439
</emu-clause>
408440

409441
<emu-clause id="sec-temporal-calendarequals" aoid="CalendarEquals">

spec/plaindate.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -887,11 +887,7 @@ <h1>TemporalDateToString ( _temporalDate_, _showCalendar_ )</h1>
887887
1. Let _year_ be ! PadISOYear(_temporalDate_.[[ISOYear]]).
888888
1. Let _month_ be ToZeroPaddedDecimalString(_temporalDate_.[[ISOMonth]], 2).
889889
1. Let _day_ be ToZeroPaddedDecimalString(_temporalDate_.[[ISODay]], 2).
890-
1. If _showCalendar_ is *"never"*, then
891-
1. Let _calendar_ be the empty String.
892-
1. Else,
893-
1. Let _calendarID_ be ? ToString(_temporalDate_.[[Calendar]]).
894-
1. Let _calendar_ be ! FormatCalendarAnnotation(_calendarID_, _showCalendar_).
890+
1. Let _calendar_ be ? MaybeFormatCalendarAnnotation(_temporalDate_.[[Calendar]], _showCalendar_).
895891
1. Return the string-concatenation of _year_, the code unit 0x002D (HYPHEN-MINUS), _month_, the code unit 0x002D (HYPHEN-MINUS), _day_, and _calendar_.
896892
</emu-alg>
897893
</emu-clause>

spec/plaindatetime.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -964,11 +964,7 @@ <h1>TemporalDateTimeToString ( _isoYear_, _isoMonth_, _isoDay_, _hour_, _minute_
964964
1. Let _hour_ be ToZeroPaddedDecimalString(_hour_, 2).
965965
1. Let _minute_ be ToZeroPaddedDecimalString(_minute_, 2).
966966
1. Let _seconds_ be ! FormatSecondsStringPart(_second_, _millisecond_, _microsecond_, _nanosecond_, _precision_).
967-
1. If _showCalendar_ is *"never"*, then
968-
1. Let _calendarString_ be the empty String.
969-
1. Else,
970-
1. Let _calendarID_ be ? ToString(_calendar_).
971-
1. Let _calendarString_ be ! FormatCalendarAnnotation(_calendarID_, _showCalendar_).
967+
1. Let _calendarString_ be ? MaybeFormatCalendarAnnotation(_calendar_, _showCalendar_).
972968
1. Return the string-concatenation of _year_, the code unit 0x002D (HYPHEN-MINUS), _month_, the code unit 0x002D (HYPHEN-MINUS), _day_, 0x0054 (LATIN CAPITAL LETTER T), _hour_, the code unit 0x003A (COLON), _minute_, _seconds_, and _calendarString_.
973969
</emu-alg>
974970
</emu-clause>

spec/plainmonthday.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ <h1>TemporalMonthDayToString ( _monthDay_, _showCalendar_ )</h1>
411411
1. If _showCalendar_ is *"always"* or if _calendarID_ is not *"iso8601"*, then
412412
1. Let _year_ be ! PadISOYear(_monthDay_.[[ISOYear]]).
413413
1. Set _result_ to the string-concatenation of _year_, the code unit 0x002D (HYPHEN-MINUS), and _result_.
414-
1. Let _calendarString_ be ! FormatCalendarAnnotation(_calendarID_, _showCalendar_).
414+
1. Let _calendarString_ be FormatCalendarAnnotation(_calendarID_, _showCalendar_).
415415
1. Set _result_ to the string-concatenation of _result_ and _calendarString_.
416416
1. Return _result_.
417417
</emu-alg>

spec/plainyearmonth.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ <h1>TemporalYearMonthToString ( _yearMonth_, _showCalendar_ )</h1>
590590
1. If _showCalendar_ is *"always"* or if _calendarID_ is not *"iso8601"*, then
591591
1. Let _day_ be ToZeroPaddedDecimalString(_yearMonth_.[[ISODay]], 2).
592592
1. Set _result_ to the string-concatenation of _result_, the code unit 0x002D (HYPHEN-MINUS), and _day_.
593-
1. Let _calendarString_ be ! FormatCalendarAnnotation(_calendarID_, _showCalendar_).
593+
1. Let _calendarString_ be FormatCalendarAnnotation(_calendarID_, _showCalendar_).
594594
1. Set _result_ to the string-concatenation of _result_ and _calendarString_.
595595
1. Return _result_.
596596
</emu-alg>

spec/zoneddatetime.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,11 +1196,7 @@ <h1>
11961196
1. Else,
11971197
1. Let _timeZoneID_ be ? ToString(_timeZone_).
11981198
1. Let _timeZoneString_ be the string-concatenation of the code unit 0x005B (LEFT SQUARE BRACKET), _timeZoneID_, and the code unit 0x005D (RIGHT SQUARE BRACKET).
1199-
1. If _showCalendar_ is *"never"*, then
1200-
1. Let _calendarString_ be the empty String.
1201-
1. Else,
1202-
1. Let _calendarID_ be ? ToString(_zonedDateTime_.[[Calendar]]).
1203-
1. Let _calendarString_ be ! FormatCalendarAnnotation(_calendarID_, _showCalendar_).
1199+
1. Let _calendarString_ be ? MaybeFormatCalendarAnnotation(_zonedDateTime_.[[Calendar]], _showCalendar_).
12041200
1. Return the string-concatenation of _dateTimeString_, _offsetString_, _timeZoneString_, and _calendarString_.
12051201
</emu-alg>
12061202
</emu-clause>

0 commit comments

Comments
 (0)