summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ef60637)
raw | patch | inline | side by side (parent: ef60637)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 6 Mar 2003 06:12:30 +0000 (06:12 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 6 Mar 2003 06:12:30 +0000 (06:12 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1571 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/date.py | patch | blob | history | |
test/test_dates.py | patch | blob | history |
diff --git a/roundup/date.py b/roundup/date.py
index 04bcbda06524fc573a80c6cfe15938d830eafbc0..9c479175f7a3c74cdc89f42ac916a2a5dadebd95 100644 (file)
--- a/roundup/date.py
+++ b/roundup/date.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: date.py,v 1.44 2003-03-06 02:33:56 richard Exp $
+# $Id: date.py,v 1.45 2003-03-06 06:12:30 richard Exp $
__doc__ = """
Date, time and time interval handling.
"""Compare this interval to another interval."""
if other is None:
return 1
- for attr in ('year', 'month', 'day', 'hour', 'minute', 'second'):
+ for attr in 'sign year month day hour minute second'.split():
if not hasattr(other, attr):
return 1
r = cmp(getattr(self, attr), getattr(other, attr))
- if r: return r
+ if r:
+ return r
return 0
def __str__(self):
diff --git a/test/test_dates.py b/test/test_dates.py
index f88212a72774db5bc0bf5253b8c19d501de09cbf..2223e3e940bc9c2e44663b38410114b2978cbebf 100644 (file)
--- a/test/test_dates.py
+++ b/test/test_dates.py
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-# $Id: test_dates.py,v 1.18 2003-03-06 02:33:57 richard Exp $
+# $Id: test_dates.py,v 1.19 2003-03-06 06:12:30 richard Exp $
import unittest, time
ae(str(Interval('1:00')/2), '+ 0:30')
ae(str(Interval('00:01')/2), '+ 0:00:30')
+ def testSorting(self):
+ ae = self.assertEqual
+ i1 = Interval('1y')
+ i2 = Interval('1d')
+ l = [i1, i2]; l.sort()
+ ae(l, [i2, i1])
+ l = [i2, i1]; l.sort()
+ ae(l, [i2, i1])
+ i1 = Interval('- 2d')
+ i2 = Interval('1d')
+ l = [i1, i2]; l.sort()
+ ae(l, [i1, i2])
+
+
def suite():
return unittest.makeSuite(DateTestCase, 'test')