Closed Bug 2005482 Opened 11 months ago Closed 11 months ago

Constrain day before calling CreateDateFromCodes with overflow=reject for Hebrew calendar

Categories

(Core :: JavaScript: Standard Library, defect, P1)

defect

Tracking

()

RESOLVED FIXED
148 Branch
Tracking Status
firefox148 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file)

New test262 tests added in bug 2005286 revealed a bug in CreateDateFrom for the Hebrew calendar:

  • When given an ordinal month, we first call CreateDateFromCodes with the ordinal month replaced by a month code. If the resolved date has the same ordinal month as the input month, we return that date. Otherwise we try to adjust for leap years.
  • CreateDateFromCodes has an early check for invalid day values. This can result in rejecting valid inputs:
    • For example when month = 10 and day = 30 and the input year is a leap year. This should resolve to monthCode = M09 and day = 30. We first try month code "M10", but since "M10" can have at most 29 days, the early day values check in CreateDateFromCodes throws a RangeError.

To fix this bug, we need to constrain the days value before calling CreateDateFromCodes and later check if input day fits into the resolved month.

Constrain the input day before calling CreateDateFromCodes when
overflow=reject to avoid incorrectly rejecting dates. When the day was
constrained, handle overflow=reject through an explicit check using
CalendarDaysInMonth.

This case is specific to the Hebrew calendar and can't happen for Chinese/Dangi
calendars, because all Chinese/Dangi months have the same number of minimum resp.
maximum days per month.

Severity: -- → S3
Priority: -- → P1
Pushed by andre.bargull@gmail.com: https://github.com/mozilla-firefox/firefox/commit/37099145c6fb https://hg.mozilla.org/integration/autoland/rev/669b3bf32072 Constrain day before calling CreateDateFromCodes with overflow=reject for Hebrew calendar. r=spidermonkey-reviewers,dminor
Status: ASSIGNED → RESOLVED
Closed: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch
QA Whiteboard: [qa-triage-done-c149/b148]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: