Skip to content

Commit

Permalink
Polyfill: Fix parsing of calendar identifier from time-only string
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ptomato committed Feb 25, 2025
1 parent 8f491b4 commit c1c7e07
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions polyfill/lib/ecmascript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1742,9 +1742,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';
Expand Down

0 comments on commit c1c7e07

Please sign in to comment.