Skip to content

Commit 64a2395

Browse files
ptomatoanba
andcommitted
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 parent 978311d commit 64a2395

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

‎spec/intl.html‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -464,18 +464,18 @@ <h1>
464464
1. Let _styles_ be _resolvedLocaleData_.[[styles]].[[&lt;_resolvedCalendar_>]].
465465
1. Let _bestFormat_ be DateTimeStyleFormat(_dateStyle_, _timeStyle_, _styles_).
466466
1. <ins>If _dateStyle_ is not *undefined*, then</ins>
467-
1. <ins>Set _dateTimeFormat_.[[TemporalPlainDateFormat]] to AdjustDateTimeStyleFormat(_formats_, _bestFormat_, _formatMatcher_, « [[weekday]], [[era]], [[year]], [[month]], [[day]] »).</ins>
468-
1. <ins>Set _dateTimeFormat_.[[TemporalPlainYearMonthFormat]] to AdjustDateTimeStyleFormat(_formats_, _bestFormat_, _formatMatcher_, « [[era]], [[year]], [[month]] »).</ins>
469-
1. <ins>Set _dateTimeFormat_.[[TemporalPlainMonthDayFormat]] to AdjustDateTimeStyleFormat(_formats_, _bestFormat_, _formatMatcher_, « [[month]], [[day]] »).</ins>
467+
1. <ins>Set _dateTimeFormat_.[[TemporalPlainDateFormat]] to AdjustDateTimeStyleFormat(_formats_, _bestFormat_, _formatMatcher_, « *"weekday"*, *"era"*, *"year"*, *"month"*, *"day"* »).</ins>
468+
1. <ins>Set _dateTimeFormat_.[[TemporalPlainYearMonthFormat]] to AdjustDateTimeStyleFormat(_formats_, _bestFormat_, _formatMatcher_, « *"era"*, *"year"*, *"month"* »).</ins>
469+
1. <ins>Set _dateTimeFormat_.[[TemporalPlainMonthDayFormat]] to AdjustDateTimeStyleFormat(_formats_, _bestFormat_, _formatMatcher_, « *"month"*, *"day"* »).</ins>
470470
1. <ins>Else,</ins>
471471
1. <ins>Set _dateTimeFormat_.[[TemporalPlainDateFormat]] to *null*.</ins>
472472
1. <ins>Set _dateTimeFormat_.[[TemporalPlainYearMonthFormat]] to *null*.</ins>
473473
1. <ins>Set _dateTimeFormat_.[[TemporalPlainMonthDayFormat]] to *null*.</ins>
474474
1. <ins>If _timeStyle_ is not *undefined*, then</ins>
475-
1. <ins>Set _dateTimeFormat_.[[TemporalPlainTimeFormat]] to AdjustDateTimeStyleFormat(_formats_, _bestFormat_, _formatMatcher_, « [[dayPeriod]], [[hour]], [[minute]], [[second]], [[fractionalSecondDigits]] »).</ins>
475+
1. <ins>Set _dateTimeFormat_.[[TemporalPlainTimeFormat]] to AdjustDateTimeStyleFormat(_formats_, _bestFormat_, _formatMatcher_, « *"dayPeriod"*, *"hour"*, *"minute"*, *"second"*, *"fractionalSecondDigits"* »).</ins>
476476
1. <ins>Else,</ins>
477477
1. <ins>Set _dateTimeFormat_.[[TemporalPlainTimeFormat]] to *null*.</ins>
478-
1. <ins>Set _dateTimeFormat_.[[TemporalPlainDateTimeFormat]] to AdjustDateTimeStyleFormat(_formats_, _bestFormat_, _formatMatcher_, « [[weekday]], [[era]], [[year]], [[month]], [[day]], [[dayPeriod]], [[hour]], [[minute]], [[second]], [[fractionalSecondDigits]] »).</ins>
478+
1. <ins>Set _dateTimeFormat_.[[TemporalPlainDateTimeFormat]] to AdjustDateTimeStyleFormat(_formats_, _bestFormat_, _formatMatcher_, « *"weekday"*, *"era"*, *"year"*, *"month"*, *"day"*, *"dayPeriod"*, *"hour"*, *"minute"*, *"second"*, *"fractionalSecondDigits"* »).</ins>
479479
1. <ins>Set _dateTimeFormat_.[[TemporalInstantFormat]] to _bestFormat_.</ins>
480480
1. Else,
481481
1. <del>Let _needDefaults_ be *true*.</del>
@@ -647,7 +647,7 @@ <h1>
647647
_formats_: a List of DateTime Format Records,
648648
_baseFormat_: a DateTime Format Record,
649649
_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-xref href="#table-datetimeformat-components"></emu-xref>,
651651
): a DateTime Format Record
652652
</h1>
653653
<dl class="header">
@@ -660,13 +660,14 @@ <h1>
660660
</dl>
661661
<emu-alg>
662662
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-xref href="#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 [[&lt;_prop_>]] field and _allowedOptions_ does not contain _prop_, set _anyConflictingFields_ to true.
665666
1. If _anyConflictingFields_ is *false*, return _baseFormat_.
666667
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.
667668
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 [[&lt;_prop_>]] field, set _formatOptions_.[[&lt;_prop_>]] to _baseFormat_.[[&lt;_prop_>]].
670671
1. If _matcher_ is *"basic"*, then
671672
1. Let _bestFormat_ be BasicFormatMatcher(_formatOptions_, _formats_).
672673
1. Else,

0 commit comments

Comments
 (0)