django-recurrence
django-recurrence copied to clipboard
exdate set in admin ui is saved at 00:00, while comparision is made against exact dtstart time
When one sets an exclude date in the admin ui, the exdate gets ignored by the between function. It seems that the admin ui passes a date object into the model, that is then cast into a datetime object resulting in timings like 00:00. Since the between function only matches against exact datetime, the exdate does not match.
>>> s.recurrences.dtstart
datetime.datetime(2017, 5, 7, 1, 0)
>>> s.recurrences.exdates
[datetime.datetime(2017, 5, 10, 0, 0)]
>>> s.recurrences.between(datetime.datetime(2017,5,9), datetime.datetime(2017,5,12))
[datetime.datetime(2017, 5, 9, 1, 0), datetime.datetime(2017, 5, 10, 1, 0), datetime.datetime(2017, 5, 11, 1, 0)]
When setting the correct time programmatically everything works as expected:
>>> s.recurrences.exdates[0] = datetime.datetime(2017, 5, 10, 1, 0)
>>> s.recurrences.exdates
[datetime.datetime(2017, 5, 10, 1, 0)]
>>> s.recurrences.between(datetime.datetime(2017,5,9), datetime.datetime(2017,5,12))
[datetime.datetime(2017, 5, 9, 1, 0), datetime.datetime(2017, 5, 11, 1, 0)]
I assume the date passed from the admin ui widget needs some kind of normalization to set a correct time or the exdate should be implemented time agnostic at all.