Skip to content

Commit 0df570c

Browse files
committed
Polyfill: Correctly calculate negative leap years in Hebrew calendar
We need to do the non-negative modulo here, otherwise all negative years are leap years.
1 parent 49e2d1d commit 0df570c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

polyfill/lib/calendar.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,9 @@ const helperHebrew = makeNonISOHelper([{ code: 'am', isoEpoch: { year: -3760, mo
12431243
// Given that these can be calculated by counting the number of days in
12441244
// those months, I assume that these DO NOT need to be exposed as
12451245
// Hebrew-only prototype fields or methods.
1246-
return (7 * year + 1) % 19 < 7;
1246+
let cycleYear = (7 * year + 1) % 19;
1247+
if (cycleYear < 0) cycleYear += 19;
1248+
return cycleYear < 7;
12471249
},
12481250
monthsInYear(calendarDate) {
12491251
return this.inLeapYear(calendarDate) ? 13 : 12;

0 commit comments

Comments
 (0)