Skip to content

Commit 6543c99

Browse files
committed
Polyfill: Add assertion to catch error in Chinese calendar month cache
See issue #3158. This doesn't fix the issue, but adds an assertion that fails early when we hit that case, instead of later on with a more confusing error message.
1 parent 4dc96ab commit 6543c99

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

polyfill/lib/calendar.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,7 @@ const helperChinese = ObjectAssign({}, nonIsoHelperBase, {
19591959
let oldDay;
19601960
for (;;) {
19611961
const { day, monthString, relatedYear } = updateCalendarFields();
1962+
if (monthIndex === 1) assert(monthString === '1', `we didn't back up to the beginning of year ${calendarYear}`);
19621963
const isLeapMonth = Call(StringPrototypeEndsWith, monthString, ['bis']);
19631964
const monthCode = CreateMonthCode(
19641965
isLeapMonth ? Call(StringPrototypeSlice, monthString, [0, -3]) : monthString,

0 commit comments

Comments
 (0)