I am currently working on a calendar project using django that requires some time calculation, and I ran into a problem when I try to calculate the time difference between two datetime objects. When I create time, I do:
tz = timezone.get_default_timezone()
curr_day = timezone.make_aware(datetime.datetime(curr_day.year,
curr_day.month,
curr_day.day,
0, 0, 0), tz)
When I create it, only the date is important, but since the object must use the date and time for historical reasons, I added three 0 for the hour, minute, second.
My program is trying to compare if 2 datetime has a difference of 1 in days, so I do
if (event1 - event2).days == 1:
The problem occurs when I try to compare 03/12/2017 and 03/13/2017 (03/12/2017 - DST).
event1
datetime.datetime(2017, 3, 13, 4, 0, tzinfo=<UTC>)
event2
datetime.datetime(2017, 3, 12, 5, 0, tzinfo=<UTC>)
(event1-event2).days
0
, , , , 1. , ? !