Country specific date format

  • Thread starter Franz Steinhaeusler
  • Start date
F

Franz Steinhaeusler

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.

Thank you in advance,
 
D

Diez B. Roggisch

Franz said:
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:
'%d.%m.%Y'
 
F

Franz Steinhäusler

You didn't look properly:

Hi Diez,

you are right :)
'%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
 
A

Anna Martelli Ravenscroft

Franz said:
Hi Diez,

you are right :)




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
 
F

Franz Steinhaeusler

[...]
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

Hello,

thanks,

did you mean "datetime" instead of "dateutil".
(I couldn't find a dateutil)
 
A

Alex Martelli

Franz Steinhaeusler said:
Hello,

thanks,

did you mean "datetime" instead of "dateutil".
(I couldn't find a dateutil)

(Hmmm, I'd better try to answer for her, she's flying USwards right now
and I'm not sure how good her newsgroup access will be for a while...!)

I think she really meant dateutil -- a wonderful 3rd party extension.
Google for it... it IS worth it (IMHO, and I believe in Anna's too:).


Alex
 
F

Franz Steinhaeusler

(Hmmm, I'd better try to answer for her, she's flying USwards right now
and I'm not sure how good her newsgroup access will be for a while...!)

I think she really meant dateutil -- a wonderful 3rd party extension.
Google for it... it IS worth it (IMHO, and I believe in Anna's too:).


Alex

thank you, I found it.

I will give it a try.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top