test: use isoformat() to compare dates with timezone information#172
Merged
Conversation
The date 2017-10-29 02:00 is ambiguous for Europe/Warsaw. It can be UTC+1 or UTC+2. To make the test case easier to read, test all dates during the DST transition starting with an unambiguous date.
`datetime` will ignore the UTC offset when comparing dates that have the same timezone. So comparing dates with timezone information require to compare the UTC offset in addition. Use `isoformat()` to compare dates with timezone information.
potiuk
approved these changes
Jun 24, 2025
potiuk
left a comment
Contributor
There was a problem hiding this comment.
Indeed. BTW ARE YOU IN Warsaw? We should meet :)
Contributor
Author
|
Nope, I am in Berlin. :) |
Contributor
Next time at FOSS Backstage, Berlin Buzzwords - I never miss those two. |
Contributor
Author
|
Another FOSS conference in Berlin that I wasn't aware of! |
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 date 2017-10-29 02:00 is ambiguous for Europe/Warsaw. It can be UTC+1 or UTC+2.
To make the test case easier to read, test all dates during the DST transition starting with an unambiguous date.
datetimewill ignore the UTC offset when comparing dates that have the same timezone. So comparing dates with timezone information require to compare the UTC offset in addition.Use
isoformat()to compare dates with timezone information.