Skip to content

Commit 96bb9b0

Browse files
ptomatovoiestad
authored andcommitted
Editorial: Introduce Time Zone Identifier Parse Record
This Record was previously anonymous. Introduce it as a specific Record type in order to clarify the limits of the [[OffsetMinutes]] field and that the two fields are mutually exclusive. Since this type information is considered to be equivalent to assertions, this allows removing some assertions and some descriptive text from elsewhere. Credit to Vebjørn Øiestad for discovering this. Co-Authored-By: Vebjørn Øiestad <102312685+voiestad@users.noreply.github.com>
1 parent 53731c2 commit 96bb9b0

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

spec/abstractops.html

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,36 @@ <h1>ISO String Time Zone Parse Records</h1>
14111411
</emu-table>
14121412
</emu-clause>
14131413

1414+
<emu-clause id="sec-temporal-time-zone-identifier-parse-records">
1415+
<h1>Time Zone Identifier Parse Records</h1>
1416+
<p>A <dfn variants="Time Zone Identifier Parse Records">Time Zone Identifier Parse Record</dfn> is a Record value used to represent the result of parsing a time zone identifier either as an offset time zone or named time zone.</p>
1417+
<p>Time Zone Identifier Parse Records have the fields listed in <emu-xref href="#table-temporal-time-zone-identifier-parse-record-fields"></emu-xref>.</p>
1418+
<p>The two fields are mutually exclusive. One of them always has the value ~empty~.</p>
1419+
<emu-table id="table-temporal-time-zone-identifier-parse-record-fields" caption="Time Zone Identifier Parse Record Fields">
1420+
<table class="real-table">
1421+
<tr>
1422+
<th>Field Name</th>
1423+
<th>Value</th>
1424+
<th>Meaning</th>
1425+
</tr>
1426+
<tr>
1427+
<td>[[Name]]</td>
1428+
<td>a String or ~empty~</td>
1429+
<td>
1430+
The time zone's name (not necessarily an available named time zone identifier), or ~empty~ if the time zone is an offset time zone.
1431+
</td>
1432+
</tr>
1433+
<tr>
1434+
<td>[[OffsetMinutes]]</td>
1435+
<td>an integer in the inclusive interval from -1439 to 1439, or ~empty~</td>
1436+
<td>
1437+
The time zone's UTC offset expressed as a number of minutes, or ~empty~ if the time zone is a named time zone.
1438+
</td>
1439+
</tr>
1440+
</table>
1441+
</emu-table>
1442+
</emu-clause>
1443+
14141444
<emu-clause id="sec-temporal-iso-date-time-parse-records">
14151445
<h1>ISO Date-Time Parse Records</h1>
14161446
<p>An <dfn variants="ISO Date-Time Parse Records">ISO Date-Time Parse Record</dfn> is a Record value used to represent the result of parsing an ISO 8601 / RFC 9557 string.</p>
@@ -1706,20 +1736,20 @@ <h1>
17061736
<h1>
17071737
ParseTemporalTimeZoneString (
17081738
_timeZoneString_: a String,
1709-
): either a normal completion containing a Record containing information about the time zone, or a throw completion
1739+
): either a normal completion containing a Time Zone Identifier Parse Record, or a throw completion
17101740
</h1>
17111741
<dl class="header">
17121742
<dt>description</dt>
17131743
<dd>
17141744
It parses the argument as either a time zone identifier or an ISO 8601 / RFC 9557 string.
17151745
The returned Record's fields are set as follows:
17161746
<ul>
1717-
<li>If _timeZoneString_ is a named time zone identifier, then [[Name]] is _timeZoneString_ and [[OffsetMinutes]] is ~empty~.</li>
1718-
<li>Otherwise, if _timeZoneString_ is an offset time zone identifier, then [[OffsetMinutes]] is a signed integer and [[Name]] is ~empty~.</li>
1719-
<li>Otherwise, if _timeZoneString_ is a string with a time zone annotation containing a named time zone identifier, then [[Name]] is the time zone identifier contained in the annotation and [[OffsetMinutes]] is ~empty~.</li>
1720-
<li>Otherwise, if _timeZoneString_ is a string with a time zone annotation containing an offset time zone identifier, then [[OffsetMinutes]] is a signed integer and [[Name]] is ~empty~.</li>
1721-
<li>Otherwise, if _timeZoneString_ is a string using a *Z* offset designator, then [[Name]] is *"UTC"* and [[OffsetMinutes]] is ~empty~.</li>
1722-
<li>Otherwise, if _timeZoneString_ is a string using a numeric UTC offset, then [[OffsetMinutes]] is a signed integer and [[Name]] is ~empty~.</li>
1747+
<li>If _timeZoneString_ is a named time zone identifier, then [[Name]] is _timeZoneString_.</li>
1748+
<li>Otherwise, if _timeZoneString_ is an offset time zone identifier, then [[OffsetMinutes]] is the time zone's UTC offset.</li>
1749+
<li>Otherwise, if _timeZoneString_ is a string with a time zone annotation containing a named time zone identifier, then [[Name]] is the time zone identifier contained in the annotation.</li>
1750+
<li>Otherwise, if _timeZoneString_ is a string with a time zone annotation containing an offset time zone identifier, then [[OffsetMinutes]] is the time zone's UTC offset.</li>
1751+
<li>Otherwise, if _timeZoneString_ is a string using a *Z* offset designator, then [[Name]] is *"UTC"*.</li>
1752+
<li>Otherwise, if _timeZoneString_ is a string using a numeric UTC offset, then [[OffsetMinutes]] is that numeric UTC offset.</li>
17231753
<li>Otherwise, a *RangeError* is thrown.</li>
17241754
</ul>
17251755
</dd>

spec/timezone.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,12 @@ <h1>
418418
<h1>
419419
ParseTimeZoneIdentifier (
420420
_identifier_: a String,
421-
): either a normal completion containing a Record with fields [[Name]] (a named time zone identifier or ~empty~) and [[OffsetMinutes]] (an integer or ~empty~), or a throw completion
421+
): either a normal completion containing a Time Zone Identifier Parse Record, or a throw completion
422422
</h1>
423423
<dl class="header">
424424
<dt>description</dt>
425425
<dd>
426-
If _identifier_ is a named time zone identifier, [[Name]] will be _identifier_ and [[OffsetMinutes]] will be ~empty~.
427-
If _identifier_ is an offset time zone identifier, [[Name]] will be ~empty~ and [[OffsetMinutes]] will be a signed integer.
428-
Otherwise, a *RangeError* will be thrown.
426+
It parses _identifier_ to determine whether it identifies an offset time zone or named time zone. If _identifier_ is syntactically invalid, a *RangeError* will be thrown.
429427
</dd>
430428
</dl>
431429
<emu-alg>
@@ -434,14 +432,13 @@ <h1>
434432
1. If _parseResult_ contains a |TimeZoneIANAName| Parse Node, then
435433
1. Let _name_ be the source text matched by the |TimeZoneIANAName| Parse Node contained within _parseResult_.
436434
1. NOTE: _name_ is syntactically valid, but does not necessarily conform to <a href="https://data.iana.org/time-zones/theory.html#naming">IANA Time Zone Database naming guidelines</a> or correspond with an available named time zone identifier.
437-
1. Return the Record { [[Name]]: CodePointsToString(_name_), [[OffsetMinutes]]: ~empty~ }.
435+
1. Return Time Zone Identifier Parse Record { [[Name]]: CodePointsToString(_name_), [[OffsetMinutes]]: ~empty~ }.
438436
1. Else,
439437
1. Assert: _parseResult_ contains a |UTCOffset[~SubMinutePrecision]| Parse Node.
440438
1. Let _offset_ be the source text matched by the |UTCOffset[~SubMinutePrecision]| Parse Node contained within _parseResult_.
441439
1. Let _offsetNanoseconds_ be ! ParseDateTimeUTCOffset(CodePointsToString(_offset_)).
442440
1. Let _offsetMinutes_ be _offsetNanoseconds_ / (60 × 10<sup>9</sup>).
443-
1. Assert: _offsetMinutes_ is an integer.
444-
1. Return the Record { [[Name]]: ~empty~, [[OffsetMinutes]]: _offsetMinutes_ }.
441+
1. Return Time Zone Identifier Parse Record { [[Name]]: ~empty~, [[OffsetMinutes]]: _offsetMinutes_ }.
445442
</emu-alg>
446443
</emu-clause>
447444
</emu-clause>

0 commit comments

Comments
 (0)