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
Editorial: Account for [[pattern]] etc. in AdjustDateTimeStyleFormat
Based on Anba's suggestion:
#3273 (comment)
We pass a List of property names into AdjustDateTimeStyleFormat instead
of a List of field names, so they can be compared directly with the
"Property" column of the "Components of date and time formats" table.
This avoids the problem of formats having other fields such as
[[pattern]] and [[pattern12]] that would always conflict with the
allowed fields.
Co-Authored-By: André Bargull <andre.bargull@gmail.com>
1. <ins>Set _dateTimeFormat_.[[TemporalInstantFormat]] to _bestFormat_.</ins>
480
480
1. Else,
481
481
1. <del>Let _needDefaults_ be *true*.</del>
@@ -647,7 +647,7 @@ <h1>
647
647
_formats_: a List of DateTime Format Records,
648
648
_baseFormat_: a DateTime Format Record,
649
649
_matcher_: either *"basic"* or *"best fit"*,
650
-
_allowedOptions_: a List of field names,
650
+
_allowedOptions_: a List of property names from the "Property" column of <emu-xrefhref="#table-datetimeformat-components"></emu-xref>,
651
651
): a DateTime Format Record
652
652
</h1>
653
653
<dlclass="header">
@@ -660,13 +660,14 @@ <h1>
660
660
</dl>
661
661
<emu-alg>
662
662
1. Let _anyConflictingFields_ be *false*.
663
-
1. For each name _name_ of fields present in _baseFormat_, do
664
-
1. If _allowedOptions_ does not contain _name_, set _anyConflictingFields_ to *true*.
663
+
1. For each row of <emu-xrefhref="#table-datetimeformat-components"></emu-xref>, except the header row, in table order, do
664
+
1. Let _prop_ be the name given in the "Property" column of the current row.
665
+
1. If _baseFormat_ has a [[<_prop_>]] field and _allowedOptions_ does not contain _prop_, set _anyConflictingFields_ to true.
665
666
1. If _anyConflictingFields_ is *false*, return _baseFormat_.
666
667
1. NOTE: The above steps prevent the operation from returning an altered format when _baseFormat_ would be sufficient. This should be unnecessary, but exists because the ECMA-402 specification does not guarantee that a format returned from DateTimeStyleFormat can also be returned from BasicFormatMatcher or BestFitFormatMatcher.
667
668
1. Let _formatOptions_ be a new Record.
668
-
1. For each field name _fieldName_ of _allowedOptions_, do
669
-
1.Set the field of _formatOptions_ whose name is _fieldName_to the value of the field of _baseFormat_ whose name is _fieldName_.
669
+
1. For each property name _prop_ of _allowedOptions_, do
670
+
1.If _baseFormat_ has a [[<_prop_>]] field, set _formatOptions_.[[<_prop_>]] to _baseFormat_.[[<_prop_>]].
670
671
1. If _matcher_ is *"basic"*, then
671
672
1. Let _bestFormat_ be BasicFormatMatcher(_formatOptions_, _formats_).
0 commit comments