From: stefan Date: Thu, 4 Nov 2010 21:56:51 +0000 (+0000) Subject: Simplify and fix interval comparison. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=aae24244fbc4b208adb0d0db5382407331101fe6;p=roundup.git Simplify and fix interval comparison. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4570 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/date.py b/roundup/date.py index cedc6d4..a86ed59 100644 --- a/roundup/date.py +++ b/roundup/date.py @@ -719,14 +719,8 @@ class Interval: def __cmp__(self, other): """Compare this interval to another interval.""" - if other is None: - # we are always larger than None - return 1 - for attr in 'sign year month day hour minute second'.split(): - r = cmp(getattr(self, attr), getattr(other, attr)) - if r: - return r - return 0 + + return cmp(self.as_seconds(), other.as_seconds()) def __str__(self): """Return this interval as a string."""