datetime parser fails on valid ISO 8601 string

Bug #974463 reported by Chris Johnson
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
dateutil
Confirmed
High
Tomi Hukkalainen

Bug Description

dateutil.parser.parse()
-- input = a string, supposedly formatted as an ISO 8601 date/time
-- output = a Python datetime, if the input could be parsed

This works:

>>> dateutil.parser.parse("2012-04-05T13:06:47.458Z")
datetime.datetime(2012, 4, 5, 13, 6, 47, 458000, tzinfo=tzutc())

This fails:

>>> dateutil.parser.parse("2012-04-05T13:06:47,458Z")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dateutil/parser.py", line 697, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dateutil/parser.py", line 303, in parse
    raise ValueError, "unknown string format"
ValueError: unknown string format

The only difference between the two is, in failed case fractional seconds are delimited by comma, not period.

The ISO 8601 standard allows both comma and period.

Should succeed / give the same output for both inputs.

Regards
-- Chris

Revision history for this message
Tomi Hukkalainen (tpievila) wrote : Re: [Bug 974463] [NEW] datetime parser fails on valid ISO 8601 string

 status confirmed

 importance high

 assignee tpievila

--
Tomi Pieviläinen, +358 400 487 504
A: Because it disrupts the natural way of thinking.
Q: Why is top posting frowned upon?

Changed in dateutil:
assignee: nobody → Tomi Pieviläinen (tpievila)
importance: Undecided → High
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.