usefullness of pythons' builtin locale functions on Windows
Gerhard Haering
gerhard.haering at gmx.de
Wed Aug 7 02:33:28 EDT 2002
In article <3d50ba69.89612046 at News.CIS.DFN.DE>, Gerson Kurz wrote:
> The documentation for strftime in the module time says
>
> %x Locale's appropriate date representation.
> %X Locale's appropriate time representation.
>
> I run W2k, with a german locale selected. (Which works in nearly all
> other programs I run). I'm using
>
> PythonWin 2.2.1 (#34, Apr 15 2002, 09:51:39) [MSC 32 bit (Intel)] on
> win32.
>
> So, I tried this:
>
>>>> import time
>>>> time.strftime( "%x %X" )
> '08/07/02 08:15:37'
>
> The date format is incorrect for german users, it uses MM/DD/YY where
> we would normally write DD.MM.YYYY. So, I look at module "locale"
>
>>>> import locale
>>>> locale.setlocale( locale.LC_ALL, "de" )
> Traceback (most recent call last):
> File "<interactive input>", line 1, in ?
> File "C:\Python22\lib\locale.py", line 372, in setlocale
> return _setlocale(category, locale)
> Error: locale setting not supported
>>> locale.setlocale(locale.LC_ALL, "GERMAN")
'German_Germany.1252'
>>> time.strftime("%x %X")
'07.08.2002 08:26:47'
>>>
I only know that specific "GERMAN" locale - I don't have any idea on where to
get a list of valid locales for Windows.
Gerhard
--
mail: gerhard <at> bigfoot <dot> de registered Linux user #64239
web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0
public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))
More information about the Python-list
mailing list