Skip to content

add utcnow to if conditional evaluation#1793

Merged
gazpachoking merged 1 commit intoFlexget:developfrom
aauren:add_utcnow_to_if_conditional
Apr 17, 2017
Merged

add utcnow to if conditional evaluation#1793
gazpachoking merged 1 commit intoFlexget:developfrom
aauren:add_utcnow_to_if_conditional

Conversation

@aauren
Copy link
Copy Markdown
Contributor

@aauren aauren commented Apr 17, 2017

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:

  • add utcnow keyword to the list of keywords the if plugin understands

Config usage if relevant (new plugin or updated schema):

    if:
      - rss_pubdate > utcnow - timedelta(hours=1): reject

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.

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.
@gazpachoking gazpachoking merged commit 2dce5ea into Flexget:develop Apr 17, 2017
@gazpachoking
Copy link
Copy Markdown
Member

Thanks. Want to add that to the if plugin wiki?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants