TDateTime = type Double;
class RTL_DELPHIRETURN TDateTime : public TDateTimeBase
The TDateTime class inherits a val data member--declared as a double--that holds the date-time value. The integral part of a TDateTime value is the number of days that have passed since December 30, 1899. The fractional part of a TDateTime value is the time of day. The maximal correct date supported by TDateTime values is limited to 12/31/9999 23:59:59:999. All values that go beyond this date cause errors and exceptions in most routines that operate with TDateTime values.
The following table displays examples of TDateTime values and their corresponding dates and times:
|0||December 30, 1899; 12:00 A.M.|
|2.75||January 1, 1900; 6:00 P.M.|
|-1.25||December 29, 1899; 6:00 A.M.|
|35065||January 1, 1996; 12:00 A.M.|
To find the fractional number of days between two dates, simply subtract the two values, unless one of the TDateTime values is negative. Similarly, to increment a date and time value by a certain fractional number of days, add the fractional number to the date and time value if the TDateTime value is positive.
The DateUtils unit has several APIs (such as DaysBetween, HoursBetween, WeeksBetween, etc) that are better APIs for calculating the time between two TDateTime, and these APIs work whether the underlying double is negative or positive.
When working with negative TDateTime values, computations must handle time portion separately. The fractional part reflects the fraction of a 24-hour day without regard to the sign of the TDateTime value. For example, 6:00 A.M. on December 29, 1899 is –1.25, not –1 + 0.25, which would equal –0.75. Dates greater than -1.0 up to 0.0, and dates less than 1.0 down to 0.0, mirror each other. That's because +ve zero and -ve zero are equal.
The following stream operators are defined:
ostream& operator << (ostream& os, const TDateTime& arg); istream& operator >> (istream& is, TDateTime& arg);