System.TDateTime.Create

From RAD Studio API Documentation
Jump to: navigation, search

C++

__fastcall TDateTime()                                  {Val = 0;}
__fastcall TDateTime(const TDateTimeBase& src)          {Val = src.Val;}
__fastcall TDateTime(const double src)                  {Val = src;}
__fastcall TDateTime(const int src)                     {Val = 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);

Properties

Type Visibility Source Unit Parent
constructor public systdate.h System TDateTime

Description

Creates and initializes an instance of TDateTime.

Use TDateTime to instantiate a TDateTime object.

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

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

When called with a TDateTime Base object as the src parameter, the resulting object has the same value as the src parameter. TDateTimeBase is the base class for the 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 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 from 1 through 9999. Valid month values are from 1 through 12. Valid day values are from 1 through 28, 29, 30, or 31, depending on the month value. For example, the possible day values for month 2 (February) are from 1 through 28 or from 1 through 29, depending on whether 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 from 0 through 23, the minute must be from 0 through 59, the second must be from 0 through 59, and the millisecond must be from 0 through 999.

Note: When the constructor calls for a conversion that cannot 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.

See Also