Skip to content

rust: Fix daylight saving inaccuracy#122

Merged
bact merged 3 commits into
JPEWdev:mainfrom
bact:fix-rust-dst
Jul 2, 2026
Merged

rust: Fix daylight saving inaccuracy#122
bact merged 3 commits into
JPEWdev:mainfrom
bact:fix-rust-dst

Conversation

@bact

@bact bact commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

The timezone offset should use the offset of the date in the parsing (input data), not the current date (today). Or it risks to get a wrong offset due to shift from daylight saving time (DST).

Example: Decoding "2024-03-11T01:02:03" (no timezone, before DST started) while running the code today in July (DST active, UTC+1) previously produced 2024-03-11T01:02:03+01:00 which is wrong, since March 11 was actually UTC+0. It now correctly produces 2024-03-11T01:02:03Z.

Note that this issue will not occur with a valid SPDX 3 document since SPDX 3 DateTime requires it "always expressed in UTC time zone" so no DST and no issue. But as shacl2code can be generic, the issue may occurs with non-SPDX use cases.

The timezone offset should use the offset of the date in the parsing (input data), not the current date (today). Or it risks to get a wrong offset due to shift from DST.

Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@bact bact added the bug Something isn't working label Jul 1, 2026
@bact

bact commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

@stondo please kindly review at your convenience

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Coverage report

This PR does not seem to contain any modification to coverable code.

@JPEWdev

JPEWdev commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Is ti possible to add a test for this?

@bact

bact commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Will add tests, thanks

@bact
bact marked this pull request as draft July 1, 2026 17:47
bact added 2 commits July 1, 2026 21:41
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@bact
bact marked this pull request as ready for review July 2, 2026 02:02
@bact bact added this to the 1.1.1 milestone Jul 2, 2026
@bact

bact commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

Test added.

The test set locale to New York time.

Then create two date times, one noon in summer and one noon in winter, using the generated decode_date_time().

Then check if each of them get a correct time zone component in ISO date output from the generated encode_date_time() (should get "-04:00" for summer, "-05:00" for winter).

chrono Rust dependency is set to 0.4.31 because we use fixed_offset().

@bact
bact requested review from JPEWdev and Copilot and removed request for Copilot July 2, 2026 09:26
@bact
bact merged commit 53b622f into JPEWdev:main Jul 2, 2026
10 checks passed
@bact
bact deleted the fix-rust-dst branch July 2, 2026 23:29
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.

2 participants