Skip to content

Polyfill: Exception incorrectly thrown with maximum allowed PlainYearMonth in some non-ISO calendars #3251

@catamorphism

Description

@catamorphism
> Temporal.PlainYearMonth.from ( { calendar: "coptic", year: 275471, era: "am", eraYear: 275471, month: 6, monthCode: "M06"})
Uncaught RangeError: Invalid ISO date: +275760-09-21T00:00Z
    at Object.getCalendarParts (file:///home/tjc/proposal-temporal/polyfill/lib/calendar.mjs:607:46)
    at Object.isoToCalendarDate (file:///home/tjc/proposal-temporal/polyfill/lib/calendar.mjs:618:24)
    at Object.calendarToIsoDate (file:///home/tjc/proposal-temporal/polyfill/lib/calendar.mjs:930:32)
    at Object.dateToISO (file:///home/tjc/proposal-temporal/polyfill/lib/calendar.mjs:2158:32)
    at CalendarYearMonthFromFields (file:///home/tjc/proposal-temporal/polyfill/lib/ecmascript.mjs:1776:31)
    at Module.ToTemporalYearMonth (file:///home/tjc/proposal-temporal/polyfill/lib/ecmascript.mjs:1375:21)
    at PlainYearMonth.from (file:///home/tjc/proposal-temporal/polyfill/lib/plainyearmonth.mjs:142:15)

The ISO date +275760-09-21 should not be rejected here, because the year/month +275760-09 is within range. This happens because getCalendarParts calls IntlDateTimeFormatPrototypeFormatToParts, which throws on an out-of-range ISO date.

I haven't checked if the bug affects other calendars. The other affected calendars are ethioaa, ethiopic, hebrew, indian, islamic-civil, islamic-tbla, and islamic-umalqura.

Metadata

Metadata

Assignees

No one assigned

    Labels

    non-prod-polyfillTHIS POLYFILL IS NOT FOR PRODUCTION USE!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions