diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index 12ce550562..9c48b6eb23 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -1153,6 +1153,13 @@ export const ES = ObjectAssign({}, ES2020, { ToTemporalDate: (item, options = {}) => { if (ES.Type(item) === 'Object') { if (ES.IsTemporalDate(item)) return item; + if (ES.IsTemporalZonedDateTime(item)) { + item = ES.BuiltinTimeZoneGetPlainDateTimeFor( + GetSlot(item, TIME_ZONE), + GetSlot(item, INSTANT), + GetSlot(item, CALENDAR) + ); + } if (ES.IsTemporalDateTime(item)) { const TemporalPlainDate = GetIntrinsic('%Temporal.PlainDate%'); return new TemporalPlainDate( @@ -1197,6 +1204,13 @@ export const ES = ObjectAssign({}, ES2020, { let year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, calendar; if (ES.Type(item) === 'Object') { if (ES.IsTemporalDateTime(item)) return item; + if (ES.IsTemporalZonedDateTime(item)) { + return ES.BuiltinTimeZoneGetPlainDateTimeFor( + GetSlot(item, TIME_ZONE), + GetSlot(item, INSTANT), + GetSlot(item, CALENDAR) + ); + } if (ES.IsTemporalDate(item)) { const TemporalPlainDateTime = GetIntrinsic('%Temporal.PlainDateTime%'); return new TemporalPlainDateTime( @@ -1354,6 +1368,13 @@ export const ES = ObjectAssign({}, ES2020, { let hour, minute, second, millisecond, microsecond, nanosecond, calendar; if (ES.Type(item) === 'Object') { if (ES.IsTemporalTime(item)) return item; + if (ES.IsTemporalZonedDateTime(item)) { + item = ES.BuiltinTimeZoneGetPlainDateTimeFor( + GetSlot(item, TIME_ZONE), + GetSlot(item, INSTANT), + GetSlot(item, CALENDAR) + ); + } if (ES.IsTemporalDateTime(item)) { const TemporalPlainTime = GetIntrinsic('%Temporal.PlainTime%'); return new TemporalPlainTime( diff --git a/spec/plaindate.html b/spec/plaindate.html index ff1428ad4c..1a986c311d 100644 --- a/spec/plaindate.html +++ b/spec/plaindate.html @@ -676,6 +676,10 @@

ToTemporalDate ( _item_ [ , _options_ ] )

1. If Type(_item_) is Object, then 1. If _item_ has an [[InitializedTemporalDate]] internal slot, then 1. Return _item_. + 1. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then + 1. Let _instant_ be ! CreateTemporalInstant(_item_.[[Nanoseconds]]). + 1. Let _plainDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). + 1. Return ! CreateTemporalDate(_plainDateTime_.[[ISOYear]], _plainDateTime_.[[ISOMonth]], _plainDateTime_.[[ISODay]], _plainDateTime_.[[Calendar]]). 1. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then 1. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). 1. Let _calendar_ be ? GetOptionalTemporalCalendar(_item_). diff --git a/spec/plaindatetime.html b/spec/plaindatetime.html index d172d41f1b..4b91c02a8c 100644 --- a/spec/plaindatetime.html +++ b/spec/plaindatetime.html @@ -903,6 +903,9 @@

ToTemporalDateTime ( _item_ [ , _options_ ] )

1. If Type(_item_) is Object, then 1. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then 1. Return _item_. + 1. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then + 1. Let _instant_ be ! CreateTemporalInstant(_item_.[[Nanoseconds]]). + 1. Return ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). 1. If _item_ has an [[InitializedTemporalDate]] internal slot, then 1. Return ? CreateTemporalDateTime(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], 0, 0, 0, 0, 0, 0, _item_.[[Calendar]]). 1. Let _calendar_ be ? GetOptionalTemporalCalendar(_item_). diff --git a/spec/plaintime.html b/spec/plaintime.html index ef97e208cf..f43f1bdd10 100644 --- a/spec/plaintime.html +++ b/spec/plaintime.html @@ -610,6 +610,10 @@

ToTemporalTime ( _item_ [ , _overflow_ ] )

1. If Type(_item_) is Object, then 1. If _item_ has an [[InitializedTemporalTime]] internal slot, then 1. Return _item_. + 1. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then + 1. Let _instant_ be ? CreateTemporalInstant(_item_.[[Nanoseconds]]). + 1. Set _plainDateTime_ to ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). + 1. Return ! CreateTemporalTime(_plainDateTime_.[[ISOHour]], _plainDateTime_.[[ISOMinute]], _plainDateTime_.[[ISOSecond]], _plainDateTime_.[[ISOMillisecond]], _plainDateTime_.[[ISOMicrosecond]], _plainDateTime_.[[ISONanosecond]]). 1. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then 1. Return ! CreateTemporalTime(_item_.[[ISOHour]], _item_.[[ISOMinute]], _item_.[[ISOSecond]], _item_.[[ISOMillisecond]], _item_.[[ISOMicrosecond]], _item_.[[ISONanosecond]]). 1. Let _calendar_ be ? GetOptionalTemporalCalendar(_item_).