1.1 --- a/EventAggregatorSupport.py Sun Jan 30 00:40:20 2011 +0100
1.2 +++ b/EventAggregatorSupport.py Mon Jan 31 01:18:10 2011 +0100
1.3 @@ -982,7 +982,7 @@
1.4 times.add(end.as_date().next_day())
1.5
1.6 times = list(times)
1.7 - times.sort()
1.8 + times.sort(cmp_dates_as_day_start)
1.9
1.10 scale = []
1.11 first = 1
1.12 @@ -998,6 +998,26 @@
1.13
1.14 # Date-related functions.
1.15
1.16 +def cmp_dates_as_day_start(a, b):
1.17 +
1.18 + """
1.19 + Compare dates/datetimes 'a' and 'b' treating dates without time information
1.20 + as the earliest time in a particular day.
1.21 + """
1.22 +
1.23 + are_equal = a == b
1.24 +
1.25 + if are_equal:
1.26 + a2 = a.as_datetime_or_date()
1.27 + b2 = b.as_datetime_or_date()
1.28 +
1.29 + if isinstance(a2, Date) and isinstance(b2, DateTime):
1.30 + return -1
1.31 + elif isinstance(a2, DateTime) and isinstance(b2, Date):
1.32 + return 1
1.33 +
1.34 + return cmp(a, b)
1.35 +
1.36 class Period:
1.37
1.38 "A simple period of time."