Skip to content

Fix date round-trip bugs across non-UTC timezones - #107

Merged
goneall merged 5 commits into
spdx:masterfrom
bact:fix-utc
Sep 17, 2026
Merged

goneall merged 5 commits into
spdx:masterfrom
bact:fix-utc

Conversation

@bact

@bact bact commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

To fix #106.

PR #100 correctly changes date string formatting to UTC (per SPDX spec) but haven't yet change cell value read/write - so they are still use default JVM timezone, and fail round-trip tests on non-UTC timezone (on local machines, as reported on #106)

This PR:

  • force UTC in package dates and document created date parsing
  • add timezone and daylight saving regression test.

Since there a lot of bolilerplate for date/time and number read from/write to cell, I put them in helper function - also to avoid drifts in the future.

Implementation details

  • Shared AbstractSheet helpers (SPDX_UTC_DATE_FORMAT, getCellLocalDateTimeUtc, formatCellUtcDate, parseUtcDate, toUtcLocalDateTime) replace per-file DATE_FORMAT aliases and duplicated conversions
  • AnnotationsSheet, DocumentInfoSheet, DocumentInfoSheetV2d0, PackageInfoSheetV2d3 all use them
  • OdsCell.getLocalDateTimeCellValue to throws on wrong-typed cells like real POI; getDateCellValue delegates to it

Note that the adversarial test cases against extreme timezones and daylight saving edge cases are generated by AI.

- Force UTC in package dates and document created date parsing
- Add timezone and daylight saving regression test

Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@bact bact added the bug Something isn't working label Sep 17, 2026
@bact bact linked an issue Sep 17, 2026 that may be closed by this pull request
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@bact
bact requested a review from goneall September 17, 2026 13:50
@bact
bact removed the request for review from goneall September 17, 2026 15:18
@bact
bact marked this pull request as draft September 17, 2026 15:18
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@bact
bact marked this pull request as ready for review September 17, 2026 16:14

@goneall goneall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tested locally and it fixed the issue

Thanks @bact

@goneall
goneall merged commit 2c511ef into spdx:master Sep 17, 2026
1 check passed
@bact
bact deleted the fix-utc branch September 17, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit tests do not pass on local machine

2 participants