Home » U++ Library support » CalendarCtrl » New SetDate for DateTimeCtrl
New SetDate for DateTimeCtrl [message #11332] |
Wed, 05 September 2007 21:50 |
dmcgeoch
Messages: 52 Registered: November 2006 Location: New Jersey
|
Member |
|
|
Hello,
I found that I was constantly writing functions to take the string that was returned from the DateTimeCtrl and converting it back to the format understood by it. I added the following line to the DateTimeCtrl Class:
DateTimeCtrl& SetDate(String dte);
And added the following function definition:
DateTimeCtrl& DateTimeCtrl::SetDate(String dte)
{
int y,m,d;
y = atoi(dte.Left(4));
m = atoi(dte.Mid(5, 2));
d = atoi(dte.Right(2));
SetData(Date(y, m, d));
return *this;
}
I'm sure it not the most effective method, but it does work. Attached are the modified files.
|
|
|
Re: New SetDate for DateTimeCtrl [message #11338 is a reply to message #11332] |
Thu, 06 September 2007 11:19 |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
DateTimeCtrl::GetData actually returns a Date, which can of course then be converted to a string.
Date d = ~datetime;
String date_string = AsString(d);
...
datetime <<= d;
But even if you only have a String you can still set it directly:
datetime.SetText(date_string);
or
datetime <<= Scan(DATE_V, date_string);
These methods are also preferable because they use the global date format (see SetDateFormat & SetDateScan).
James
[Updated on: Thu, 06 September 2007 11:23] Report message to a moderator
|
|
|
|
|
Re: New SetDate for DateTimeCtrl [message #11830 is a reply to message #11815] |
Wed, 26 September 2007 22:44 |
dmcgeoch
Messages: 52 Registered: November 2006 Location: New Jersey
|
Member |
|
|
I'll put an example up later to demonstrate what I mean.
Dave
After multiple attempts to recreate the problem, I was unable to recreate the problem.
It's possible the original problem I have was with an earlier revision of Ultimate++. I am currently using 708-dev1 and the problem I had previously seems to be resolved. I am now using the StrToDate function before using the SetData(date) function.
Thank you for your help,
Dave
[Updated on: Fri, 28 September 2007 01:38] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Apr 26 00:11:42 CEST 2024
Total time taken to generate the page: 0.05247 seconds
|