diff --git a/roundup/date.py b/roundup/date.py
index 7daf952d5a01364b2a4a3ad89e61de9a11885adf..a86ed59fe0a3e909e58f040f7663c47c07d3ac21 100644 (file)
--- a/roundup/date.py
+++ b/roundup/date.py
info = m.groupdict()
- # determine whether we need to add anything at the end
+ # If add_granularity is true, construct the maximum time given
+ # the precision of the input. For example, given the input
+ # "12:15", construct "12:15:59". Or, for "2008", construct
+ # "2008-12-31.23:59:59".
if add_granularity:
for gran in 'SMHdmy':
if info[gran] is not None:
else:
add_granularity = Interval('+1%s'%gran)
break
+ else:
+ raise ValueError(self._('Could not determine granularity'))
# get the current date as our default
dt = datetime.datetime.utcnow()
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)
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."""