Country specific date format

Franz Steinhäusler franz.steinhaeusler at utanet.at
Fri Oct 8 21:46:36 CEST 2004


On Fri, 08 Oct 2004 13:28:04 +0200, "Diez B. Roggisch"
<deetsNOSPAM at web.de> wrote:

>Franz Steinhaeusler wrote:
>
>> Hello,
>> 
>> with following function, i get a human readable date/time format.
>> 
>> mtime = time.strftime(self.timeformat ,time.localtime(st.st_mtime))
>> 
>> However is there a simple solution to get a country specific format:
>> for example
>> 10/08/2004
>> 
>> and for German:
>> 08.10.2004
>> 
>> I looked in locale class, but I didn't get more wise.
>
>You didn't look properly:

Hi Diez,

you are right :)

>
>>>> locale.nl_langinfo(locale.D_FMT)
>'%m/%d/%y'
>>>> locale.setlocale(locale.LC_ALL, 'de_DE')
>>>> locale.nl_langinfo(locale.D_FMT)
>'%d.%m.%Y'

thanks for answering, I have windows XP,
and it seems, this method doesn't exist:

import locale
locale.nl_langinfo(locale.D_FMT)
Traceback (most recent call last):
  File "<input>", line 1, in ?
AttributeError: 'module' object has no attribute 'nl_langinfo'
WinXP, Python 2.3.3

from the doc:
nl_langinfo( option) 

Return some locale-specific information as a string. This function is
not available on all systems, and the set of possible options might
also vary across platforms. The possible argument values are numbers,
for which symbolic constants are available in the locale module. 

is there any possibility ( please WITHOUT the win32 extensions and
other extra package except for wxPython ;) )
to discover the date/time country specific string?

regards

-- 

Franz Steinhaeusler
DrPython: http://drpython.sourceforge.net/
Project Page: http://sourceforge.net/projects/drpython/



More information about the Python-list mailing list