FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

require UTC for UNTIL when DTSTART is timezone-aware by ryanpetrello · Pull Request #634 · dateutil/dateutil · GitHub

require UTC for UNTIL when DTSTART is timezone-aware - #634

Merged
pganssle merged 1 commit into
dateutil:masterfrom
ryanpetrello:fix-633
Mar 14, 2018
Merged

pganssle merged 1 commit into
dateutil:masterfrom
ryanpetrello:fix-633

Conversation

Copy link
Copy Markdown
Contributor

related: #620
related: #633

ryanpetrello commented Mar 12, 2018
edited
Loading

Copy link
Copy Markdown
Contributor Author

@pganssle I think I've addressed the feedback you added to: ryanpetrello@a9007c4#commitcomment-28049100

Comment thread dateutil/rrule.py Outdated
self._until = until

if self._dtstart and self._until:
if all((

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this might be better as:

if (self._dtstart.tzinfo is not None) != (self._until.tzinfo is not None)

That's basically the condition under which it would fail because of the comparison anyway, and I don't want to enforce that it's specifically tzutc (what if you used datetime.timezone.utc or pytz.UTC). I think being slightly less strict about the specifics of the RFC is worth it in this case, since I want to tread lightly.

I'll note that there's a very strange edge case that would occur if self._dtstart.tzinfo is self._until.tzinfo and the UNTIL value is an ambiguous time, but I'm not terribly worried about that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Oh, and one thing to note is that my formulation also catches the case where only UNTIL is aware.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good point - addressed 👍

Comment thread dateutil/rrule.py
until = datetime.datetime.fromordinal(until.toordinal())
self._until = until

if self._dtstart and self._until:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There's no need for this line. The problem is with the incompatibility between DTSTART and UNTIL. Not sure what the RFC has to say, but if UNTIL is aware and DTSTART has no specified time zone, you still don't know when to end the rule.

ryanpetrello Mar 13, 2018
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@pganssle it seems necessary to me. If I change this and run the tests:

>       if (self._dtstart.tzinfo is not None) != (self._until.tzinfo is not None):
E       AttributeError: 'NoneType' object has no attribute 'tzinfo'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

...or at the very least, we need to check truthiness of self._until.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ah, you are right, sorry, I read this as self._dstart.tzinfo, my bad.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL