# HG changeset patch # User Paul Boddie # Date 1367532777 -7200 # Node ID 52ce79af5ae73b95addbe67b88f2f1037219246e # Parent 457a5817ee498b0c5f7c80edd8555eacd3070b53 Changed DateSupport to permit identical timespan instants (whose start and end times are identical) to be recognised as such when compared. diff -r 457a5817ee49 -r 52ce79af5ae7 DateSupport.py --- a/DateSupport.py Wed May 01 15:48:18 2013 +0200 +++ b/DateSupport.py Fri May 03 00:12:57 2013 +0200 @@ -92,9 +92,7 @@ as the earliest time in a particular day. """ - are_equal = a == b - - if are_equal: + if a == b: a2 = a.as_datetime_or_date() b2 = b.as_datetime_or_date() @@ -746,20 +744,21 @@ if isinstance(other, ActsAsTimespan): other = other.as_timespan() - if self.end is not None and other.start is not None and self.is_before(self.end, other.start): - return -1 - elif self.start is not None and other.end is not None and self.is_before(other.end, self.start): - return 1 - else: - return 0 + before = self.end is not None and other.start is not None and self.is_before(self.end, other.start) + after = self.start is not None and other.end is not None and self.is_before(other.end, self.start) + else: + before = self.end is not None and self.is_before(self.end, other) + after = self.start is not None and self.is_before(other, self.start) + # Two identical points in time will be "before" each other according to + # the is_before test. + + if not before and not after or before and after: + return 0 + elif before: + return -1 else: - if self.end is not None and self.is_before(self.end, other): - return -1 - elif self.start is not None and self.is_before(other, self.start): - return 1 - else: - return 0 + return 1 class TimespanCollection: diff -r 457a5817ee49 -r 52ce79af5ae7 README.txt --- a/README.txt Wed May 01 15:48:18 2013 +0200 +++ b/README.txt Fri May 03 00:12:57 2013 +0200 @@ -72,6 +72,8 @@ * Introduced support for reverse iteration over stored items. * Expanded the stored metadata for cached remote resources in MoinRemoteSupport. + * Changed DateSupport to permit identical timespan instants (whose start and + end times are identical) to be recognised as such when compared. New in MoinSupport 0.2 (Changes since MoinSupport 0.1) ------------------------------------------------------