Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » Formating date according to the country
Formating date according to the country [message #21016] Sat, 25 April 2009 17:16 Go to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Hello,

I am using a SQLite3 database. To the best of my knowledge, SQLite database stores al dates in the form:

'2009-04-17'

or

'YYYY-MM-DD'

right?

So, to get the date from the database and show it in an arrays control or label i do:

Date dtDate=Date(SQL[8]);
String strDate=Format("%2.2d-%2.2d-%2.2d",
dtDate.day,dtDate.month,dtDate.year);

But this statically formats date in DD-MM-YYYY format.

So, how can i format a date according to a specific country language or according to the operating system format?

Many tanks

Alex



I am geting
Re: Formating date according to the country [message #21064 is a reply to message #21016] Wed, 29 April 2009 20:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
AFAIK, Sqlite3 does not have any predefined date format - what we store is just choosen text interpretation.

Anyway, that is not the question:)

To format Date in local format, just use AsString(date).

Anyway, you should set your language first using SetLanguage.

Mirek
Re: Formating date according to the country [message #21067 is a reply to message #21064] Thu, 30 April 2009 13:49 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

SQLite is now properly supports the date field.

At least in your schema, I define the date field, and more, all works fine.

To access the SQLite tables I'm using plugin for firefox.

It shows the normal date field is automatically created by U++

index.php?t=getfile&id=1703&private=0


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: Formating date according to the country [message #21068 is a reply to message #21067] Thu, 30 April 2009 14:08 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Yes. Anyway, AFAIK Sqlite just stores the type of column as text. It does not use it to evaluate expression and date is just stored as text.

In practice, it means that (given current format), basic DATE comparisons in SQL will work, but no DATE arithmetics seems to be possible.

Mirek
Re: Formating date according to the country [message #21080 is a reply to message #21068] Sat, 02 May 2009 10:01 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
But it seems not working:


SetLanguage(LNG_('P', 'T', 'P', 'T'));
Date dtData=GetSysDate();
String strData=AsString(dtData);
Exclamation(strData);


This shows 5/2/2009 but in the Portuguese language countries dates are presented liike this 2/5/2009 (DD/MM/YYYY)


Thanks

Alex
Re: Formating date according to the country [message #21086 is a reply to message #21080] Sun, 03 May 2009 16:47 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello alex100

I would use:

SetLanguage(LNGC_('P','T','P','T', CHARSET_UTF8));
SetDateFormat("%3:02d/%2:02d/%1:4d");
SetDateScan("dmy");

Best regards
Koldo


Best regards
Iñaki
Re: Formating date according to the country [message #21093 is a reply to message #21086] Sun, 03 May 2009 19:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Yes, PT-PT is not yet translated. Date formatting/scanning strings are normally part ot language translation.

I have updated translation tutorial

http://www.ultimatepp.org/srcdoc$Core$Translating$en-us.html

you migth be interested in providing PT-PT translation for us.

Mirek
Re: Formating date according to the country [message #21124 is a reply to message #21093] Mon, 04 May 2009 12:45 Go to previous messageGo to next message
kbyte is currently offline  kbyte
Messages: 87
Registered: July 2008
Member
No Message Body

[Updated on: Mon, 04 May 2009 13:57]

Report message to a moderator

Re: Formating date according to the country [message #21127 is a reply to message #21124] Mon, 04 May 2009 13:58 Go to previous messageGo to next message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
luzr wrote on Sun, 03 May 2009 19:06

Yes, PT-PT is not yet translated. Date formatting/scanning strings are normally part ot language translation.

I have updated translation tutorial

http://www.ultimatepp.org/srcdoc$Core$Translating$en-us.html

you migth be interested in providing PT-PT translation for us.

Mirek



Hi, I think I cant provide date format by burning it on the source code because I want my application compliant with internationalization, which means that, if it is executed on France, it gets the format from the underlying SO or something and show dates in french format. If I burn the format then the format is always the same Sad


Another option id to ask for the user (on the first app launch) the choosed date format and then respect it always.


Of course I am interested in helping you with PT translations!
As you may know Portuguese is one of the most spoken languages into the world. From europe to asia, africa, south america and near Autralia (East Timor)

As you also may know, I not yet a upp pro (but i want to be!) so you have to guide me how can I help you on translations.

Thank you

Alex

Re: Formating date according to the country [message #21130 is a reply to message #21127] Mon, 04 May 2009 14:11 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello alex100

The translation is really very simple. Just follow the link instructions. If you have any doubt just ask.

Best regards
Koldo


Best regards
Iñaki
Re: Formating date according to the country [message #21131 is a reply to message #21130] Mon, 04 May 2009 14:17 Go to previous message
alex100 is currently offline  alex100
Messages: 118
Registered: November 2007
Experienced Member
Ok,
I got it now!

I will translate it and submit it when ready!

Thanks


Alex


Previous Topic: a dll usage failure
Next Topic: Help needed to set the focus
Goto Forum:
  


Current Time: Thu Mar 28 22:16:19 CET 2024

Total time taken to generate the page: 0.01057 seconds