Skip to content

Commit 994ead2

Browse files
committed
Simplify and fix interval comparison.
1 parent 8d37a3b commit 994ead2

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

roundup/date.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -719,14 +719,8 @@ def set(self, spec, allowdate=1, interval_re=re.compile('''
719719

720720
def __cmp__(self, other):
721721
"""Compare this interval to another interval."""
722-
if other is None:
723-
# we are always larger than None
724-
return 1
725-
for attr in 'sign year month day hour minute second'.split():
726-
r = cmp(getattr(self, attr), getattr(other, attr))
727-
if r:
728-
return r
729-
return 0
722+
723+
return cmp(self.as_seconds(), other.as_seconds())
730724

731725
def __str__(self):
732726
"""Return this interval as a string."""

0 commit comments

Comments
 (0)