[Python-Dev] Python strptime

Gustavo Niemeyer niemeyer@conectiva.com
Mon, 17 Jun 2002 20:45:15 -0300


> Well, since locale info is not directly accessible for time-specific
> things in Python (let alone in C in a standard way), I have to do multiple
> calls to strftime to get the names of the weekdays.  As for the strings
> representing locale-specifc date, time, and date/time representation I
> have to go through and figure out what the format of the output to extract
> the format string used by strftime to create the string. Since it is in
> pure Python and relies only on strftime and locale for its info, it works
> on all systems.  I have yet to have anyone say it doesn't work for them.
> I also think it is helpful to have that info available separately from
> strptime since locale does not provide it.

What kind of information are you looking for exactly? I'm not sure if
this is available in every paltform (it's standarized only by the
"Single UNIX Specification" acording to my man page), but depending on
this issue, everything you're looking for is there:

>>> locale.nl_langinfo(locale.D_FMT)

You could also try loading a translation catalog in the target system,
but that could be unportable as well.

Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]