RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TDateTime Class

System::TDateTime is the C++ analog for the Delphi System::TDateTime data type.

Pascal
TDateTime = class(TDateTimeBase);
C++
class TDateTime : public TDateTimeBase;

System::TDateTime implements the Delphi System::TDateTime data type and the date/time runtime library routines that use the System::TDateTime data type. 

The System::TDateTime class inherits a val data member declared as a double that holds the date-time value. The integral part of a System::TDateTime value is the number of days that have passed since 12/30/1899. The fractional part of a System::TDateTime value is the time of day. 

Following are some examples of System::TDateTime values and their corresponding dates and times: 

0 12/30/1899 12:00 am 

2.75 1/1/1900 6:00 pm 

-1.25 12/29/1899 6:00 am 

35065 1/1/1996 12:00 am 

To find the fractional number of days between two dates, simply subtract the two values, unless one of the System::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 System::TDateTime value is positive.  

When working with negative System::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 System::TDateTime value. For example, 6:00 am on 12/29/1899 is –1.25, not –1 + 0.25, which would be –0.75. There are no System::TDateTime values between –1 and 0.

Note: Use only the operators declared by System::TDateTime. The compiler ignores any operators you overload yourself.
Warning: It is not possible to use System::TDateTime as a base class for inheriting. To add functionality to System::TDateTime, you must write a wrapper class.
Note: To utilize the C++ streaming operators (<< and >>) with Currency, you must use #include <iostream> before #include <systdate.h>. This occurs automatically if you include vcl.h, clx.h, or System.hpp. The following stream operators are defined:
ostream& operator << (ostream& os, const System::TDateTime& arg); 

istream& operator >> (istream& is, System::TDateTime& arg); 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!