Skip to content

Polyfill: Fix Chinese/Dangi calendar crash when Feb 17 doesn't land in month 1#3278

Merged
ptomato merged 2 commits intotc39:mainfrom
jessealama:fix-chinese-calendar-1bis-crash
Feb 19, 2026
Merged

Polyfill: Fix Chinese/Dangi calendar crash when Feb 17 doesn't land in month 1#3278
ptomato merged 2 commits intotc39:mainfrom
jessealama:fix-chinese-calendar-1bis-crash

Conversation

@jessealama
Copy link
Collaborator

@jessealama jessealama commented Feb 19, 2026

Fixes #3158.

When Feb 17 of the ISO year falls in Chinese month 1bis (a leap month after month 1) or month 2, getMonthList() crashes because it assumes Feb 17 is either in month 1 or in the previous year's final month.

The fix checks for 2 first (backing up into month 1 or theoretically 1bis), then for 1bis (backing up to the previous year's last month), letting the existing !== '1' logic advance forward into month 1 as expected.

Known affected years: 7253 (1bis), 7625 (2). Thanks to @fabon-f for digging into this!

@jessealama jessealama requested a review from ptomato February 19, 2026 14:23
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 17.64706% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.96%. Comparing base (86a7b46) to head (aa7bb6d).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
polyfill/lib/calendar.mjs 17.64% 13 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3278      +/-   ##
==========================================
- Coverage   98.09%   97.96%   -0.14%     
==========================================
  Files          22       22              
  Lines       10457    10472      +15     
  Branches     1808     1810       +2     
==========================================
+ Hits        10258    10259       +1     
- Misses        182      195      +13     
- Partials       17       18       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jessealama jessealama force-pushed the fix-chinese-calendar-1bis-crash branch from 7149c47 to 12b967f Compare February 19, 2026 15:25
@jessealama jessealama changed the title Polyfill: Fix Chinese/Dangi calendar crash when Feb 17 lands in leap month 1bis Polyfill: Fix Chinese/Dangi calendar crash when Feb 17 doesn't land in month 1 Feb 19, 2026
@jessealama jessealama force-pushed the fix-chinese-calendar-1bis-crash branch from 5d94084 to aa7bb6d Compare February 19, 2026 16:53
Copy link
Collaborator

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for digging into this.

@ptomato ptomato merged commit 8827087 into tc39:main Feb 19, 2026
10 checks passed
@jessealama jessealama deleted the fix-chinese-calendar-1bis-crash branch February 20, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reference code has some weird case in the Chinese calendar in year 7253

3 participants