Skip to content

Pad the final two year digits in the yy token - #189

Merged
chase-manning merged 2 commits into
felixge:masterfrom
xiehuanyi:fix/short-calendar-years
Oct 11, 2026
Merged

chase-manning merged 2 commits into
felixge:masterfrom
xiehuanyi:fix/short-calendar-years

Conversation

@xiehuanyi

@xiehuanyi xiehuanyi commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

The yy token slices away the first two characters of the calendar year. Years below 100 produce an empty string, 123 becomes 3, 987 becomes 7, and expanded year 10000 produces 000. This does not match the documented two-digit year token.

Pad the year magnitude before taking its final two digits. This also ensures negative single-digit years produce two digits, for example -7 becomes 07. Add local and UTC regressions for short, expanded, and negative calendar years, keeping existing modern-year cases.

Validation: the original regression fails on unchanged master; the negative-year regression also fails before the magnitude fix. npm test passes all 151 tests, including the Babel/minification build. git diff --check passes. Browser execution and the Node 12.20 minimum were not exercised. This branch is based on clean master and does not include PR #188.

AI disclosure: OpenAI Codex assisted with investigation, implementation, regression tests, and this description.

AI-assisted implementation and verification using OpenAI Codex.
Copilot AI balanced review requested due to automatic review settings October 10, 2026 17:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Negative single-digit years still include the sign instead of producing two digits.

1 open finding

🧠 Review effort: Balanced

Comment thread src/dateformat.js Resolved
@chase-manning
chase-manning merged commit 0ed05b1 into felixge:master Oct 11, 2026
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.

3 participants