rust: Fix daylight saving inaccuracy#122
Open
bact wants to merge 3 commits into
Open
Conversation
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>
Collaborator
Author
|
@stondo please kindly review at your convenience |
Owner
|
Is ti possible to add a test for this? |
Collaborator
Author
|
Will add tests, thanks |
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.
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.