X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=roundup%2Fdate.py;h=af8d1d533c155a4bf2c6ca055a640f342cc6c5ef;hb=b5264517ddce88390bb87f29c925a73716c89c51;hp=f857bf7c969103488280ffa7777a8352a6248607;hpb=d2f2c9ff47c1b90b5973e46109f9ef3d1dba024f;p=roundup.git diff --git a/roundup/date.py b/roundup/date.py index f857bf7..af8d1d5 100644 --- a/roundup/date.py +++ b/roundup/date.py @@ -522,6 +522,7 @@ class Date: def local(self, offset): """ Return this date as yyyy-mm-dd.hh:mm:ss in a local time zone. + The offset is a pytz tz offset if pytz is installed. """ y, m, d, H, M, S = _utc_to_local(self.year, self.month, self.day, self.hour, self.minute, self.second, offset) @@ -718,14 +719,11 @@ 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."""