Repository navigation
Conversation
numberToSimpleDate corrected an overshooting year estimate by comparing the start of the previous year instead of the start of the estimated year, so with leapYear1900 enabled the 31st of December of 32 years between 1900 and 2200 (e.g. 2036 and 2040) came out as day 0 of January. Fixes handsontable#1793 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@aliassar Thank you very much for taking the time to prepare the pull request. There's one thing holding us back from using those changes in production — could you please sign the CLA: https://cla.handsontable.com/sign?pr=handsontable%2Fhyperformula%231873 |
|
@aliassar Thank you for signing the CLA! The status check has been updated and your pull request is now unblocked. 🎉 |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Note
Medium risk: One-condition change in the core date serial-to-date conversion used by all date functions, but it is narrow, mathematically sound (the 365.2425 estimate is off by at most ±1 year, so a single correction step suffices), and verified by round-trip testing across 1600–9999 with multiple nullDate values.
Full review: no issues found.
Want a deeper review? Comment /review improve on its own line: a full review of the latest commit with an extra fix-oriented pass (about 2x the cost).
Develop now validates license keys, so the leap-year test uses TEST_LICENSE_KEY like the other suites. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Note
Medium risk: A one-line change to core date serial-number decoding (numberToSimpleDate) that affects DAY/MONTH/YEAR/EOMONTH/YEARFRAC and other date functions, but it is a narrow correction verified by an exhaustive round-trip test across the full date range.
Full review: no issues found.
Want a deeper review? Comment /review improve on its own line: a full review of the latest commit with an extra fix-oriented pass (about 2x the cost).
…-1900-dec-31 # Conflicts: # CHANGELOG.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the changelog entry to the new Unreleased section after the 4.0.0 release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Context
With
leapYear1900: true, which is the setup the Excel compatibility guide recommends, 31 December of 32 years between 1900 and 2200 (for example 2036, 2040 and 2069) converts to day 0 of January of the next year. So=DAY(DATE(2036, 12, 31))returns0and=EOMONTH(DATE(2036, 12, 31), 0)returns 31 January 2037.numberToSimpleDateestimates the year asfloor(dateNumber / 365.2425). When that estimate was one year too high, the downward correction checked the start of the year before the estimate instead of the estimate itself, so it never fired. The fix is the one-token change suggested in the issue.How did you test your changes?
hyperformula/test/leap-year-1900.spec.ts. 5 of its 6 cases fail ondevelop, and all 6 pass with the fix.hyperformula/,npx jestpasses 2 suites and 10 tests.npx tsc --noEmitis clean, andnpx eslinton the changed files reports 0 errors.nullDatevalues and bothleapYear1900settings.develophad 640 mismatches, all on 31 December and all withleapYear1900: true. With the fix there are 0.Compatibility with Excel and Google Sheets
Not checked in Excel or Google Sheets. The fix only makes the date number convert back to the date it came from:
=DAY(DATE(2036, 12, 31))now returns31(was0) and=TEXT(EOMONTH(DATE(2036, 12, 31), 0), "yyyy-mm-dd")returns2036-12-31(was2037-01-31).Public API changes
None.
Out of scope and follow-ups
None.
Types of changes
Related issues
Checklist
dev-docs/pages this change affects – or none needed it.Note
Low Risk
Narrow one-line change in date serial decoding with dedicated tests; no public API changes.
Overview
Fixes 31 December in some years (e.g. 2036, 2040, 2069) mapping to day 0 of the following January when
leapYear1900: true, so=DAY(DATE(2036, 12, 31))and related functions (MONTH,EOMONTH, etc.) align with Excel-style serial dates again.In
DateTimeHelper.numberToSimpleDate, the downward year adjustment after the365.2425estimate now compares against January 1 of the estimated year instead of year − 1, so an overestimated year is decremented when it should be.Adds
hyperformula/test/leap-year-1900.spec.ts(six cases) and a CHANGELOG entry for #1793.Reviewed by Cursor Bugbot for commit bcf3769. Bugbot is set up for automated code reviews on this repo. Configure here.