Skip to content

Commit

Permalink
Merge pull request #124 from tc39/FrankYFTang-patch-3
Browse files Browse the repository at this point in the history
Normative: "always" (hours|minutes|seconds)Display "digital"
  • Loading branch information
FrankYFTang committed Sep 22, 2022
2 parents 3712e9e + d2fcedc commit d28076b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -2563,7 +2563,7 @@ <h1><span class="secnum">1.1.5</span> IsValidDurationRecord ( <var>record</var>
<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>
<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>

<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> {
<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> {
[[Style]]: <var>style</var>,
[[Display]]: <var>display</var>
}.</li></ol></emu-alg>
Expand Down
11 changes: 7 additions & 4 deletions spec.emu
Expand Up @@ -236,13 +236,16 @@ contributors: Ujjwal Sharma, Younies Mahmoud
1. Let _style_ be ? GetOption(_options_, _unit_, *"string"*, _stylesList_, *undefined*).
1. Let _displayDefault_ be *"always"*.
1. If _style_ is *undefined*, then
1. Set _displayDefault_ to *"auto"*.
1. If _baseStyle_ is *"digital"*, then
1. If _unit_ is not one of *"hours"*, *"minutes"*, or *"seconds"*, then
1. Set _displayDefault_ to *"auto"*.
1. Set _style_ to _digitalBase_.
1. Else if _prevStyle_ is *"numeric"* or *"2-digit"*, then
1. Set _style_ to *"numeric"*.
1. Else,
1. Set _style_ to _baseStyle_.
1. Set _displayDefault_ to *"auto"*.
1. If _prevStyle_ is *"numeric"* or *"2-digit"*, then
1. Set _style_ to *"numeric"*.
1. Else,
1. Set _style_ to _baseStyle_.
1. Let _displayField_ be the string-concatenation of _unit_ and *"Display"*.
1. Let _display_ be ? GetOption(_options_, _displayField_, *"string"*, &laquo; *"auto"*, *"always"* &raquo;, _displayDefault_).
1. If _prevStyle_ is *"numeric"* or *"2-digit"*, then
Expand Down

0 comments on commit d28076b

Please sign in to comment.