Bug in module time: localization?

Berthold Höllmann bhoel at starship.python.net
Sun Mar 26 14:55:46 EST 2000


"hartmut Goebel" <hartmut at oberon.noris.de> writes:

> Hello,
> 
> python 1.5.2 seams to ignore locale setting when generating names of month of
> weekday. Below find a test skript which always print english names ("Monday
> March") instead of german ones ("Montag März").
> 
> The shell command 'date "+%A %B"' returns the expected result: localized.
> 
> Does anyone have an idea how to solve this problem?
> 
Hello Hartmut,

Try something like:

>python
Python 1.5.2 (#2, Apr 22 1999, 14:34:42)  [GCC egcs-2.91.66 19990314 (egcs-1.1.2  on linux2
Copyright 1991-1995 Stichting Mathematisch
>>> import os, time
>>> testTime = (2000, 03, 11, 0, 0, 0, 0, 0, 0)
>>> def testDate(env, value):
...     os.environ[env] = value
...     print "%-10s:\t%s\t\t" % (env, os.environ[env]),
...     print time.strftime("%A %B", testTime)
... 
>>> testDate('LANG', 'de_DE')
LANG      :     de_DE           Monday March
>>> import locale
>>> locale.setlocale (locale.LC_ALL,"")
'de_DE'
>>> testDate('LANG', 'de_DE')
LANG      :     de_DE           Montag März
>>> 

Cheers

Berthold
-- 
bhoel at starship.python.net / http://starship.python.net/crew/bhoel/
        It is unlawful to use this email address for unsolicited ads
        (USC Title 47 Sec.227). I will assess a US$500 charge for
        reviewing and deleting each unsolicited ad.



More information about the Python-list mailing list