Fix skipping day when parsing times if UTC and TIMEZONE day are different#1183
Merged
Gallaecio merged 1 commit intoscrapinghub:masterfrom Dec 18, 2023
Merged
Fix skipping day when parsing times if UTC and TIMEZONE day are different#1183Gallaecio merged 1 commit intoscrapinghub:masterfrom
Gallaecio merged 1 commit intoscrapinghub:masterfrom
Conversation
Baviaan
approved these changes
Oct 29, 2023
Contributor
Baviaan
left a comment
There was a problem hiding this comment.
Thanks for making these changes, looks good!
Contributor
|
Closing and reopening to trigger CI (hopefully). |
Contributor
|
Perfect, thank you! |
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.
This should fix #1169
If only a time is provided such as "8pm", the previous logic determines if the time is in the "future" or "past" by comparing the base time of day and the parsed time.
This works if the timezone is UTC, but to make this respect the TIMEZONE setting, #1002 subtracts the timezone's offset from the parsed time. If this causes the day to roll over, then comparing times will incorrectly report the parsed date as being in the past. For example.
datetime(2023, 2, 3, 4).time() == datetime.time(4, 0)is reported as earlier thamdatetime(2023, 2, 2, 18).time() == datetime.time(18, 0), and erroneously adding day. To correct this, we could compare dates rather than times.