Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
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.
 
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 28-Mar-12 7:25am
Zebre145
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Comments
Espen Harlinn at 29-Apr-12 12:54pm
   
Right :-D
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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
  Permalink  
Comments
Zebre at 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!
pwasser at 2-Apr-12 19:12pm
   
Glad it helped. You called it an idea but this is the exact conversion you asked for.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
v2

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



Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 28 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid