You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The PartitionDurationFormatPattern abstract operation is called with the arguments <var>durationFormat</var> (which must be an object initialized as a DurationFormat) and <var>duration</var> (which must be a <emu-xrefhref="#sec-list-and-record-specification-type"><ahref="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> with the fields enumerated in <emu-xrefhref="#table-duration-components" id="_ref_0"><ahref="#table-duration-components">Table 1</a></emu-xref> ), and creates the corresponding parts according to the effective locale and the formatting options of <var>durationFormat</var>. The following steps are taken:</p>
1882
1882
1883
-
<emu-alg><ol><li>Let <var>result</var> be a new empty <emu-xrefhref="#sec-list-and-record-specification-type"><ahref="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>If <var>durationFormat</var>.[[Style]] is <code>"dotted"</code>, then<ol><li>Let <var>patternParts</var> be <emu-xrefaoid="PartitionPattern"><ahref="https://tc39.github.io/ecma402/#sec-partitionpattern">PartitionPattern</a></emu-xref>(<var>durationFormat</var>.[[Templates]]).</li><li>For each <var>patternPart</var> in <var>patternParts</var>, do<ol><li>Let <var>p</var> be <var>patternPart</var>.[[Type]].</li><li>If <var>p</var> is <code>"literal"</code>, then<ol><li>Append <var>patternPart</var> to the end of <var>result</var>.</li></ol></li><li>Else if <var>duration</var>[[<<var>p</var>>]] is not <emu-val>undefined</emu-val> and <var>p</var> exists in <var>durationFormat</var>.[[Fields]], then<ol><li>Let <var>num</var> be <emu-xrefaoid="FormatNumeric"><ahref="https://tc39.github.io/ecma402/#sec-formatnumber">FormatNumeric</a></emu-xref>(<var>durationFormat</var>.[[NumberFormat]], <var>duration</var>[[<<var>p</var>>]]).</li><li>Append the new <emu-xrefhref="#sec-list-and-record-specification-type"><ahref="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> { [[Type]]: <var>p</var>, [[Value]]: <var>num</var> } to the end of <var>result</var>.</li></ol></li></ol></li></ol></li><li>Else,<ol><li>For each row in <emu-xrefhref="#table-duration-components" id="_ref_1"><ahref="#table-duration-components">Table 1</a></emu-xref> except the header row, do<ol><li>Let <var>field</var> be the Property value.</li><li>Let <var>val</var> be <var>duration</var>.[[<<var>field</var>>]]</li><li>If <var>val</var> is not <emu-val>undefined</emu-val> and <var>field</var> exists in <var>durationFormat</var>.[[Fields]], then<ol><li>Let <var>num</var> be ! <emu-xrefaoid="PartitionNumberPattern"><ahref="https://tc39.github.io/ecma402/#sec-partitionnumberpattern">PartitionNumberPattern</a></emu-xref>(<var>durationFormat</var>.[[NumberFormat]], val).</li><li>Let <var>pr</var> be ! <emu-xrefaoid="ResolvePlural"><ahref="https://tc39.github.io/ecma402/#sec-resolveplural">ResolvePlural</a></emu-xref>(<var>durationFormat</var>.[[PluralRules]], val).</li><li>Let <var>template</var> be <var>durationFormat</var>.[[Templates]].[[<<var>field</var>>]].[[<<var>pr</var>>]].</li><li>Let <var>parts</var> be ! <emu-xrefaoid="MakePartsList"><ahref="https://tc39.github.io/ecma402/#sec-makepartslist">MakePartsList</a></emu-xref>(<var>template</var>, <var>field</var>, <var>num</var>).</li><li>Let <var>concat</var> be an empty String.</li><li>For each <var>part</var> in <var>parts</var>, do<ol><li>Set <var>concat</var> to the <emu-xrefhref="#sec-ecmascript-language-types-string-type"><ahref="https://tc39.es/ecma262/#sec-ecmascript-language-types-string-type">string-concatenation</a></emu-xref> of <var>concat</var> and <var>part</var>.[[Value]].</li><li>If <var>part</var> has a [[Unit]] field, then<ol><li>Set <var>concat</var> to the <emu-xrefhref="#sec-ecmascript-language-types-string-type"><ahref="https://tc39.es/ecma262/#sec-ecmascript-language-types-string-type">string-concatenation</a></emu-xref> of <var>concat</var> and <var>part</var>.[[Unit]].</li></ol></li></ol></li><li>Append the new <emu-xrefhref="#sec-list-and-record-specification-type"><ahref="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> { [[Type]]: <var>field</var>, [[Value]]: <var>concat</var> } to the end of <var>result</var>.</li></ol></li></ol></li><li>Set <var>result</var> to ! <emu-xrefaoid="CreatePartsFromList"><ahref="https://tc39.github.io/proposal-intl-list-format/#sec-createpartsfromlist">CreatePartsFromList</a></emu-xref>(<var>durationFormat</var>.[[ListFormat]], <var>result</var>).</li></ol></li><li>Return <var>result</var>.
1883
+
<emu-alg><ol><li>Let <var>result</var> be a new empty <emu-xrefhref="#sec-list-and-record-specification-type"><ahref="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref>.</li><li>If <var>durationFormat</var>.[[Style]] is <code>"dotted"</code>, then<ol><li><mark>TODO: [[Templates]] needs to be keyed by which fields are available in this case.</mark></li><li>Let <var>patternParts</var> be <emu-xrefaoid="PartitionPattern"><ahref="https://tc39.github.io/ecma402/#sec-partitionpattern">PartitionPattern</a></emu-xref>(<var>durationFormat</var>.[[Templates]]).</li><li>For each <var>patternPart</var> in <var>patternParts</var>, do<ol><li>Let <var>p</var> be <var>patternPart</var>.[[Type]].</li><li>If <var>p</var> is <code>"literal"</code>, then<ol><li>Append <var>patternPart</var> to the end of <var>result</var>.</li></ol></li><li>Else if <var>duration</var>[[<<var>p</var>>]] is not <emu-val>undefined</emu-val> and <var>p</var> exists in <var>durationFormat</var>.[[Fields]], then<ol><li>Let <var>num</var> be <emu-xrefaoid="FormatNumeric"><ahref="https://tc39.github.io/ecma402/#sec-formatnumber">FormatNumeric</a></emu-xref>(<var>durationFormat</var>.[[NumberFormat]], <var>duration</var>[[<<var>p</var>>]]).</li><li>Append the new <emu-xrefhref="#sec-list-and-record-specification-type"><ahref="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> { [[Type]]: <var>p</var>, [[Value]]: <var>num</var> } to the end of <var>result</var>.</li></ol></li></ol></li></ol></li><li>Else,<ol><li>For each row in <emu-xrefhref="#table-duration-components" id="_ref_1"><ahref="#table-duration-components">Table 1</a></emu-xref> except the header row, do<ol><li>Let <var>field</var> be the Property value.</li><li>Let <var>val</var> be <var>duration</var>.[[<<var>field</var>>]]</li><li>If <var>val</var> is not <emu-val>undefined</emu-val> and <var>field</var> exists in <var>durationFormat</var>.[[Fields]], then<ol><li>Let <var>num</var> be ! <emu-xrefaoid="PartitionNumberPattern"><ahref="https://tc39.github.io/ecma402/#sec-partitionnumberpattern">PartitionNumberPattern</a></emu-xref>(<var>durationFormat</var>.[[NumberFormat]], val).</li><li>Let <var>pr</var> be ! <emu-xrefaoid="ResolvePlural"><ahref="https://tc39.github.io/ecma402/#sec-resolveplural">ResolvePlural</a></emu-xref>(<var>durationFormat</var>.[[PluralRules]], val).</li><li>Let <var>template</var> be <var>durationFormat</var>.[[Templates]].[[<<var>field</var>>]].[[<<var>pr</var>>]].</li><li>Let <var>parts</var> be ! <emu-xrefaoid="MakePartsList"><ahref="https://tc39.github.io/ecma402/#sec-makepartslist">MakePartsList</a></emu-xref>(<var>template</var>, <var>field</var>, <var>num</var>).</li><li>Let <var>concat</var> be an empty String.</li><li>For each <var>part</var> in <var>parts</var>, do<ol><li>Set <var>concat</var> to the <emu-xrefhref="#sec-ecmascript-language-types-string-type"><ahref="https://tc39.es/ecma262/#sec-ecmascript-language-types-string-type">string-concatenation</a></emu-xref> of <var>concat</var> and <var>part</var>.[[Value]].</li><li>If <var>part</var> has a [[Unit]] field, then<ol><li>Set <var>concat</var> to the <emu-xrefhref="#sec-ecmascript-language-types-string-type"><ahref="https://tc39.es/ecma262/#sec-ecmascript-language-types-string-type">string-concatenation</a></emu-xref> of <var>concat</var> and <var>part</var>.[[Unit]].</li></ol></li></ol></li><li>Append the new <emu-xrefhref="#sec-list-and-record-specification-type"><ahref="https://tc39.es/ecma262/#sec-list-and-record-specification-type">Record</a></emu-xref> { [[Type]]: <var>field</var>, [[Value]]: <var>concat</var> } to the end of <var>result</var>.</li></ol></li></ol></li><li>Set <var>result</var> to ! <emu-xrefaoid="CreatePartsFromList"><ahref="https://tc39.github.io/proposal-intl-list-format/#sec-createpartsfromlist">CreatePartsFromList</a></emu-xref>(<var>durationFormat</var>.[[ListFormat]], <var>result</var>).</li></ol></li><li>Return <var>result</var>.
<p>The value of the [[LocaleData]] internal slot is implementation defined within the constraints described in <emu-xrefhref="#sec-internal-slots"><ahref="https://tc39.github.io/ecma402/#sec-internal-slots">9.1</a></emu-xref> and the following additional constraints for all locale values <var>locale</var>:</p>
1935
1935
1936
1936
<ul>
1937
-
1938
1937
<li>[[LocaleData]].[[<<var>locale</var>>]].[[nu]] must be a <emu-xrefhref="#sec-list-and-record-specification-type"><ahref="https://tc39.es/ecma262/#sec-list-and-record-specification-type">List</a></emu-xref> as specified in <emu-xrefhref="#sec-intl.numberformat-internal-slots"><ahref="https://tc39.github.io/ecma402/#sec-intl.numberformat-internal-slots">12.3.3</a></emu-xref>.</li>
1939
1938
<li>[[LocaleData]].[[<<var>locale</var>>]] must have a [[formats]] field. The value of this field must be a record, which must have fields with the names of the four formatting styles: <code>long</code>, <code>short</code>, <code>narrow</code>, and <code>dotted</code>. Each of first three fields must be records themselves, and each must have fields with the names of the supported units: <code>nanonseconds</code>, <code>microseconds</code>, <code>milliseconds</code>, <code>seconds</code>, <code>minutes</code>, <code>hours</code>, <code>days</code>, <code>weeks</code>, <code>months</code>, and <code>years</code>, which are Records with a field for each of the plural categories relevant for <var>locale</var>; the value corresponding to those fields is a pattern which may contain "{0}" to be replaced by a formatted number. The value of the fourth field, corresponding to the <code>dotted</code> style, on the other hand, should be a pattern; i.e. a String that contains for an arbitrary subset of the Duration component fields a substring starting with <code>"{"</code>, followed by the name of the field, followed by <code>"}"</code>.</li>
1940
1939
</ul>
1941
1940
1942
-
<emu-notetype="editor"><spanclass="note">Editor's Note</span><divclass="note-contents">It is recommended that implementations use the locale data provided by the Common Locale Data Repository (available at <ahref="http://cldr.unicode.org/">http://cldr.unicode.org/</a>).</div></emu-note>
1941
+
<emu-notetype="editor"><spanclass="note">Editor's Note</span><divclass="note-contents">TODO: [[formats]].[[dotted]] need to be keyed by the available fields.</div></emu-note>
1942
+
<emu-note><spanclass="note">Note</span><divclass="note-contents">It is recommended that implementations use the locale data provided by the Common Locale Data Repository (available at <ahref="http://cldr.unicode.org/">http://cldr.unicode.org/</a>).</div></emu-note>
1943
1943
</emu-clause>
1944
1944
</emu-clause>
1945
1945
@@ -2036,6 +2036,7 @@ <h1><span class="secnum">1.5</span> Properties of Intl.DurationFormat Instances<
2036
2036
<li>[[PluralRules]] is an Intl.PluralRules object used for formatting.</li>
2037
2037
<li>[[ListFormat]] is an Intl.ListFormat object used for formatting.</li>
2038
2038
</ul>
2039
+
<emu-notetype="editor"><spanclass="note">Editor's Note</span><divclass="note-contents">[[Templates]] needs to be keyed by the available fields when [[Style]] is "dotted"</div></emu-note>
<p>The value of the [[LocaleData]] internal slot is implementation defined within the constraints described in <emu-xref href="#sec-internal-slots"></emu-xref> and the following additional constraints for all locale values _locale_:</p>
202
203
203
204
<ul>
204
-
205
205
<li>[[LocaleData]].[[<_locale_>]].[[nu]] must be a List as specified in <emu-xref href="#sec-intl.numberformat-internal-slots"></emu-xref>.</li>
206
206
<li>[[LocaleData]].[[<_locale_>]] must have a [[formats]] field. The value of this field must be a record, which must have fields with the names of the four formatting styles: `long`, `short`, `narrow`, and `dotted`. Each of first three fields must be records themselves, and each must have fields with the names of the supported units: `nanonseconds`, `microseconds`, `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `weeks`, `months`, and `years`, which are Records with a field for each of the plural categories relevant for _locale_; the value corresponding to those fields is a pattern which may contain "{0}" to be replaced by a formatted number. The value of the fourth field, corresponding to the `dotted` style, on the other hand, should be a pattern; i.e. a String that contains for an arbitrary subset of the Duration component fields a substring starting with `"{"`, followed by the name of the field, followed by `"}"`.</li>
207
207
</ul>
208
208
209
-
<emu-note type=editor>It is recommended that implementations use the locale data provided by the Common Locale Data Repository (available at <a href="http://cldr.unicode.org/">http://cldr.unicode.org/</a>).</emu-note>
209
+
<emu-note type=editor>TODO: [[formats]].[[dotted]] need to be keyed by the available fields.</emu-note>
210
+
<emu-note>It is recommended that implementations use the locale data provided by the Common Locale Data Repository (available at <a href="http://cldr.unicode.org/">http://cldr.unicode.org/</a>).</emu-note>
0 commit comments