summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Twomey <micktwomey@gmail.com>2013-10-17 22:33:30 +0100
committerMichael Twomey <micktwomey@gmail.com>2013-10-17 22:33:30 +0100
commitc13d90b35086331fb37687c95c602b1aa0fb52a5 (patch)
treee1c4290aa2dde21d6f0f8933aa9bb11549f2e219
parentf83e711ed7d38673b057b1c32a3bd72b2532e94a (diff)
downloadpyiso8601-c13d90b35086331fb37687c95c602b1aa0fb52a5.tar.gz
Handle compact date format
Thanks to rvandolson@esri.com Fixes #6
-rw-r--r--README.rst1
-rw-r--r--iso8601/iso8601.py2
-rw-r--r--iso8601/test_iso8601.py1
3 files changed, 3 insertions, 1 deletions
diff --git a/README.rst b/README.rst
index 29889e5..5e49eaa 100644
--- a/README.rst
+++ b/README.rst
@@ -75,6 +75,7 @@ Changes
* Fix pickling and deepcopy of returned datetime objects (https://bitbucket.org/micktwomey/pyiso8601/issue/3/dates-returned-by-parse_date-do-not) (thanks to fogathmann and john@openlearning.com)
* Fix timezone offsets without a separator (https://bitbucket.org/micktwomey/pyiso8601/issue/4/support-offsets-without-a-separator) (thanks to joe.walton.gglcd)
* "Z" produces default timezone if one is specified (https://bitbucket.org/micktwomey/pyiso8601/issue/5/z-produces-default-timezone-if-one-is) (thanks to vfaronov). This one may cause problems if you've been relying on default_timezone to use that timezone instead of UTC. Strictly speaking that was wrong but this is potentially backwards incompatible.
+* Handle compact date format (https://bitbucket.org/micktwomey/pyiso8601/issue/6/handle-compact-date-format) (thanks to rvandolson@esri.com)
0.1.4
-----
diff --git a/iso8601/iso8601.py b/iso8601/iso8601.py
index 2be28dc..efd6413 100644
--- a/iso8601/iso8601.py
+++ b/iso8601/iso8601.py
@@ -173,7 +173,7 @@ def parse_date(datestring, default_timezone=UTC):
year=to_int(groups, "year"),
month=to_int(groups, "month"),
day=to_int(groups, "day"),
- hour=to_int(groups, "hour"),
+ hour=to_int(groups, "hour", default_to_zero=True),
minute=to_int(groups, "minute", default_to_zero=True),
second=to_int(groups, "second", default_to_zero=True),
microsecond=groups["second_fraction"],
diff --git a/iso8601/test_iso8601.py b/iso8601/test_iso8601.py
index 7a3c7a0..17e1a21 100644
--- a/iso8601/test_iso8601.py
+++ b/iso8601/test_iso8601.py
@@ -58,6 +58,7 @@ def test_parse_invalid_date(invalid_date):
("20131015T18:30Z", datetime.datetime(2013, 10, 15, 18, 30, 0, 0, iso8601.UTC)), # YYYYMMDD
("2012-12-19T23:21:28.512400+00:00", datetime.datetime(2012, 12, 19, 23, 21, 28, 512400, iso8601.FixedOffset(0, 0, "+00:00"))), # https://code.google.com/p/pyiso8601/issues/detail?id=21
("2006-10-20T15:34:56.123+0230", datetime.datetime(2006, 10, 20, 15, 34, 56, 123000, iso8601.FixedOffset(2, 30, "+02:30"))), # https://code.google.com/p/pyiso8601/issues/detail?id=18
+ ("19950204", datetime.datetime(1995, 2, 4, tzinfo=iso8601.UTC)), # https://code.google.com/p/pyiso8601/issues/detail?id=1
])
def test_parse_valid_date(valid_date, expected_datetime):
parsed = iso8601.parse_date(valid_date)