Skip to content

Commit

Permalink
Draft: tighten language in non-ISO-calendar mergeFields()
Browse files Browse the repository at this point in the history
Note, DefaultMergeCalendarFields still exists in this branch but one use
of it would be removed in #2310, and #1418 would consolidate this
definition of Temporal.Calendar.prototype.mergeFields() with the earlier
one in the 262 part of the proposal. So ultimately, this would be the only
definition of mergeFields.

To do, if we decide this is the right approach:
- Check that all the places that might produce abrupt completions are
  correct
- Change the reference code to follow this spec
  • Loading branch information
ptomato committed Jan 13, 2023
1 parent 67a0eb7 commit 6b4cf0e
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions spec/intl.html
Original file line number Diff line number Diff line change
Expand Up @@ -1660,23 +1660,6 @@ <h1>
<dd>It takes a list of standard fields in _fields_ that are necessary for a given operation and returns a new list by adding relevant calendar-specific fields for the calendar represented by _calendar_. This is relevant for calendars which accept fields other than the standard set of built-in calendar fields.</dd>
</dl>
</emu-clause>

<emu-clause id="sec-temporal-calendardatemergefields" type="abstract operation">
<h1>
CalendarDateMergeFields (
_calendar_: a String,
_fields_: an Object,
_additionalFields_: an Object,
): an Object
</h1>
<dl class="header">
<dt>description</dt>
<dd>It takes two Objects of calendar-specific fields for the calendar represented by _calendar_ in _fields_ and _additionalFields_ and returns a new Object that includes both sets of fields. The values in _additionalFields_ should supersede the values in _fields_. Also, the returned Object must be free of ambiguity or conflicts. This is relevant for calendars which accept fields other than the standard set of built-in calendar fields.</dd>
</dl>
<emu-note>
For example, if _fields_ contains *"year"* but _additionalFields_ contains *"era"* and *"eraYear"*, then the returned list must not include *"year"* in order to avoid ambiguity or conflict between different ways of specifying the year.
</emu-note>
</emu-clause>
</emu-clause>

<emu-clause id="sup-properties-of-the-temporal-calendar-prototype-object">
Expand Down Expand Up @@ -2123,14 +2106,26 @@ <h1>Temporal.Calendar.prototype.mergeFields ( _fields_, _additionalFields_ )</h1
1. Let _calendar_ be the *this* value.
1. Perform ? RequireInternalSlot(_calendar_, [[InitializedTemporalCalendar]]).
1. Set _fields_ to ? ToObject(_fields_).
1. Let _merged_ be OrdinaryObjectCreate(%Object.prototype%).
1. Perform ? CopyDataProperties(_merged_, _fields_, « », « *undefined* »).
1. Set _additionalFields_ to ? ToObject(_additionalFields_).
1. If _calendar_.[[Identifier]] is *"iso8601"*, then
1. Return ? DefaultMergeCalendarFields(_fields_, _additionalFields_).
1. Let _fieldsCopy_ be OrdinaryObjectCreate(%Object.prototype%).
1. Perform ? CopyDataProperties(_fieldsCopy_, _fields_, « », « *undefined* »).
1. Let _additionalFieldsCopy_ be OrdinaryObjectCreate(%Object.prototype%).
1. Let _additionalFieldsCopy_ be OrdinaryObjectCreate(*null*).
1. Perform ? CopyDataProperties(_additionalFieldsCopy_, _additionalFields_, « », « *undefined* »).
1. Return CalendarDateMergeFields(_calendar_.[[Identifier]], _fieldsCopy_, _additionalFieldsCopy_).
1. NOTE: Every property of _additionalFieldsCopy_ is a data property with non-*undefined* value, but some property keys may be Symbols.
1. Let _additionalKeys_ be ! _additionalFieldsCopy_.[[OwnPropertyKeys]]().
1. For each element _key_ of _additionalKeys_, do
1. If _calendar_.[[Identifier]] is *"iso8601"*, then
1. If _key_ is *"month"*, let _excludedKeys_ be « *"monthCode"* ».
1. Else if _key_ is *"monthCode"*, let _excludedKeys_ be « *"month"* ».
1. Else let _excludedKeys_ be « ».
1. Else,
1. Let _excludedKeys_ be the List of property keys that are mutually excluded by _key_.
1. NOTE: For example, in calendars that use eras, if _key_ is *"year"*, let _excludedKeys_ be « *"era"*, *"eraYear"* ». _excludedKeys_ may be empty.
1. NOTE: In calendars where eras do not start and end at year boundaries, note that _excludedKeys_ should contain *"era"* and *"eraYear"* if _key_ is *"day"*, *"month"*, or *"monthCode"*.
1. For each element _excludedKey_ of _excludedKeys_, do
1. Perform ! DeletePropertyOrThrow(_merged_, _excludedKey_).
1. Perform ? CopyDataProperties(_merged_, _additionalFieldsCopy_, « »).
1. Return _merged_.
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down

0 comments on commit 6b4cf0e

Please sign in to comment.