Skip to content

feat(excel): expose has_1904_epoch in workbook metadata#3905

Merged
jqnatividad merged 2 commits into
masterfrom
feat/excel-has-1904-epoch
May 26, 2026
Merged

feat(excel): expose has_1904_epoch in workbook metadata#3905
jqnatividad merged 2 commits into
masterfrom
feat/excel-has-1904-epoch

Conversation

@jqnatividad
Copy link
Copy Markdown
Collaborator

Summary

  • Surfaces calamine 0.35's has_1904_epoch() for XLS/XLSX/XLSB in the qsv excel --metadata JSON output so consumers can tell whether dates are anchored to the 1900 or 1904 epoch.
  • Field is Option<bool> with #[serde(skip_serializing_if = "Option::is_none")], so ODS (which has no equivalent concept) cleanly omits it.
  • Adds a generated XLSX fixture (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":false for the standard 1900-epoch fixtures.

Test plan

  • cargo build --locked --bin qsv -F all_features
  • cargo t excel -F all_features — 61 passed (was 60)
  • cargo clippy -F all_features --bin qsv — no new warnings in src/cmd/excel.rs
  • cargo +nightly fmt applied
  • Manually verified qsv excel --metadata S on the 1904 fixture reports has_1904_epoch:true, and that ODS output omits the field

🤖 Generated with Claude Code

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>
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 26, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 via skip_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.

Comment thread src/cmd/excel.rs Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@jqnatividad jqnatividad merged commit b5d4479 into master May 26, 2026
14 of 16 checks passed
@jqnatividad jqnatividad deleted the feat/excel-has-1904-epoch branch May 26, 2026 16:36
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