Changing Locale for datetime.strptime conversions

AlienBaby matt.j.warren at gmail.com
Tue Jul 6 05:55:25 EDT 2010


Hi,

I'm using datetime.strptime(string,format) to convert dates parsed
from a file into datetime objects.

However, the files come from various places around the world, and
strptime fails when non-english month names are used.

strptime says it converts month names using the current locales
version of the name.  I've looked into the locale module but can't see
how I would setup.change a locales date/time representations, I can
only see categories related to decimal number / currency
representations.

Can anyone show how I could change the locale such that strptime could
parse a date string that used say, German month names?

Thankyou



More information about the Python-list mailing list