473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Country specific date format

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
6 4114
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: josepe | last post by:
Greetings, How i can know the country of the visitor of the web? Thanks a lot.
2
by: David Mitchell | last post by:
I have tried using the following code to count the specific number of each weekday but get a compile error "User defined type not defined" which I think relates to the first line of the function: -...
9
by: Dave Brydon | last post by:
Access 2003: I currently apply my Postal/Zip Code Format based off the Country Selected; the way I do it is by checking on the country; using the forms "On Current" event procedure, then I use...
1
by: Tan | last post by:
I would like to have a a text box for users to enter the date format according to the country where they are, let's say if users are in USA the format would be dd/mm/yyyy and if the users in UK...
4
by: Jan Nielsen | last post by:
Hi I have a dataform that shows a date from a MSDE 2000 in a textbox. It uses the format: dd-mm-yyyy hh:mm:ss It would it to use the format dd-mm-yyyy But I can't find a Format property for the...
4
by: Nalaka | last post by:
Hi, I have some request specific data that gets created in a "early event", that I need to pass around to many other events. I need access to this data during that request. (and more importantly...
5
by: webrod | last post by:
Hi, I'm new to DB2. Is there a way to know the date format of the DB2 instance from a SQL query? I guess the date format or the country code is stored in a system table? which one? thanks
1
by: nitinkeser | last post by:
how i convert date into specific format in asp? like in date format 'Jun 17, 2007' ?
5
by: alexandrus | last post by:
Hello, I have a problem. I have a email stored in database in fields (e.g. AddressLine1, Postal Code, Zip .. e.t.c.) I need a solution to display address to user in selected country format. It...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.