Implement non-ISO calendar support for Temporal (Chinese, Dangi, Hebrew, Persian) by lahma · Pull Request #2342 · sebastienros/jint (original) (raw)
and others added 6 commits
Add calendar arithmetic for Chinese, Dangi, Hebrew, and Persian calendars using .NET's built-in System.Globalization.Calendar classes.
New NonIsoCalendars adapter handles ISO↔calendar date conversion, calendar-aware field accessors (month, monthCode, day, daysInMonth, monthsInYear, inLeapYear), date arithmetic preserving monthCode semantics across leap months, and calendar date difference calculation.
Key changes:
- NonIsoCalendars.cs: Central adapter wrapping ChineseLunisolarCalendar, KoreanLunisolarCalendar, HebrewCalendar, PersianCalendar
- TemporalHelpers.cs: Calendar-aware field accessors, era support for Hebrew/Persian, Japanese era cutoff fix (1873 not 1868)
- All prototype files: Calendar-aware getters and with() methods
- All constructor files: monthCode passthrough for non-ISO calendars
- CalendarDateAdd/CalendarDateUntil dispatch to non-ISO adapter
- Graceful fallback to ISO-like fields for out-of-range dates
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
… validation
- Remove exclusion for numbering-systems.js (all digit mappings now work)
- Fix display month validation: reject monthCode with display month > 12 even with overflow "constrain" (M13L is never valid)
- Fix HebrewCalendar out-of-range year handling in GetLeapMonthOrdinal and GetMonthsInYear with try/catch guards
- Fix Japanese Meiji era cutoff from 1868 to 1873 (when Japan adopted the Gregorian calendar per Temporal spec)
- Fix PlainDateTime/ZonedDateTime/PlainYearMonth/PlainMonthDay constructors to pass monthCode through to CalendarDateToISO for non-ISO calendars
- Fix PlainDateTime with() monthCode parsing to use ParseMonthCode (supports "L" suffix) instead of int.TryParse
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
Hebrew calendar uses a 19-year Metonic cycle where years 3, 6, 8, 11, 14, 17, 19 are leap years. This allows correct leap year detection for Hebrew years outside .NET HebrewCalendar's range (5343-5999).
Fixes GetLeapMonthOrdinal and GetMonthsInYear to use algorithmic detection as fallback, enabling CalendarDateAdd to correctly reject adding years to leap months when the target year isn't a leap year.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
…ions
- PlainMonthDay.prototype.with() now uses calendar-aware field defaults and CalendarDateToISO for non-ISO calendars
- Remove exclusions for PlainYearMonth.with(non-iso-calendar-fields), PlainMonthDay.with(non-iso-calendar-fields), PlainMonthDay.from(fields-object)
- Fix HebrewDateToIso to use algorithmic leap year for out-of-range years
93,300 test262 tests pass, 0 failures.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
For non-ISO calendars, ordinal month number does not equal the display month in monthCode (e.g., month 5 = M04L in Chinese calendar with leap month). The ISO-specific validation that checks month == monthFromCode must be skipped for non-ISO calendars where CalendarDateToISO handles the resolution.
Applied to all 5 constructors: PlainDate, PlainDateTime, PlainMonthDay, PlainYearMonth, ZonedDateTime.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
Update CreatePlainDateFromFields and CreateZonedDateTimeFromFields in TemporalHelpers to use CalendarDateToISO for non-ISO calendars and skip ordinal/display month consistency checks.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
This was referenced
Mar 23, 2026
This was referenced
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})