Petter
Petter

Reputation: 38624

Python dateutil parser fails

I am attempting to parse the following date strings obtained from email headers:

from dateutil import parser
d1 = parser.parse('Tue, 28 Jun 2011 01:46:52 +0200')
d2 = parser.parse('Mon, 11 Jul 2011 10:01:56 +0200 (CEST)')
d3 = parser.parse('Wed, 13 Jul 2011 02:00:01 +0000 (GMT+00:00)')

The third one fails; am I missing something obvious?

Upvotes: 3

Views: 4280

Answers (2)

phimuemue
phimuemue

Reputation: 35983

have you tried parser.parse('...', fuzzy=True)? (I suppose it works :))

Upvotes: 4

Michał Bentkowski
Michał Bentkowski

Reputation: 2145

Give a try to parsedatetime library.

In [16]: import parsedatetime.parsedatetime as pdt

In [17]: p = pdt.Calendar()

In [18]: p.parse("Wed, 13 Jul 2011 02:00:01 +0000 (GMT+00:00)")
Out[18]: ((2011, 7, 20, 0, 0, 0, 2, 201, -1), 3)

Upvotes: 2

Related Questions