feat(excel): expose has_1904_epoch in workbook metadata#3905
Merged
Conversation
Surfaces calamine 0.35's new has_1904_epoch() (tafia/calamine#630) in the --metadata JSON output for XLS/XLSX/XLSB workbooks so consumers can tell whether dates are anchored to the 1900 or 1904 epoch. ODS has no equivalent concept, so the field is omitted there via skip_serializing_if. Adds a fixture (resources/test/excel-1904-epoch.xlsx, generated with openpyxl using CALENDAR_MAC_1904) and a focused short-JSON test that asserts has_1904_epoch":true; existing pretty-JSON tests are updated to include "has_1904_epoch":false for the standard 1900-epoch fixtures. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends qsv excel --metadata JSON output to include workbook-level date epoch information (1900 vs 1904) by surfacing calamine’s has_1904_epoch() for Excel formats that expose it.
Changes:
- Added
has_1904_epoch: Option<bool>to Excel metadata JSON structs (omitted for ODS viaskip_serializing_if). - Populated the new field from the loaded workbook for Xls/Xlsx/Xlsb metadata modes.
- Updated existing JSON metadata tests and added a new XLSX fixture + test for a 1904-epoch workbook.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/cmd/excel.rs |
Adds has_1904_epoch to JSON metadata structures, computes it from the workbook, and documents it in --help text. |
tests/test_excel.rs |
Updates expected JSON strings to include has_1904_epoch and adds a focused test for a 1904-epoch XLSX fixture. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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
has_1904_epoch()for XLS/XLSX/XLSB in theqsv excel --metadataJSON output so consumers can tell whether dates are anchored to the 1900 or 1904 epoch.Option<bool>with#[serde(skip_serializing_if = "Option::is_none")], so ODS (which has no equivalent concept) cleanly omits it.resources/test/excel-1904-epoch.xlsx, built with openpyxl +CALENDAR_MAC_1904) and a focused short-JSON test asserting"has_1904_epoch":true. Existing pretty-JSON tests were updated to include"has_1904_epoch":falsefor the standard 1900-epoch fixtures.Test plan
cargo build --locked --bin qsv -F all_featurescargo t excel -F all_features— 61 passed (was 60)cargo clippy -F all_features --bin qsv— no new warnings insrc/cmd/excel.rscargo +nightly fmtappliedqsv excel --metadata Son the 1904 fixture reportshas_1904_epoch:true, and that ODS output omits the field🤖 Generated with Claude Code