fix(xlsx): honor the 1904 date system on read#3
Merged
Conversation
readXlsx and readXlsxRows now parse <workbookPr date1904="1"/> and convert date serials from the 1904 epoch — previously the flag was ignored and dates in legacy Mac workbooks read back ~4 years off (the conversion utility existed in utils/date.ts but was unwired). Writes still emit the 1900 system: the model stores real Dates, so a 1904 round-trip preserves instants while normalizing the file. Verified against the 1904.xlsx fixture with exceljs as oracle (B4 = serial 0 = 1904-01-01). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JrxsnGbCRtq7VPskBRoSPr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
readXlsxandreadXlsxRowsnow parse<workbookPr date1904="1"/>and convert date serials from the 1904 epoch. Previously the flag was ignored — the conversion support existed insrc/utils/date.ts(oracle-validated in SP-1) but was never wired into the xlsx codecs, so dates in legacy Mac workbooks read back ~4 years off. This was documented as a known gap in the migration guide and README roadmap; this PR closes it.Write behavior is unchanged by design: the model stores real
Dateobjects, so writes keep emitting the standard 1900 system. Round-tripping a 1904 workbook preserves every instant while normalizing the file to 1900.Changes
workbook-reader: parseworkbookPr→ newdate1904field onWorkbookPartsworksheet-reader/read: thread the flag intoserialToDateviaReadContextstream-reader: same threading throughparseRowTest plan
TDD: both tests were written first and failed on the 1900 epoch (read
1900-01-01), then passed after the fix:read-conformance:1904.xlsxfixture B4 (serial 0) must read as1904-01-01— expected value confirmed against the exceljs oraclestream-reader: same assertion throughreadXlsxRowsFull suite: 255 tests green, typecheck/lint/format clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_01JrxsnGbCRtq7VPskBRoSPr