Skip to content

Commit

Permalink
Editorial: Second argument to CalendarExtraFields is only a List
Browse files Browse the repository at this point in the history
The enum values are no longer passed anywhere in the spec text, so remove
them as a permissible type. Update the polyfill implementation to match,
which had a bug; it always assumed ~date~, which was incorrect.

Closes: #2999
  • Loading branch information
ptomato authored and Ms2ger committed Oct 8, 2024
1 parent 24613a8 commit c6adcab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions polyfill/lib/calendar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1860,9 +1860,11 @@ const helperDangi = { ...helperChinese, id: 'dangi' };
* ISO and non-ISO implementations vs. code that was very different.
*/
const nonIsoGeneralImpl = {
extraFields(type = 'date') {
if (type === 'month-day') return [];
return ['era', 'eraYear'];
extraFields(fields) {
if (this.helper.hasEra && Call(ArrayPrototypeIncludes, fields, ['year'])) {
return ['era', 'eraYear'];
}
return [];
},
resolveFields(fields /* , type */) {
if (this.helper.calendarType !== 'lunisolar') {
Expand Down
2 changes: 1 addition & 1 deletion polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ export function ISODateToFields(calendar, isoDate, type = 'date') {
}

export function PrepareCalendarFields(calendar, bag, calendarFieldNames, nonCalendarFieldNames, requiredFields) {
const extraFieldNames = calendarImplForID(calendar).extraFields();
const extraFieldNames = calendarImplForID(calendar).extraFields(calendarFieldNames);
const fields = Call(ArrayPrototypeConcat, calendarFieldNames, [nonCalendarFieldNames, extraFieldNames]);
const result = ObjectCreate(null);
let any = false;
Expand Down
4 changes: 2 additions & 2 deletions spec/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -862,12 +862,12 @@ <h1>
<h1>
CalendarExtraFields (
_calendar_: a calendar type,
_type_: ~date~, ~year-month~, ~month-day~, or a List of values from the Enumeration Key column of <emu-xref href="#table-temporal-calendar-fields-record-fields"></emu-xref>,
_fields_: a List of values from the Enumeration Key column of <emu-xref href="#table-temporal-calendar-fields-record-fields"></emu-xref>,
): a List of values from the Enumeration Key column of <emu-xref href="#table-temporal-calendar-fields-record-fields"></emu-xref>
</h1>
<dl class="header">
<dt>description</dt>
<dd>It characterizes calendar-specific fields that are relevant for values of the provided _type_ in the built-in calendar identified by _calendar_ (inferring the type when _type_ is a List by interpreting its elements as field names). For example, « ~era~, ~era-year~ » is returned when _calendar_ is *"gregory"* or *"japanese"* and _type_ is ~date~ or ~year-month~ or a List containing ~year~.</dd>
<dd>It characterizes calendar-specific fields that are relevant for the provided _fields_ in the built-in calendar identified by _calendar_. For example, « ~era~, ~era-year~ » is returned when _calendar_ is *"gregory"* or *"japanese"* and _fields_ is a List containing ~year~.</dd>
</dl>
<emu-alg>
1. If _calendar_ is *"iso8601"*, return an empty List.
Expand Down

0 comments on commit c6adcab

Please sign in to comment.