Country specific date format

Anna Martelli Ravenscroft anna at aleax.it
Sun Oct 10 23:09:17 CEST 2004


Franz Steinhäusler wrote:
> 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
> 

I would look at dateutil. It has some pretty nifty stuff for handling 
timezones and locale-specific date issues...

HTH
Anna



More information about the Python-list mailing list