Skip to content

Commit d28076b

Browse files
authored
Merge pull request #124 from tc39/FrankYFTang-patch-3
Normative: "always" (hours|minutes|seconds)Display "digital"
2 parents 3712e9e + d2fcedc commit d28076b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2563,7 +2563,7 @@ <h1><span class="secnum">1.1.5</span> IsValidDurationRecord ( <var>record</var>
25632563
<h1><span class="secnum">1.1.6</span> GetDurationUnitOptions ( <var>unit</var>, <var>options</var>, <var>baseStyle</var>, <var>stylesList</var>, <var>digitalBase</var>, <var>prevStyle</var> )</h1>
25642564
<p>The abstract operation GetDurationUnitOptions takes arguments <var>unit</var> (a String), <var>options</var> (an <emu-xref href="#sec-ecmascript-language-types"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types">ECMAScript language value</a></emu-xref>), <var>baseStyle</var> (a String), <var>stylesList</var> (a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> of String), <var>digitalBase</var> (a String), and <var>prevStyle</var> (a String) and returns a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> with [[Style]] and [[Display]] fields. It extracts the relevant options for any given <var>unit</var> from an options bag and returns them as a <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref>. It performs the following steps when called:</p>
25652565

2566-
<emu-alg><ol><li>Let <var>style</var> be ?&nbsp;<emu-xref aoid="GetOption"><a href="https://tc39.github.io/ecma402/#sec-getoption">GetOption</a></emu-xref>(<var>options</var>, <var>unit</var>, <emu-val>"string"</emu-val>, <var>stylesList</var>, <emu-val>undefined</emu-val>).</li><li>Let <var>displayDefault</var> be <emu-val>"always"</emu-val>.</li><li>If <var>style</var> is <emu-val>undefined</emu-val>, then<ol><li>Set <var>displayDefault</var> to <emu-val>"auto"</emu-val>.</li><li>If <var>baseStyle</var> is <emu-val>"digital"</emu-val>, then<ol><li>Set <var>style</var> to <var>digitalBase</var>.</li></ol></li><li>Else if <var>prevStyle</var> is <emu-val>"numeric"</emu-val> or <emu-val>"2-digit"</emu-val>, then<ol><li>Set <var>style</var> to <emu-val>"numeric"</emu-val>.</li></ol></li><li>Else,<ol><li>Set <var>style</var> to <var>baseStyle</var>.</li></ol></li></ol></li><li>Let <var>displayField</var> be the <emu-xref href="#sec-ecmascript-language-types-string-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-string-type">string-concatenation</a></emu-xref> of <var>unit</var> and <emu-val>"Display"</emu-val>.</li><li>Let <var>display</var> be ?&nbsp;<emu-xref aoid="GetOption"><a href="https://tc39.github.io/ecma402/#sec-getoption">GetOption</a></emu-xref>(<var>options</var>, <var>displayField</var>, <emu-val>"string"</emu-val>, « <emu-val>"auto"</emu-val>, <emu-val>"always"</emu-val> », <var>displayDefault</var>).</li><li>If <var>prevStyle</var> is <emu-val>"numeric"</emu-val> or <emu-val>"2-digit"</emu-val>, then<ol><li>If <var>style</var> is not <emu-val>"numeric"</emu-val> or <emu-val>"2-digit"</emu-val>, then<ol><li>Throw a <emu-val>RangeError</emu-val> exception.</li></ol></li><li>Else if <var>unit</var> is <emu-val>"minutes"</emu-val> or <emu-val>"seconds"</emu-val>, then<ol><li>Set <var>style</var> to <emu-val>"2-digit"</emu-val>.</li></ol></li></ol></li><li>Return the <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> {
2566+
<emu-alg><ol><li>Let <var>style</var> be ?&nbsp;<emu-xref aoid="GetOption"><a href="https://tc39.github.io/ecma402/#sec-getoption">GetOption</a></emu-xref>(<var>options</var>, <var>unit</var>, <emu-val>"string"</emu-val>, <var>stylesList</var>, <emu-val>undefined</emu-val>).</li><li>Let <var>displayDefault</var> be <emu-val>"always"</emu-val>.</li><li>If <var>style</var> is <emu-val>undefined</emu-val>, then<ol><li>If <var>baseStyle</var> is <emu-val>"digital"</emu-val>, then<ol><li>If <var>unit</var> is not one of <emu-val>"hours"</emu-val>, <emu-val>"minutes"</emu-val>, or <emu-val>"seconds"</emu-val>, then<ol><li>Set <var>displayDefault</var> to <emu-val>"auto"</emu-val>.</li></ol></li><li>Set <var>style</var> to <var>digitalBase</var>.</li></ol></li><li>Else,<ol><li>Set <var>displayDefault</var> to <emu-val>"auto"</emu-val>.</li><li>If <var>prevStyle</var> is <emu-val>"numeric"</emu-val> or <emu-val>"2-digit"</emu-val>, then<ol><li>Set <var>style</var> to <emu-val>"numeric"</emu-val>.</li></ol></li><li>Else,<ol><li>Set <var>style</var> to <var>baseStyle</var>.</li></ol></li></ol></li></ol></li><li>Let <var>displayField</var> be the <emu-xref href="#sec-ecmascript-language-types-string-type"><a href="https://tc39.es/ecma262/#sec-ecmascript-language-types-string-type">string-concatenation</a></emu-xref> of <var>unit</var> and <emu-val>"Display"</emu-val>.</li><li>Let <var>display</var> be ?&nbsp;<emu-xref aoid="GetOption"><a href="https://tc39.github.io/ecma402/#sec-getoption">GetOption</a></emu-xref>(<var>options</var>, <var>displayField</var>, <emu-val>"string"</emu-val>, « <emu-val>"auto"</emu-val>, <emu-val>"always"</emu-val> », <var>displayDefault</var>).</li><li>If <var>prevStyle</var> is <emu-val>"numeric"</emu-val> or <emu-val>"2-digit"</emu-val>, then<ol><li>If <var>style</var> is not <emu-val>"numeric"</emu-val> or <emu-val>"2-digit"</emu-val>, then<ol><li>Throw a <emu-val>RangeError</emu-val> exception.</li></ol></li><li>Else if <var>unit</var> is <emu-val>"minutes"</emu-val> or <emu-val>"seconds"</emu-val>, then<ol><li>Set <var>style</var> to <emu-val>"2-digit"</emu-val>.</li></ol></li></ol></li><li>Return the <emu-xref href="#sec-list-and-record-specification-type"><a href="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> {
25672567
[[Style]]: <var>style</var>,
25682568
[[Display]]: <var>display</var>
25692569
}.</li></ol></emu-alg>

spec.emu

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,16 @@ contributors: Ujjwal Sharma, Younies Mahmoud
236236
1. Let _style_ be ? GetOption(_options_, _unit_, *"string"*, _stylesList_, *undefined*).
237237
1. Let _displayDefault_ be *"always"*.
238238
1. If _style_ is *undefined*, then
239-
1. Set _displayDefault_ to *"auto"*.
240239
1. If _baseStyle_ is *"digital"*, then
240+
1. If _unit_ is not one of *"hours"*, *"minutes"*, or *"seconds"*, then
241+
1. Set _displayDefault_ to *"auto"*.
241242
1. Set _style_ to _digitalBase_.
242-
1. Else if _prevStyle_ is *"numeric"* or *"2-digit"*, then
243-
1. Set _style_ to *"numeric"*.
244243
1. Else,
245-
1. Set _style_ to _baseStyle_.
244+
1. Set _displayDefault_ to *"auto"*.
245+
1. If _prevStyle_ is *"numeric"* or *"2-digit"*, then
246+
1. Set _style_ to *"numeric"*.
247+
1. Else,
248+
1. Set _style_ to _baseStyle_.
246249
1. Let _displayField_ be the string-concatenation of _unit_ and *"Display"*.
247250
1. Let _display_ be ? GetOption(_options_, _displayField_, *"string"*, &laquo; *"auto"*, *"always"* &raquo;, _displayDefault_).
248251
1. If _prevStyle_ is *"numeric"* or *"2-digit"*, then

0 commit comments

Comments
 (0)