diff options
author | Cheuk Ho <cheuk@Cheuks-MacBook-Pro.local> | 2018-10-02 14:47:38 +0100 |
---|---|---|
committer | Paul Ganssle <paul@ganssle.io> | 2018-10-06 13:39:50 -0400 |
commit | 91ba90e61941ddbcd16dbe8ef8441d0b8e51a084 (patch) | |
tree | 6cc1ebb98b774ce0217728fdecc42c3be4e60bcf /dateutil | |
parent | 479e340ce9f32581aa6eeb54e97c4e7866d31611 (diff) | |
download | dateutil-91ba90e61941ddbcd16dbe8ef8441d0b8e51a084.tar.gz |
Accept 'z' for 'Z' in isoparse
Diffstat (limited to 'dateutil')
-rw-r--r-- | dateutil/parser/_parser.py | 2 | ||||
-rw-r--r-- | dateutil/parser/isoparser.py | 4 | ||||
-rw-r--r-- | dateutil/test/test_isoparser.py | 2 |
3 files changed, 5 insertions, 3 deletions
diff --git a/dateutil/parser/_parser.py b/dateutil/parser/_parser.py index 044466d..1cb592d 100644 --- a/dateutil/parser/_parser.py +++ b/dateutil/parser/_parser.py @@ -291,7 +291,7 @@ class parserinfo(object): ("s", "second", "seconds")] AMPM = [("am", "a"), ("pm", "p")] - UTCZONE = ["UTC", "GMT", "Z"] + UTCZONE = ["UTC", "GMT", "Z", "z"] PERTAIN = ["of"] TZOFFSET = {} # TODO: ERA = ["AD", "BC", "CE", "BCE", "Stardate", diff --git a/dateutil/parser/isoparser.py b/dateutil/parser/isoparser.py index 172972b..e3cf6d8 100644 --- a/dateutil/parser/isoparser.py +++ b/dateutil/parser/isoparser.py @@ -341,7 +341,7 @@ class isoparser(object): while pos < len_str and comp < 5: comp += 1 - if timestr[pos:pos + 1] in b'-+Z': + if timestr[pos:pos + 1] in b'-+Zz': # Detect time zone boundary components[-1] = self._parse_tzstr(timestr[pos:]) pos = len_str @@ -376,7 +376,7 @@ class isoparser(object): return components def _parse_tzstr(self, tzstr, zero_as_utc=True): - if tzstr == b'Z': + if tzstr == b'Z' or tzstr == b'z': return tz.tzutc() if len(tzstr) not in {3, 5, 6}: diff --git a/dateutil/test/test_isoparser.py b/dateutil/test/test_isoparser.py index b0e6564..ecd6e84 100644 --- a/dateutil/test/test_isoparser.py +++ b/dateutil/test/test_isoparser.py @@ -228,6 +228,8 @@ def test_iso_ordinal(isoord, dt_expected): (b'20140204T123015.224', datetime(2014, 2, 4, 12, 30, 15, 224000)), (b'2014-02-04T12:30:15.224Z', datetime(2014, 2, 4, 12, 30, 15, 224000, tz.tzutc())), + (b'2014-02-04T12:30:15.224z', datetime(2014, 2, 4, 12, 30, 15, 224000, + tz.tzutc())), (b'2014-02-04T12:30:15.224+05:00', datetime(2014, 2, 4, 12, 30, 15, 224000, tzinfo=tz.tzoffset(None, timedelta(hours=5))))]) |