1.1 --- a/imiptools/period.py Mon Feb 02 18:46:59 2015 +0100
1.2 +++ b/imiptools/period.py Mon Feb 02 19:43:14 2015 +0100
1.3 @@ -20,6 +20,7 @@
1.4 """
1.5
1.6 from bisect import bisect_left, insort_left
1.7 +from datetime import datetime
1.8 from imiptools.dates import get_datetime, get_start_of_day, to_timezone
1.9
1.10 # Time management.
1.11 @@ -124,9 +125,16 @@
1.12 start, end = t[:2]
1.13
1.14 # NOTE: This only really works if the datetimes are UTC already.
1.15 + # NOTE: Since the periods should originate from the free/busy data,
1.16 + # NOTE: and since that data should employ UTC times, this should not be
1.17 + # NOTE: an immediate problem.
1.18
1.19 - start = to_timezone(get_datetime(start), tzid)
1.20 - end = to_timezone(get_datetime(end), tzid)
1.21 + start = get_datetime(start)
1.22 + end = get_datetime(end)
1.23 +
1.24 + start = isinstance(start, datetime) and to_timezone(start, tzid) or get_start_of_day(start, tzid)
1.25 + end = isinstance(end, datetime) and to_timezone(end, tzid) or get_start_of_day(end, tzid)
1.26 +
1.27 l.append((start, end) + tuple(t[2:]))
1.28
1.29 return l