Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeError from PlainYearMonth::toLocaleString #52

Open
kgram opened this issue Dec 16, 2024 · 0 comments
Open

RangeError from PlainYearMonth::toLocaleString #52

kgram opened this issue Dec 16, 2024 · 0 comments

Comments

@kgram
Copy link

kgram commented Dec 16, 2024

I cannot find any good explanation other than an error for this behaviour. It seems trying to get a localized string for a PlainMonthYear throws RangeError: Mismatching Calendars.

Temporal.PlainYearMonth.from('2024-11').toLocaleString('en')

The bundled code is minified and likely extremely optimized, so it is hard to say exactly what happens. The problem happens in toEpochMillis, where resolvedOptions is

{
  calendar: "gregory",
  locale: "en",
  month: "numeric",
  numberingSystem: "latn",
  timeZone: "UTC",
  year: "numeric"
}

and the slotsList is

[{
  branding: "PlainYearMonth",
  calendar: "iso8601",
  isoDay: 1,
  isoMonth: 11,
  isoYear: 2024,
}]

If I convert to a PlainDate first and only format the month/year (Temporal.PlainYearMonth.from('2024-11').toPlainDate({ day: 1 }).toLocaleString('en', { month: 'long', year: 'numeric' })), it works just fine. It appears that PlainYearMonth has strictCalendarChecks enabled in its ClassFormatConfig, so I'm guessing part of this is intentional, but it does not seem like there should be an error here.

I don't know if this is somehow related to my environment, but I don't understand what I could have done to affect any of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant