aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCheuk Ho <cheuk@Cheuks-MBP.domain.name>2018-10-04 08:57:53 +0100
committerPaul Ganssle <paul@ganssle.io>2018-10-06 13:39:50 -0400
commit969d6bac84ca34276155d85c4943c3c736781187 (patch)
treec32f9defd0c71294022cbcb9f1026bb143c9ed1e
parent4e696bbeeb81e3d9078943500f648d845295c845 (diff)
downloaddateutil-969d6bac84ca34276155d85c4943c3c736781187.tar.gz
Accept 'z' for UTC in parser
-rw-r--r--dateutil/parser/_parser.py6
-rw-r--r--dateutil/test/test_parser.py5
2 files changed, 9 insertions, 2 deletions
diff --git a/dateutil/parser/_parser.py b/dateutil/parser/_parser.py
index 1cb592d..efb76fa 100644
--- a/dateutil/parser/_parser.py
+++ b/dateutil/parser/_parser.py
@@ -388,7 +388,8 @@ class parserinfo(object):
if res.year is not None:
res.year = self.convertyear(res.year, res.century_specified)
- if res.tzoffset == 0 and not res.tzname or res.tzname == 'Z':
+ if (res.tzoffset == 0 and not res.tzname or res.tzname == 'Z'
+ or res.tzname == 'z'):
res.tzname = "UTC"
res.tzoffset = 0
elif res.tzoffset != 0 and res.tzname and self.utczone(res.tzname):
@@ -1060,7 +1061,8 @@ class parser(object):
tzname is None and
tzoffset is None and
len(token) <= 5 and
- all(x in string.ascii_uppercase for x in token))
+ (all(x in string.ascii_uppercase for x in token)
+ or token in self.info.UTCZONE))
def _ampm_valid(self, hour, ampm, fuzzy):
"""
diff --git a/dateutil/test/test_parser.py b/dateutil/test/test_parser.py
index c2d5d9a..dcaa7cc 100644
--- a/dateutil/test/test_parser.py
+++ b/dateutil/test/test_parser.py
@@ -472,6 +472,11 @@ class ParserTest(unittest.TestCase):
self.assertEqual(parse("1976-07-04T00:01:02Z", ignoretz=True),
datetime(1976, 7, 4, 0, 1, 2))
+ def testRandomFormat18(self):
+ self.assertEqual(parse("1986-07-05T08:15:30z",
+ ignoretz=True),
+ datetime(1986, 7, 5, 8, 15, 30))
+
def testRandomFormat20(self):
self.assertEqual(parse("Tue Apr 4 00:22:12 PDT 1995", ignoretz=True),
datetime(1995, 4, 4, 0, 22, 12))