Skip to content

fix: derive short years from the full calendar year - #14

Open
xiehuanyi wants to merge 1 commit into
lukeed:masterfrom
xiehuanyi:fix-historical-short-years-20261008
Open

xiehuanyi wants to merge 1 commit into
lukeed:masterfrom
xiehuanyi:fix-historical-short-years-20261008

Conversation

@xiehuanyi

Copy link
Copy Markdown

{YY} currently uses Date.getYear(), which returns the year minus 1900. For many earlier dates the negative value is sliced incorrectly: year 1801 formats as 99, and year 1899 formats as -1, instead of 01 and 99.

Use getFullYear() and let the existing two-character formatter select the year suffix. Modern dates and custom formatter overrides retain their behavior.

Validation:

  • Five historical-year assertions fail before the fix (24/29 assertions pass).
  • npm test passes all 29 assertions on local Node 22 and every CI runtime: Node 6, 12 and 18.
  • Regression covers early years, dates before 1900, the 1900 boundary and a modern date.
  • git diff --check passes.

AI assistance: Codex assisted with discovery, implementation and validation. Tests cover nonnegative calendar years; formatting of dates before the common era is unchanged.

Copilot AI balanced review requested due to automatic review settings October 8, 2026 11:25

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.

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.

2 participants