My idea was to display the date according to locale.
If locale is set to English the date will be format mm / dd / yy, if locale is set to Italian the date will be format dd / mm / yy and so on.
The code would be something like this:
b = wx,Locale(wx.LANGUAGE_ENGLISH)
#wx.Locale(wx.LANGUAGE_ITALIAN)
…
…
a = wx.DateTime.Today()
if b.GetLocale() = ‘italian’:
a.Format(’%d-%m-%Y’)
if b.GetLocale() = ‘english’;
a.Format(’%m-%d-%Y’)
There is no way to make this more automatic without controls?
My idea was to display the date according to locale.
If locale is set to English the date will be format mm / dd / yy, if
locale is set to Italian the date will be format dd / mm / yy and so on.
The code would be something like this:
b = wx,Locale(wx.LANGUAGE_ENGLISH) #wx.Locale(wx.LANGUAGE_ITALIAN)
...
...
a = wx.DateTime.Today()
if b.GetLocale() = 'italian':
a.Format('%d-%m-%Y')
if b.GetLocale() = 'english';
a.Format('%m-%d-%Y')
Is that actually from your code? I believe you meant ==, not = (syntax
errror).
Also, the locale is returned capitalised. Check for "Italian", not
"italian".
Anyway, use these methods:
ParseDateTime(self, datetime)
Identical to calling Format() with "%x" argument (which means 'preferred
date representation for the current locale').
ParseFormat(self, date, format, dateDef)
Identical to calling Format() with "%X" argument (which means 'preferred
time representation for the current locale')
Try wx.LANGUAGE_ENGLISH_US, some locales where English is spoken the day-first date is the accepted standard, so you need to get more specific. Also, there is the FormatDate method that does the same as Format('%x') but might be a little easier to remember.
···
On 7/21/10 3:10 AM, Fabio Spadaro wrote:
Anyway I tried
a = wx.Locale(wx.LANGUAGE_ENGLISH)
b = wx.DateTime.Today()
print b.Format("%x")
but the date is displayed in the format Italian(u'21/07/2010')
a = wx.Locale(wx.LANGUAGE_ENGLISH)
b = wx.DateTime.Today()
print b.Format("%x")
but the date is displayed in the format Italian(u’21/07/2010’)
Try wx.LANGUAGE_ENGLISH_US, some locales where English is spoken the day-first date is the accepted standard, so you need to get more specific. Also, there is the FormatDate method that does the same as Format(‘%x’) but might be a little easier to remember.