diff --git a/polyfill/lib/calendar.mjs b/polyfill/lib/calendar.mjs index 3d72741f04..a494a7bf94 100644 --- a/polyfill/lib/calendar.mjs +++ b/polyfill/lib/calendar.mjs @@ -2160,3 +2160,10 @@ impl['indian'] = ObjectAssign({}, nonIsoGeneralImpl, { helper: helperIndian }); impl['buddhist'] = ObjectAssign({}, nonIsoGeneralImpl, { helper: helperBuddhist }); impl['japanese'] = ObjectAssign({}, nonIsoGeneralImpl, { helper: helperJapanese }); impl['gregory'] = ObjectAssign({}, nonIsoGeneralImpl, { helper: helperGregory }); + +function calendarFieldsImpl(calendar, fieldNames) { + return impl[calendar].fields(fieldNames); +} +// Probably not what the intrinsics mechanism was intended for, but view this as +// an export of calendarFieldsImpl while avoiding circular dependencies +DefineIntrinsic('calendarFieldsImpl', calendarFieldsImpl); diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index 9c17e94113..33d358615f 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -1803,9 +1803,8 @@ export function CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar export function CalendarFields(calendar, fieldNames) { if (typeof calendar === 'string') { - const TemporalCalendar = GetIntrinsic('%Temporal.Calendar%'); - calendar = new TemporalCalendar(calendar); - return Call(GetIntrinsic('%Temporal.Calendar.prototype.fields%'), calendar, [fieldNames]); + if (calendar === 'iso8601') return fieldNames; + return GetIntrinsic('%calendarFieldsImpl%')(calendar, fieldNames); } const fields = GetMethod(calendar, 'fields'); fieldNames = Call(fields, calendar, [fieldNames]); diff --git a/spec/calendar.html b/spec/calendar.html index 42bca64e90..75fdf17ada 100644 --- a/spec/calendar.html +++ b/spec/calendar.html @@ -99,9 +99,12 @@

1. If _calendar_ is a String, then - 1. Set _calendar_ to ! CreateTemporalCalendar(_calendar_). - 1. Let _fieldsArray_ be ? Call(%Temporal.Calendar.prototype.fields%, _calendar_, « CreateArrayFromList(_fieldNames_) »). - 1. Return ! CreateListFromArrayLike(_fieldsArray_, « String »). + 1. Assert: _fieldNames_ contains no String other than *"year"*, *"month"*, *"monthCode"*, or *"day"*. + 1. If _calendar_ is *"iso8601"*, return _fieldNames_. + 1. Let _extraFieldDescriptors_ be CalendarFieldDescriptors(_calendar_, _fieldNames_). + 1. For each Calendar Field Descriptor Record _desc_ of _extraFieldDescriptors_, do + 1. Append _desc_.[[Property]] to _fieldNames_. + 1. Return _fieldNames_. 1. Let _fieldsArray_ be ? Invoke(_calendar_, *"fields"*, « CreateArrayFromList(_fieldNames_) »). 1. Let _iteratorRecord_ be ? GetIterator(_fieldsArray_, ~sync~). 1. Return ? IteratorToListOfType(_iteratorRecord_, « String »).