1.1 --- a/EventAggregatorSupport.py Sat Jul 09 22:26:01 2011 +0200
1.2 +++ b/EventAggregatorSupport.py Sun Jul 10 00:45:41 2011 +0200
1.3 @@ -1102,16 +1102,6 @@
1.4
1.5 return cmp(a, b)
1.6
1.7 -class Period:
1.8 -
1.9 - "A simple period of time."
1.10 -
1.11 - def __init__(self, data):
1.12 - self.data = data
1.13 -
1.14 - def count(self):
1.15 - return self.data[0] * 12 + self.data[1]
1.16 -
1.17 class Convertible:
1.18
1.19 "Support for converting temporal objects."
1.20 @@ -1163,6 +1153,23 @@
1.21 length = min(len(data), len(other_data))
1.22 return cmp(data[:length], other_data[:length])
1.23
1.24 + def __sub__(self, other):
1.25 +
1.26 + """
1.27 + Return the difference between this object and the 'other' object at the
1.28 + highest common accuracy of both objects.
1.29 + """
1.30 +
1.31 + if not isinstance(other, Temporal):
1.32 + return NotImplemented
1.33 + else:
1.34 + data = self.as_tuple()
1.35 + other_data = other.as_tuple()
1.36 + if len(data) < len(other_data):
1.37 + return len(self.until(other))
1.38 + else:
1.39 + return len(other.until(self))
1.40 +
1.41 def _until(self, start, end, nextfn, prevfn):
1.42
1.43 """
1.44 @@ -1246,15 +1253,6 @@
1.45
1.46 previous = previous_month
1.47
1.48 - def __sub__(self, start):
1.49 -
1.50 - """
1.51 - Return the difference in years and months between this month and the
1.52 - 'start' month as a period.
1.53 - """
1.54 -
1.55 - return Period([(x - y) for x, y in zip(self.data, start.data)])
1.56 -
1.57 def months_until(self, end):
1.58
1.59 "Return the collection of months from this month until 'end'."
2.1 --- a/macros/EventAggregator.py Sat Jul 09 22:26:01 2011 +0200
2.2 +++ b/macros/EventAggregator.py Sun Jul 10 00:45:41 2011 +0200
2.3 @@ -68,7 +68,9 @@
2.4
2.5 self.category_name_parameters = "&".join([("category=%s" % name) for name in category_names])
2.6
2.7 - self.duration = (last - first).count() + 1
2.8 + # Calculate the duration in terms of the highest common unit of time.
2.9 +
2.10 + self.duration = last - first
2.11
2.12 if self.calendar_name is not None:
2.13