Skip to content

Commit

Permalink
Normative: Drop support for sub-minute UTC offsets
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 authored and ryzokuken committed Sep 27, 2023
1 parent af4ec46 commit e25c455
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions spec/datetimeformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ <h1>
1. Else,
1. Set _timeZone_ to ? ToString(_timeZone_).
1. If IsTimeZoneOffsetString(_timeZone_) is *true*, then
1. Let _parseResult_ be ParseText(StringToCodePoints(_timeZone_), |UTCOffset|).
1. Assert: _parseResult_ is a Parse Node.
1. If _parseResult_ contains more than one |MinuteSecond| Parse Node, throw a *RangeError* exception.
1. Let _offsetNanoseconds_ be ParseTimeZoneOffsetString(_timeZone_).
1. Set _timeZone_ to FormatTimeZoneOffsetString(_offsetNanoseconds_).
1. Let _offsetMinutes_ be _offsetNanoseconds_ / (6 × 10<sup>10</sup>).
1. Assert: _offsetMinutes_ is an integer.
1. Set _timeZone_ to FormatOffsetTimeZoneIdentifier(_offsetMinutes_).
1. Else if IsValidTimeZoneName(_timeZone_) is *true*, then
1. Set _timeZone_ to CanonicalizeTimeZoneName(_timeZone_).
1. Else,
Expand Down Expand Up @@ -169,28 +174,24 @@ <h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-formattimezoneoffsetstring" aoid="FormatTimeZoneOffsetString">
<h1>FormatTimeZoneOffsetString ( _offsetNanoseconds_ )</h1>
<emu-clause id="sec-formatoffsettimezoneidentifier" type="abstract operation">
<h1>
FormatOffsetTimeZoneIdentifier (
_offsetMinutes_: an integer,
): a String
</h1>
<dl class="header">
<dt>description</dt>
<dd>
It formats a UTC offset, in minutes, into a UTC offset string formatted like ±HH:MM.
</dd>
</dl>
<emu-alg>
1. Assert: _offsetNanoseconds_ is an integer.
1. If _offsetNanoseconds_ &ge; 0, let _sign_ be the code unit 0x002B (PLUS SIGN); otherwise, let _sign_ be the code unit 0x002D (HYPHEN-MINUS).
1. Set _offsetNanoseconds_ to abs(_offsetNanoseconds_).
1. Let _nanoseconds_ be _offsetNanoseconds_ modulo 10<sup>9</sup>.
1. Let _seconds_ be floor(_offsetNanoseconds_ / 10<sup>9</sup>) modulo 60.
1. Let _minutes_ be floor(_offsetNanoseconds_ / (6 &times; 10<sup>10</sup>)) modulo 60.
1. Let _hours_ be floor(_offsetNanoseconds_ / (3.6 &times; 10<sup>12</sup>)).
1. Let _h_ be ToZeroPaddedDecimalString(_hours_, 2).
1. Let _m_ be ToZeroPaddedDecimalString(_minutes_, 2).
1. Let _s_ be ToZeroPaddedDecimalString(_seconds_, 2).
1. If _nanoseconds_ &ne; 0, then
1. Let _fraction_ be ToZeroPaddedDecimalString(_nanoseconds_, 9).
1. Set _fraction_ to the longest possible substring of _fraction_ starting at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO).
1. Let _post_ be the string-concatenation of the code unit 0x003A (COLON), _s_, the code unit 0x002E (FULL STOP), and _fraction_.
1. Else if seconds &ne; 0, then
1. Let _post_ be the string-concatenation of the code unit 0x003A (COLON) and _s_.
1. Else,
1. Let _post_ be the empty String.
1. Return the string-concatenation of _sign_, _h_, the code unit 0x003A (COLON), _m_, and _post_.
1. If _offsetMinutes_ &ge; 0, let _sign_ be the code unit 0x002B (PLUS SIGN); otherwise, let _sign_ be the code unit 0x002D (HYPHEN-MINUS).
1. Let _absoluteMinutes_ be abs(_offsetMinutes_).
1. Let _hours_ be floor(_absoluteMinutes_ / 60).
1. Let _minutes_ be _absoluteMinutes_ modulo 60.
1. Return the string-concatenation of _sign_, ToZeroPaddedDecimalString(_hours_, 2), the code unit 0x003A (COLON), and ToZeroPaddedDecimalString(_minutes_, 2).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down

0 comments on commit e25c455

Please sign in to comment.