Parsing date strings into tuples

Joonas Paalasmaa joonas at olen.to
Thu Feb 21 07:50:39 EST 2002


Question 1:
How can I parse date strings into tuples returned by localtime().
Date strings are in in some of the formats listed below.

'Wed, 20 Feb 2002 09:25:29 EET'
'Wed, Feb 20 2002 00:44:38 -0800'
'Wed, 20 Feb 2002 10:09:27 -0500 (EST)'

Question 2:
Why doesn't this work?

 >>> time.strptime('Wed, 20 Feb 2002 09:25:29 EET',
     "%a, %d %b %Y %H:%M:%S %Z")
Traceback (most recent call last):
   File "<pyshell#5>", line 1, in ?
     time.strptime('Wed, 20 Feb 2002 09:25:29 EET', "%a, %d %b %Y 
%H:%M:%S %Z")
ValueError: unconverted data remains: 'EET'




More information about the Python-list mailing list