Skip to content

Conversation

@ryanpetrello
Copy link
Contributor

related: #620
related: #633

@ryanpetrello
Copy link
Contributor Author

ryanpetrello commented Mar 12, 2018

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

self._until = until

if self._dtstart and self._until:
if all((
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point - addressed 👍

until = datetime.datetime.fromordinal(until.toordinal())
self._until = until

if self._dtstart and self._until:
Copy link
Member

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.

Copy link
Contributor Author

@ryanpetrello ryanpetrello Mar 13, 2018

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'

Copy link
Contributor Author

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.

Copy link
Member

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.

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