Commit d503df87 authored by Martijn Pieters's avatar Martijn Pieters

Collector #1386: Fixed ISO 1386 parsing, making the colon in the timezone

offset optional.
parent 6a3e0103
......@@ -1678,11 +1678,11 @@ class DateTime:
datereg = re.compile('([0-9]{4})(-([0-9][0-9]))?(-([0-9][0-9]))?')
timereg = re.compile('T([0-9]{2})(:([0-9][0-9]))?(:([0-9][0-9]))?(\.[0-9]{1,20})?')
zonereg = re.compile('([+-][0-9][0-9])(:([0-9][0-9]))')
zonereg = re.compile('([+-][0-9][0-9])(:?([0-9][0-9]))')
# Date part
fields = datereg.split(s.strip())
fields = datereg.split(s.strip(), 1)
if fields[1]: year = int(fields[1])
if fields[3]: month = int(fields[3])
......
......@@ -259,6 +259,10 @@ class DateTimeTests(unittest.TestCase):
isoDt = DateTime('2002-05-02T08:00:00-04:00')
self.assertEqual( ref1, isoDt)
# Bug 1386: the colon in the timezone offset is optional
isoDt = DateTime('2002-05-02T08:00:00-0400')
self.assertEqual( ref1, isoDt)
dgood = '2002-05-02'
tgood = 'T08:00:00-04:00'
for dbad in '2002-5-2', '2002-10-2', '2002-2-10', '02-2-10':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment