diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index d1865acd9e..93eb82dc8f 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -1956,11 +1956,15 @@ export const ES = ObjectAssign({}, ES2022, { return result; }, + ObjectImplementsTemporalTimeZoneProtocol: (object) => { + if (ES.IsTemporalTimeZone(object)) return true; + return 'getOffsetNanosecondsFor' in object && 'getPossibleInstantsFor' in object && 'id' in object; + }, ToTemporalTimeZoneSlotValue: (temporalTimeZoneLike) => { if (ES.Type(temporalTimeZoneLike) === 'Object') { if (ES.IsTemporalZonedDateTime(temporalTimeZoneLike)) return GetSlot(temporalTimeZoneLike, TIME_ZONE); - if (ES.IsTemporalCalendar(temporalTimeZoneLike)) { - throw new RangeError('Expected a time zone object but received a Temporal.Calendar'); + if (!ES.ObjectImplementsTemporalTimeZoneProtocol(temporalTimeZoneLike)) { + throw new TypeError('expected a Temporal.TimeZone or object implementing the Temporal.TimeZone protocol'); } return temporalTimeZoneLike; } diff --git a/spec/timezone.html b/spec/timezone.html index ea4667f929..3b44f7d35f 100644 --- a/spec/timezone.html +++ b/spec/timezone.html @@ -546,6 +546,28 @@