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

CalendarMonthDayToISOReferenceDate: Throw RangeError if resolved date is outside of valid limits #2997

Closed
anba opened this issue Oct 7, 2024 · 2 comments · Fixed by #3004
Assignees
Labels
editorial spec-text Specification text involved

Comments

@anba
Copy link
Contributor

anba commented Oct 7, 2024

CalendarMonthDayToISOReferenceDate should have the same note as in CalendarDateToISO to disallow dates outside the valid limits:

It also throws a RangeError exception if the date described by fields is outside the range allowed by ISODateWithinLimits.

Reason: The resolved year can be far into the past and may be outside the valid limits.

The maximum year for ICU4X is -5738:

js> Temporal.PlainMonthDay.from({day: 30, monthCode: "M09L", calendar: "chinese"}, {overflow: "reject"}).toString();
"-005738-11-17[u-ca=chinese]"

ICU4C computes dates possibly even further into the past. -239723 is computed as the first year where M09L-30 exists:

js> new Intl.DateTimeFormat("en-u-ca-chinese", {timeZone:"UTC"}).format(new Date("-239723-01-05")) 
"9bis/30/-239723"

ICU4C doesn't compute any 30 days months for M01L, M10L, M11L, and M12L inside the Date limits. But it's possible that ICU4C can compute 30 days leap months outside those limits.

@ptomato
Copy link
Collaborator

ptomato commented Oct 8, 2024

Given #2869 I am skeptical about the accuracy of these dates, but this is a good point. It's possible that we trip an assertion here, so we should add this. Note that as of #2996, this is no longer a note in CalendarDateToISO, but an actual step in CalendarDateFromFields/CalendarYearMonthFromFields. So I'll add a similar step in CalendarMonthDayFromFields.

@ptomato ptomato self-assigned this Oct 8, 2024
@ptomato ptomato added spec-text Specification text involved editorial labels Oct 8, 2024
@ptomato
Copy link
Collaborator

ptomato commented Oct 8, 2024

(I'm hesitant to add a test262 test for this, though, since it may be based on spurious data.)

ptomato added a commit that referenced this issue Oct 8, 2024
This was previously not thought necessary, but some month-day combinations
are rare enough in the Chinese lunar calendar that they might occur only
outside of the representable range.

Failing this check would hit an assertion elsewhere anyway, so this is
editorial.

Closes: #2997
ptomato added a commit that referenced this issue Oct 8, 2024
This was previously not thought necessary, but some month-day combinations
are rare enough in the Chinese lunar calendar that they might occur only
outside of the representable range.

Failing this check would hit an assertion elsewhere anyway, so this is
editorial.

Closes: #2997
Ms2ger pushed a commit that referenced this issue Oct 8, 2024
This was previously not thought necessary, but some month-day combinations
are rare enough in the Chinese lunar calendar that they might occur only
outside of the representable range.

Failing this check would hit an assertion elsewhere anyway, so this is
editorial.

Closes: #2997
Ms2ger pushed a commit that referenced this issue Oct 8, 2024
This was previously not thought necessary, but some month-day combinations
are rare enough in the Chinese lunar calendar that they might occur only
outside of the representable range.

Failing this check would hit an assertion elsewhere anyway, so this is
editorial.

Closes: #2997
@Ms2ger Ms2ger closed this as completed in e51b82e Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial spec-text Specification text involved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants