diff options
author | Michael Twomey <micktwomey@gmail.com> | 2013-10-17 21:28:58 +0100 |
---|---|---|
committer | Michael Twomey <micktwomey@gmail.com> | 2013-10-17 21:28:58 +0100 |
commit | f83e711ed7d38673b057b1c32a3bd72b2532e94a (patch) | |
tree | 902b690505b569fe9785995c4b45e7e2f16b1329 /iso8601 | |
parent | d51f5646e3867494c57cb6463535c0183662bebb (diff) | |
download | pyiso8601-f83e711ed7d38673b057b1c32a3bd72b2532e94a.tar.gz |
Z always specifies UTC now
Thanks to vfaronov
Fixes #5
Diffstat (limited to 'iso8601')
-rw-r--r-- | iso8601/iso8601.py | 2 | ||||
-rw-r--r-- | iso8601/test_iso8601.py | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/iso8601/iso8601.py b/iso8601/iso8601.py index 86c076b..2be28dc 100644 --- a/iso8601/iso8601.py +++ b/iso8601/iso8601.py @@ -134,7 +134,7 @@ def parse_timezone(matches, default_timezone=UTC): """ if matches["timezone"] == "Z": - return default_timezone + return UTC # This isn't strictly correct, but it's common to encounter dates without # timezones so I'll assume the default (which defaults to UTC). # Addresses issue 4. diff --git a/iso8601/test_iso8601.py b/iso8601/test_iso8601.py index 079663d..7a3c7a0 100644 --- a/iso8601/test_iso8601.py +++ b/iso8601/test_iso8601.py @@ -18,6 +18,14 @@ def test_parse_no_timezone_different_default(): assert d == datetime.datetime(2007, 1, 1, 8, 0, 0, 0, tz) assert d.tzinfo == tz +def test_parse_utc_different_default(): + """Z should mean 'UTC', not 'default'. + + """ + tz = iso8601.FixedOffset(2, 0, "test offset") + d = iso8601.parse_date("2007-01-01T08:00:00Z", default_timezone=tz) + assert d == datetime.datetime(2007, 1, 1, 8, 0, 0, 0, iso8601.UTC) + @pytest.mark.parametrize("invalid_date", [ ("2013-10-",), ("2013-",), |