Convert CkDateTime to Delphi TDateTime

Question: Which is the best way to convert a CkDateTime to a Delphi TDateTime?

Answer: I didn’t know the answer, so I Googled “Delphi TDateTime” to see exactly what it is.  It brought me to this web page:

In Delphi, TDateTime is a type that maps to a Double. In C++, the TDateTime class corresponds to the Delphi TDateTime type.  

The integral part of a Delphi TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of the TDateTime value is fraction of a 24 hour day that has elapsed.

My experience tells me that anytime you see a date/time represented as a double, you have an OLE Date.  (Google “ole date format”)

The CkDateTime’s GetAsOleDate function returns an OLE date.  It should be just a matter of setting the Delphi TDateTime equal to the double returned by GetAsOleDate:

dt: HCkDateTime;
bLocal: Boolean;
// Delphi TDateTime (which is just a Double)
ddt: TDateTime;

dt := CkDateTime_Create();

bLocal := True;
ddt := CkDateTime_GetAsOleDate(dt,bLocal);