diff options
author | cce <devnull@localhost> | 2006-01-09 09:15:26 +0000 |
---|---|---|
committer | cce <devnull@localhost> | 2006-01-09 09:15:26 +0000 |
commit | 09d4facbb27cd0ec67a2638be20781c9d1fcad00 (patch) | |
tree | 5ad72f879de660672f9850677cec40514e01c4ad | |
parent | 454cabcbd44baac1062692274ae181713ecaf3b4 (diff) | |
download | paste-09d4facbb27cd0ec67a2638be20781c9d1fcad00.tar.gz |
- add support for 'dd-mon-yyyy' date format
-rw-r--r-- | paste/util/datetimeutil.py | 7 | ||||
-rw-r--r-- | tests/test_util/test_datetimeutil.py | 3 |
2 files changed, 7 insertions, 3 deletions
diff --git a/paste/util/datetimeutil.py b/paste/util/datetimeutil.py index 5cd20ba..7fbccbe 100644 --- a/paste/util/datetimeutil.py +++ b/paste/util/datetimeutil.py @@ -203,8 +203,11 @@ def parse_date(val): d = d.split("+")[0]
if " " in d:
d = d.split(" ")[0]
- now = date(int(y),int(m),int(d))
- val = "xxx" + val[10:]
+ try:
+ now = date(int(y),int(m),int(d))
+ val = "xxx" + val[10:]
+ except ValueError:
+ pass
# allow for 'now', 'mon', 'tue', etc.
if not now:
diff --git a/tests/test_util/test_datetimeutil.py b/tests/test_util/test_datetimeutil.py index ace069f..3da3d62 100644 --- a/tests/test_util/test_datetimeutil.py +++ b/tests/test_util/test_datetimeutil.py @@ -79,12 +79,14 @@ def test_date(): assert('1999-04-18' == normalize_date("1999-04-11 7"))
assert('1999-04-11' == normalize_date("11 apr 1999"))
assert('1999-04-11' == normalize_date("11 Apr 1999"))
+ assert('1999-04-11' == normalize_date("11-apr-1999"))
assert('1999-04-11' == normalize_date("11 April 1999"))
assert('1999-04-11' == normalize_date("11 APRIL 1999"))
assert('1999-04-11' == normalize_date("11 april 1999"))
assert('1999-04-11' == normalize_date("11 aprick 1999"))
assert('1999-04-11' == normalize_date("APR 11, 1999"))
assert('1999-04-11' == normalize_date("4/11/1999"))
+ assert('1999-04-11' == normalize_date("4-11-1999"))
assert('1999-04-11' == normalize_date("1999-4-11"))
assert('1999-04-11' == normalize_date("19990411"))
@@ -115,7 +117,6 @@ def test_date(): return
raise "type error expected", val
- assertError("4-11-1999")
assertError("2000-13-11")
assertError("APR 99")
assertError("29 FEB 1900")
|