473,597 Members | 2,045 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Country specific date format

Hello,

with following function, i get a human readable date/time format.

mtime = time.strftime(s elf.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 4138
Franz Steinhaeusler wrote:
Hello,

with following function, i get a human readable date/time format.

mtime = time.strftime(s elf.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_langi nfo(locale.D_FM T) '%m/%d/%y' locale.setlocal e(locale.LC_ALL , 'de_DE')
locale.nl_langi nfo(locale.D_FM T)

'%d.%m.%Y'
--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
On Fri, 08 Oct 2004 13:28:04 +0200, "Diez B. Roggisch"
<de*********@we b.de> wrote:
Franz Steinhaeusler wrote:
Hello,

with following function, i get a human readable date/time format.

mtime = time.strftime(s elf.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_langi nfo(locale.D_FM T)'%m/%d/%y' locale.setlocal e(locale.LC_ALL , 'de_DE')
locale.nl_langi nfo(locale.D_FM T)

'%d.%m.%Y'


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

import locale
locale.nl_langi nfo(locale.D_FM T)
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*********@we b.de> wrote:

Franz Steinhaeusler wrote:

Hello,

with following function, i get a human readable date/time format.

mtime = time.strftime(s elf.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.set locale(locale.L C_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_langi nfo(locale.D_FM T)
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.i t> 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.c om (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
1805
by: josepe | last post by:
Greetings, How i can know the country of the visitor of the web? Thanks a lot.
2
3411
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: - Public Function HowManySpecificDays(StartDate As Date, EndDate As Date) As DayCounts and specifically the word "DayCounts" Can anyone help?
9
2054
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 additional code on my Postal/Zip Code field, using the fields "On Got Focus" event (Code Below) to manipulate the input mask. This procedure works well; however, I now wish to have a longer Value List of countries instead of using "Other", but I...
1
1235
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 then the format would be dd/mm/yyyy any help would be very much appriciated than you very much in advance Tan
4
5336
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 textbox. So I tried in the VB code the wizard generates Me.editDateOfBirth.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.objDSBoerneKirken, "tPersoner.DateOfBirth")) Me.editDateOfBirth.Location = New System.Drawing.Point(120, 604)
4
1571
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 disapears after the request is completed). But... asp.net "Request" is read only. Is there a request specific global place, where I can put this data into?
5
4059
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
12913
by: nitinkeser | last post by:
how i convert date into specific format in asp? like in date format 'Jun 17, 2007' ?
5
3664
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 does't matter online service or offline dll. It doesn't matter free or paid service. Please, help
0
7885
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8271
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8380
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6686
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5426
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2399
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1231
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.