You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Normative: Throw on conversion from TimeZone to Calendar and vice versa
In order to prevent bugs like `new Temporal.ZonedDateTime(0n, cal, tz)`
(where the calendar and time zone arguments are switched, silently
poisoning the object) ToTemporalCalendar should throw if it encounters a
Temporal.TimeZone instance, and ToTemporalTimeZone should throw if it
encounters a Temporal.Calendar instance.
Includes implementation in the reference code.
Co-authored-by: Aditi <aditisingh1400@gmail.com>
Closes: #2354
1. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalTime]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then
369
369
1. Return _temporalCalendarLike_.[[Calendar]].
370
+
1. If _temporalCalendarLike_ has an [[InitializedTemporalTimeZone]] internal slot, throw a *RangeError* exception.
370
371
1. If ? HasProperty(_temporalCalendarLike_, *"calendar"*) is *false*, return _temporalCalendarLike_.
371
372
1. Set _temporalCalendarLike_ to ? Get(_temporalCalendarLike_, *"calendar"*).
372
-
1. If Type(_temporalCalendarLike_) is Object and ? HasProperty(_temporalCalendarLike_, *"calendar"*) is *false*, return _temporalCalendarLike_.
373
+
1. If Type(_temporalCalendarLike_) is Object, then
374
+
1. If _temporalCalendarLike_ has an [[InitializedTemporalTimeZone]] internal slot, throw a *RangeError* exception.
375
+
1. If ? HasProperty(_temporalCalendarLike_, *"calendar"*) is *false*, return _temporalCalendarLike_.
373
376
1. Let _identifier_ be ? ToString(_temporalCalendarLike_).
374
377
1. Set _identifier_ to ? ParseTemporalCalendarString(_identifier_).
375
378
1. If IsBuiltinCalendar(_identifier_) is *false*, throw a *RangeError* exception.
0 commit comments