Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've been tasked with converting old code created using Borland C++ Builder and creating something we can use again. I think I'm mostly on the right track except I'm stuck with some of the form stuff.

C++
double startTime = (int)(Form1->DatePickerStart->Date.Val) + Form1->ExtractDays(Form1->TimeEditStart->Text);


I'm having trouble figuring out what this double will look like. I tried just taking a date time and converting it to ticks but that didn't work.

Can anyone read this?

DatePickerStart is just a calendar date picker, and Time Edit Start is just a time selector. But converting the date to an int and adding the time converted to days and making it a double seems weird to me and I can't just picture what this is creating. An example would be helpful I think
Posted

Hi,

It has been a long time since I used the Borland compiler but I believe the double returned from the date picker was identical to the double within the COleDateTime[^].

Best Wishes,
-David Delaune
 
Share this answer
 
Comments
Espen Harlinn 29-Apr-12 12:54pm    
Right :-D
To convert to time_t (unix time)

http://msdn.microsoft.com/en-us/library/w4ddyt9h(v=vs.80).aspx[^]


TDateTime BorlandTime = somevalue;

time_t time_t_time = round((BorlandTime - 25569.0) * 86400);


25569 sets to Unix epoch 1/1/1970
86400 == seconds in day
 
Share this answer
 
Comments
Zebre 2-Apr-12 11:43am    
I ended up using your idea to create this function which worked for me.

double GetTimeTSecondsFrom(long ticks)
{
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return (new DateTime(ticks) - epoch).TotalSeconds;
}

Thanks for the help!
[no name] 2-Apr-12 19:12pm    
Glad it helped. You called it an idea but this is the exact conversion you asked for.
If it created a double, try converting that back into a datetime and see if the result is what you expect. The debugger will come in handy here.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900