Open pigmonkey opened 7 years ago
Thanks @pigmonkey!
That change makes sense to me - would you mind sending that in a pull request?
@pigmonkey I ran into the same issue - did you fix this? And if yes, is the fix as simple as specifying a dtstart
?
Yes, if you pass in an aware datetime for dtstart
it will work as expected. The other option would be to not pass dtstart
, but to strip the tzinfo from your other date objects (using something like timezone.make_naive
.
I keep meaning to submit a PR to fix this, but have not gotten to it yet.
This pull request was merged can you make a release with it please? I am seeing this issue in version 1.10.1
which is the latest version.
I see, the pull request did not address dealing with when there is no dtstart or dtend attached to the recurrence so this support is incomplete. If you call
recurrence.between(start, end)
and they are not set then the datetime created is offset naive and the comparison fails and your app crashes.
Looks like not your bug: https://github.com/dateutil/dateutil/issues/979
I believe RRULE is using UTC time. so, just convert aware datetime object to UTC and remove tzinfo. It should work perfectly
I have a model similar to the
Course
model in the documentation.I've created an object with a simple recurrence of once per month on the fifth. There are no dates (
dtend
,dtstart
,until
, etc) associated.When asking for a list of occurrences between two naive datetime objects, everything works as expected.
However, my Django app uses timezones, so I rarely deal with naive objects. Instead I'll pass in two timezone aware objects.
This error was unexpected since I am not providing offset-naive datetimes anywhere in this example. I believe the problem is that because I am not specifying
dtstart
the dateutil library callsdatetime.datetime.now()
when django-recurrence generates thedateutil.rrule.rrule
.Since Django can have configured timezones, it seems like django-recurrence should always pass
timezone.now()
asdtstart
to dateutil unless the user has provided a value. That will result in an aware object if timezones are configured, and a naive object otherwise, which is likely the expected behaviour.