0

Perhaps I am missing something obvious, but does anyone know why the parser from dateutil fails to render the following hour correctly? (The hour should be 20 instead of 0.)

>>> from dateutil import parser
>>> parser.parse("20130501200439+01'00'")
datetime.datetime(2013, 5, 1, 0, 4, 39, tzinfo=tzoffset(None, 3600))

Add a T:

>>> parser.parse("20130501T200439+01'00'") # added T
datetime.datetime(2013, 5, 1, 0, 4, 39, tzinfo=tzoffset(None, 3600))

Add ignoretz:

>>> parser.parse("20130501T200439+01'00'", ignoretz=True) # ignore timezone
datetime.datetime(2013, 5, 1, 0, 4, 39)

Try a different hour:

>>> parser.parse("20130501T030439+01'00'") # should render hour as 3
datetime.datetime(2013, 5, 1, 0, 4, 39, tzinfo=tzoffset(None, 3600))

1 Answer 1

1

The parser doesn't seem to accept the form of tz data in the string. Removing the single quotes seems to work:

>>> parser.parse("20130501200439+01'00'".replace("'", ""))
datetime.datetime(2013, 5, 1, 20, 4, 39, tzinfo=tzoffset(None, 3600))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.