add utcnow to if conditional evaluation#1793
Merged
gazpachoking merged 1 commit intoFlexget:developfrom Apr 17, 2017
Merged
Conversation
The "now()" function in Python is relative to your local timezone, whereas the pubdate for most RSS feeds, and possibly many other sources of input, are specified as UTC. So when comparing dates, similar to what is shown in the documentation, it's a lot easier to use utcnow instead of now.
Member
|
Thanks. Want to add that to the if plugin wiki? |
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 "now()" function in Python is relative to your local timezone,
whereas the pubdate for most RSS feeds, and possibly many other sources
of input, are specified as UTC. So when comparing dates, similar to what
is shown in the documentation, it's a lot easier to use utcnow instead
of now.
Motivation for changes:
This allows you to be able to compare dates in a like manner without having to do timezone offset tracking yourself when using the if plugin. While the current implementation of the "if" plugin already handles comparing local timezones with the "now" keyword. Adding the "utcnow" keyword would allow comparing UTC timezones.
Detailed changes:
Config usage if relevant (new plugin or updated schema):
Log and/or tests output (preferably both):
I've tested this locally by making the change, installing it, and running it against the above configuration and it works correctly.