From 53b33c03679f425e4e8504444d0f18f2d79aad5e Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Fri, 14 Feb 2025 16:19:50 -0800 Subject: [PATCH] Polyfill: Fix parsing of calendar identifier from time-only string https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalcalendarstring ParseTemporalCalendarString specifies to try to parse the string as TemporalDateTimeString[+Zoned], TemporalDateTimeString[~Zoned], TemporalInstantString, TemporalTimeString, TemporalMonthDayString, and TemporalYearMonthString consecutively until one succeeds. I always thought TemporalTimeString would be handled by ParseISODateTime in the polyfill, but it seems I was wrong about that. See: #3090 --- polyfill/lib/ecmascript.mjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/polyfill/lib/ecmascript.mjs b/polyfill/lib/ecmascript.mjs index 3ac0ac8f6..3d7840cb7 100644 --- a/polyfill/lib/ecmascript.mjs +++ b/polyfill/lib/ecmascript.mjs @@ -1741,9 +1741,13 @@ export function ToTemporalCalendarIdentifier(calendarLike) { ({ calendar } = ParseISODateTime(identifier)); } catch { try { - ({ calendar } = ParseTemporalYearMonthString(identifier)); + ({ calendar } = ParseTemporalTimeString(identifier)); } catch { - ({ calendar } = ParseTemporalMonthDayString(identifier)); + try { + ({ calendar } = ParseTemporalYearMonthString(identifier)); + } catch { + ({ calendar } = ParseTemporalMonthDayString(identifier)); + } } } if (!calendar) calendar = 'iso8601';