Share via


COleDateTime::COleDateTime

COleDateTime( );
COleDateTime( const COleDateTime& dateSrc );
COleDateTime( const VARIANT& varSrc );
COleDateTime( DATE dtSrc );
COleDateTime( time_t timeSrc );
COleDateTime( const SYSTEMTIME& systimeSrc );
COleDateTime( const FILETIME& filetimeSrc );
COleDateTime( int nYear**, int** nMonth**, int** nDay**, int** nHour**, int** nMin**, int** nSec );
COleDateTime( WORD wDosDate**, WORD** wDosTime );

Parameters

dateSrc

An existing COleDateTime object to be copied into the new COleDateTime object.

varSrc

An existing VARIANT data structure (possibly a COleVariant object) to be converted to a date/time value (VT_DATE) and copied into the new COleDateTime object.

dtSrc

A date/time (DATE) value to be copied into the new COleDateTime object.

timeSrc

A time_t value to be converted to a date/time value and copied into the new COleDateTime object.

systimeSrc

A SYSTEMTIME structure to be converted to a date/time value and copied into the new COleDateTime object.

filetimeSrc

A FILETIME structure to be converted to a date/time value and copied into the new COleDateTime object.

nYear, nMonth, nDay, nHour, nMin, nSec

Indicate the date and time values to be copied into the new COleDateTime object.

wDosDate, wDosTime

MS-DOS date and time values to be converted to a date/time value and copied into the new COleDateTime object.

Remarks

All of these constructors create new COleDateTime objects initialized to the specified value. The following table shows valid ranges for each date and time component:

Date/Time Component Valid Range
year 100 – 9999
month 0 – 12
day 0 – 31
hour 0 – 23
minute 0 – 59
second 0 – 59

Note that the actual upper bound for the day component varies based on the month and year components. For details, see the SetDate or SetDateTime member functions.

Following is a brief description of each constructor:

  • COleDateTime()   Constructs a COleDateTime object initialized to 0 (midnight, 30 December 1899).

  • COleDateTime(dateSrc)   Constructs a COleDateTime object from an existing COleDateTime object.

  • COleDateTime(varSrc)   Constructs a COleDateTime object. Attempts to convert a structure or COleVariant object to a date/time (VT_DATE) value. If this conversion is successful, the converted value is copied into the new COleDateTime object. If it is not, the value of the COleDateTime object is set to 0 (midnight, 30 December 1899) and its status to invalid.

  • COleDateTime(dtSrc)   Constructs a COleDateTime object from a DATE value.

  • COleDateTime(timeSrc)   Constructs a COleDateTime object from a time_t value.

  • COleDateTime(systimeSrc)   Constructs a COleDateTime object from a SYSTEMTIME value.

  • COleDateTime(filetimeSrc)   Constructs a COleDateTime object from a FILETIME value.

  • COleDateTime(nYear, nMonth, nDay, nHour, nMin, nSec)   Constructs a COleDateTime object from the specified numerical values.

  • COleDateTime(wDosDate, wDosTime)   Constructs a COleDateTime object from the specified MS-DOS date and time values.

For more information, see the entry in the Win32 SDK OLE Programmer's Reference.

For more information on the time_t data type, see the function in the Run-Time Library Reference.

For more information, see the and structures in the Win32 SDK documentation.

For more information on MS-DOS date and time values, see in the Win32 SDK documentation.

For more information about the bounds for COleDateTime values, see the article in Visual C++ Programmer’s Guide.

Example

time_t osBinaryTime;   // C run-time time (defined in <time.h>)
time(&osBinaryTime);   // Get the current time from the
                     // operating system.

COleDateTime time1;   // initialized to 00:00am, 30 December 1899
                     // (and m_nStatus is valid!)

COleDateTime time2 = time1; // Copy constructor
COleDateTime time3(osBinaryTime)   // from time_t
COleDateTime time4( 1999, 3, 19, 22, 15, 0 ); // 10:15PM March 19, 1999

SYSTEMTIME sysTime;   // Win32 time information
GetSystemTime(&sysTime);

COleDateTime time5(sysTime);

COleDateTime OverviewClass MembersHierarchy Chart

See Also   COleDateTime::SetDate, COleDateTime::SetDateTime, COleDateTime::SetTime, COleDateTime::GetStatus, COleDateTime::operator =, COleDateTime::m_dt, COleDateTime::m_status