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 » New SetDate for DateTimeCtrl
New SetDate for DateTimeCtrl [message #11332] Wed, 05 September 2007 21:50 Go to next message
dmcgeoch is currently offline  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 Go to previous messageGo to next message
mrjt is currently offline  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 #11634 is a reply to message #11338] Wed, 19 September 2007 21:59 Go to previous messageGo to next message
dmcgeoch is currently offline  dmcgeoch
Messages: 52
Registered: November 2006
Location: New Jersey
Member
Sorry for the delay in my response.

I tried using the various methods and while the date I was looking for was displayed in the control, it was not in the correct format and if I elected to display the CalendarCtrl the current date was highlighted, not the displayed date.

I've been trying various methods to update the Ctrl properly and in a cleaner method then I already used.

Something else to note is that the function

void Calendar::SetDate(const Date &dt)

does not set the selected date as expected.

Dave
Re: New SetDate for DateTimeCtrl [message #11815 is a reply to message #11634] Wed, 26 September 2007 17:42 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
As far as I can tell everything works as it should. What specifically is wrong with SetDate? A code snippet or compilable package would be helpful.

If the format is incorrect you can set like so:
	SetDateFormat("%3:02d/%2:02d/%1:4d");
	SetDateScan("dmy");
(changes the default from backwards American to 'normal' dd/mm/yyyy)

James
Re: New SetDate for DateTimeCtrl [message #11830 is a reply to message #11815] Wed, 26 September 2007 22:44 Go to previous message
dmcgeoch is currently offline  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 Embarassed 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

Previous Topic: Update to CalendarCtrl / TimeDateCtrl
Next Topic: DropTime problem
Goto Forum:
  


Current Time: Fri Mar 29 00:54:43 CET 2024

Total time taken to generate the page: 0.01715 seconds