Jerry Dodge
Jerry Dodge

Reputation: 27276

Can TDateTime be used in a DLL for other languages to use?

The TDateTime in Delphi is represented as a Double type. I need to export this in a DLL to be used in other languages (such as C#, C++, Java...). Is the TDateTime (represented as a Double in Delphi) compatible with other languages? (Do they recognize Double types as a date/time?) Or do I need to convert it to a string when exporting and convert it on each end?

Upvotes: 1

Views: 490

Answers (1)

Ken White
Ken White

Reputation: 125669

Languages other than Delphi will accept a Double as a floating point value, but will not understand that it's intended to represent a date or time value. A TDateTime is simply a means that Delphi uses to refer to a point in time; it's compatible with COM-based dates in the sense that it is used to refer to a point in time that has an origin of 12/30/1899 00:00:00 (the equivalent of a TDateTime variable initialized to 0).

If you want other languages to understand it as a date value, you'll need to either convert it to a string or document it as being a reference from that point in time and expect the other language to use it appropriately.

Upvotes: 5

Related Questions