RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TDateTime::TDateTime Constructor ()

Creates and initializes an instance of System::TDateTime::TDateTime.

Pascal
constructor Create;
constructor Create(const src: TDateTimeBase&);
constructor Create(const src: TDateTime&);
constructor Create(const src: double);
constructor Create(const src: Integer);
constructor Create(const src: System::String&; flag: TDateTimeFlag = DateTime);
constructor Create(year: unsigned short; month: unsigned short; day: unsigned short);
constructor Create(hour: unsigned short; min: unsigned short; sec: unsigned short; msec: unsigned short);
constructor Create(year: unsigned short; month: unsigned short; day: unsigned short; hour: unsigned short; min: unsigned short; sec: unsigned short; msec: unsigned short);
C++
__fastcall TDateTime();
__fastcall TDateTime(const TDateTimeBase& src);
__fastcall TDateTime(const TDateTime& src);
__fastcall TDateTime(const double src);
__fastcall TDateTime(const int src);
__fastcall TDateTime(const System::String& src, TDateTimeFlag flag = DateTime);
__fastcall TDateTime(unsigned short year, unsigned short month, unsigned short day);
__fastcall TDateTime(unsigned short hour, unsigned short min, unsigned short sec, unsigned short msec);
__fastcall TDateTime(unsigned short year, unsigned short month, unsigned short day, unsigned short hour, unsigned short min, unsigned short sec, unsigned short msec);

Use System::TDateTime::TDateTime to instantiate a System::TDateTime::TDateTime object. 

When called with no arguments, the resulting System::TDateTime::TDateTime object has a Val data member of zero. This date and time corresponds to 12/30/1899 12:00 am. 

When called with a System::TDateTime::TDateTime object as the src parameter, the resulting object is a copy of src (the copy constructor). 

When called with a System::TDateTime::TDateTimeBase object as the src parameter, the resulting object has the same value as the src parameter. System::TDateTime::TDateTimeBase is the base class for the System::TDateTime::TDateTime type. It has a single member, a public Val field that represents the value of the object. 

When called with a double or integer as the src parameter, the resulting object has the same value as the src parameter. The integral part of src is the number of days that have passed since 12/30/1899. The fractional part is the time of day, represented as a fraction of 24 hours. 

When called with an AnsiString as the src parameter and a System::TDateTime::TDateTimeFlag as the flag parameter, the resulting object’s value is converted from the AnsiString. The flag parameter indicates whether the string contains a date, a time, or both. The default for the flag is DateTime. 

When called with three unsigned shorts (as the year, month, and day parameters), the resulting object’s value is assembled from the specified year, month, and day, with a time portion of 0 (midnight). The year must be between 1 and 9999. Valid month values are 1 through 12. Valid day values are 1 through 28, 29, 30, or 31, depending on the month value. For example, the possible day values for month 2 (February) are 1 through 28 or 1 through 29, depending on whether or not the year value specifies a leap year. 

When called with four unsigned shorts (as the hour, min, sec, and msec parameters), the resulting object’s value represents a time based on the specified number of hours, minutes, seconds, and milliseconds past midnight. The date portion of the resulting value is 0 (12/30/1899). The hour must be between 0 and 23, the minute must be between 0 and 59, the second must be between 0 and 59, and the millisecond must be between 0 and 999.

Note: When the constructor calls for a conversion that can’t be performed (an AnsiString that does not represent a date or time, or invalid year, month, day, hour, min, sec, or msec value), an EConvertError exception is thrown.
 

 

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