summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bc15ee6)
raw | patch | inline | side by side (parent: bc15ee6)
author | stefan <stefan@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 23 Feb 2009 19:24:57 +0000 (19:24 +0000) | ||
committer | stefan <stefan@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Mon, 23 Feb 2009 19:24:57 +0000 (19:24 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4164 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 7daf952d5a01364b2a4a3ad89e61de9a11885adf..f857bf7c969103488280ffa7777a8352a6248607 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()
diff --git a/test/test_dates.py b/test/test_dates.py
index a8c79ea97fe5295a21420016b72481dd730d4087..0dd825121304d76aa0e816d976e090079f298d48 100644 (file)
--- a/test/test_dates.py
+++ b/test/test_dates.py
ae(str(date), '2000-02-29.00:00:00')
date = Date("2001-02-27 + 2d")
ae(str(date), '2001-03-01.00:00:00')
-
+ date = Date("2009", add_granularity=True)
+ self.assertRaises(ValueError, Date, ". +30d", add_granularity=True)
+
def testDate(self):
ae = self.assertEqual
date = Date("2000-04-17")