-
Notifications
You must be signed in to change notification settings - Fork 523
require UTC for UNTIL when DTSTART is timezone-aware #634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@pganssle I think I've addressed the feedback you added to: ryanpetrello@a9007c4#commitcomment-28049100 |
dateutil/rrule.py
Outdated
| self._until = until | ||
|
|
||
| if self._dtstart and self._until: | ||
| if all(( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and one thing to note is that my formulation also catches the case where only UNTIL is aware.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point - addressed 👍
related: dateutil#620 related: dateutil#633
| until = datetime.datetime.fromordinal(until.toordinal()) | ||
| self._until = until | ||
|
|
||
| if self._dtstart and self._until: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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'There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...or at the very least, we need to check truthiness of self._until.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you are right, sorry, I read this as self._dstart.tzinfo, my bad.
related: #620
related: #633