Parsing a date-time string?

Tim N. van der Leeuw tim.leeuwvander at nl.unisys.com
Wed Dec 21 04:43:13 EST 2005


Hi,

I want to parse strings containing date-time, which look like the
following:

 "Mon Dec 19 11:06:12:333 CET 2005"

That's a problem for strptime it seems, b/c I cannot find any
format-spec for the milliseconds-part in here. (I'm also not sure about
the validity of the tz part, but ...)

As an aside, the dates are all in english while my PC might have a
dutch locale -- not even sure about what Python would consider the
current locale.
So that's an extra obstacle to parsing these dates.

The datetime module doesn't seem to provide a better solution either.

What I want to get is some sort of sortable date; either as a number or
(if nothing else) as a string in ISO8601 format.
(But I want to avoid doing too many string manipulations on my input
dates; and changing the dateformat of the input-source will be hard if
at all justifiable.)


Any help is appreciated.

Cheers,

--Tim




More information about the Python-list mailing list