# HG changeset patch # User Paul Boddie # Date 1310251541 -7200 # Node ID 78bd2a2870b329ede3168605e54e6b584b03ee7d # Parent 8d441a7aaff44dcd034bdbc48fccb040f12e17e7 Replaced the calendar duration calculation with use of a common subtraction method for dates, removing the Period class, and thus fixing the day heading links in the day view. diff -r 8d441a7aaff4 -r 78bd2a2870b3 EventAggregatorSupport.py --- a/EventAggregatorSupport.py Sat Jul 09 22:26:01 2011 +0200 +++ b/EventAggregatorSupport.py Sun Jul 10 00:45:41 2011 +0200 @@ -1102,16 +1102,6 @@ return cmp(a, b) -class Period: - - "A simple period of time." - - def __init__(self, data): - self.data = data - - def count(self): - return self.data[0] * 12 + self.data[1] - class Convertible: "Support for converting temporal objects." @@ -1163,6 +1153,23 @@ length = min(len(data), len(other_data)) return cmp(data[:length], other_data[:length]) + def __sub__(self, other): + + """ + Return the difference between this object and the 'other' object at the + highest common accuracy of both objects. + """ + + if not isinstance(other, Temporal): + return NotImplemented + else: + data = self.as_tuple() + other_data = other.as_tuple() + if len(data) < len(other_data): + return len(self.until(other)) + else: + return len(other.until(self)) + def _until(self, start, end, nextfn, prevfn): """ @@ -1246,15 +1253,6 @@ previous = previous_month - def __sub__(self, start): - - """ - Return the difference in years and months between this month and the - 'start' month as a period. - """ - - return Period([(x - y) for x, y in zip(self.data, start.data)]) - def months_until(self, end): "Return the collection of months from this month until 'end'." diff -r 8d441a7aaff4 -r 78bd2a2870b3 macros/EventAggregator.py --- a/macros/EventAggregator.py Sat Jul 09 22:26:01 2011 +0200 +++ b/macros/EventAggregator.py Sun Jul 10 00:45:41 2011 +0200 @@ -68,7 +68,9 @@ self.category_name_parameters = "&".join([("category=%s" % name) for name in category_names]) - self.duration = (last - first).count() + 1 + # Calculate the duration in terms of the highest common unit of time. + + self.duration = last - first if self.calendar_name is not None: