By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,426 Members | 1,721 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,426 IT Pros & Developers. It's quick & easy.

Country specific date format

P: n/a
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,

--
Franz Steinhaeusler
Jul 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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:
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'
--
Regards,

Diez B. Roggisch
Jul 18 '05 #2

P: n/a
On Fri, 08 Oct 2004 13:28:04 +0200, "Diez B. Roggisch"
<de*********@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/
Jul 18 '05 #3

P: n/a
Franz Steinhäusler wrote:
On Fri, 08 Oct 2004 13:28:04 +0200, "Diez B. Roggisch"
<de*********@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
Jul 18 '05 #4

P: n/a
On Sun, 10 Oct 2004 21:09:17 GMT, Anna Martelli Ravenscroft
<an**@aleax.it> wrote:
[...]
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)
--
Franz Steinhaeusler
Jul 18 '05 #5

P: n/a
Franz Steinhaeusler <fr*****************@utanet.at> wrote:
...
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)


(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
Jul 18 '05 #6

P: n/a
On Tue, 12 Oct 2004 09:17:12 +0200, al*****@yahoo.com (Alex Martelli)
wrote:
Franz Steinhaeusler <fr*****************@utanet.at> wrote:
...
>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)


(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.

--
Franz Steinhaeusler
Jul 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.