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 » CalendarCtrl » DataTimeCtrl and format dd/mm/yyyy
DataTimeCtrl and format dd/mm/yyyy [message #9233] Sun, 22 April 2007 23:53 Go to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
Hi,

how to set the displayed date in dd/mm/yyyy?
I do not see a method to change the order of d,m,y.

Luigi
Re: DataTimeCtrl and format dd/mm/yyyy [message #9257 is a reply to message #9233] Tue, 24 April 2007 11:37 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
See Core/TimeDate.cpp. It looks like these should change the format for every date/string conversion:
void   SetDateFormat(const char *fmt);

Sets the format for date to string conversions (default: "%2:02d/%3:02d/%1:4d") and
void   SetDateScan(const char *scan);

Sets the format expected when doing string-date conversions (default: "mdy").


James

[Updated on: Tue, 24 April 2007 11:39]

Report message to a moderator

Re: DataTimeCtrl and format dd/mm/yyyy [message #9264 is a reply to message #9257] Tue, 24 April 2007 16:55 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1185
Registered: March 2006
Location: Italy
Senior Contributor
mrjt wrote on Tue, 24 April 2007 11:37

See Core/TimeDate.cpp. It looks like these should change the format for every date/string conversion:
void   SetDateFormat(const char *fmt);

Sets the format for date to string conversions (default: "%2:02d/%3:02d/%1:4d") and
void   SetDateScan(const char *scan);

Sets the format expected when doing string-date conversions (default: "mdy").

James


Thanks James,
Unfortunately those methods work very well with the date coming from GetSysTime(), but seems have no effect in the DateTimeCtrl in that it is diplayed the same format mm/dd/yyyy irrispective of their setting.
Perhaps I need to modify the control but before to try to do it I would like to be sure that there is no other methods available. This Ctrl is rather young so everything could not be present now.

Luigi
Re: DataTimeCtrl and format dd/mm/yyyy [message #9266 is a reply to message #9264] Tue, 24 April 2007 19:16 Go to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
Works perfectly for me.

Bear in mind that if you call SetDateFormat/Scan after you have entered a date into the Ctrl you won't see it change because it's stored internally as a WString. But if you change formats and then reopen the Calendar pop-up you can see that it has swapped formats correctly.

If you want the change the date format after dates have been entered you need to make sure the data gets parsed correctly:
SetDateFormat("%3:02d/%2:02d/%1:4d");
// Read using old format, then set using new format
date_field.SetData( date_field.GetData() );
SetDateScan("dmy");


James.

[Updated on: Tue, 24 April 2007 20:01]

Report message to a moderator

Previous Topic: DateTimeCtrl
Next Topic: DateTimeCtrl and format ddmmyyyy
Goto Forum:
  


Current Time: Fri Apr 19 21:52:59 CEST 2024

Total time taken to generate the page: 0.04430 seconds