CTime::CTime
CTime();
CTime(constCTime&timeSrc);
CTime(time_ttime**);**
CTime(intnYear**,intnMonth,intnDay,intnHour,intnMin,int**nSec, int nDST = -1 );
CTime(WORDwDosDate**,WORDwDosTime, int** nDST = -1 );
CTime(constSYSTEMTIME&sysTime, int nDST = -1 );
CTime(constFILETIME&fileTime, int nDST = -1 );
Parameters
timeSrc
Indicates a CTime object that already exists.
time
Indicates a time value.
nYear, nMonth, nDay, nHour, nMin, nSec
Indicates the date and time values to be copied into the new CTime object.
nDST
Indicates whether daylight savings time is in effect. Can have one of three values, as follows:
nDST set to 0 Standard time is in effect.
nDST set to a value greater than 0 Daylight savings time is in effect.
nDST set to a value less than 0 The default. Automatically computes whether standard time or daylight savings time is in effect.
wDosDate, wDosTime
MS-DOS date and time values to be converted to a date/time value and copied into the new CTime object.
sysTime
A SYSTEMTIME structure to be converted to a date/time value and copied into the new CTime object.
fileTime
A FILETIME structure to be converted to a date/time value and copied into the new CTime object.
Remarks
All these constructors create a new CTime object initialized with the specified absolute time, based on the current time zone.
Each constructor is described below:
CTime( ); Constructs an unitialized CTime object. This constructor allows you to define CTime object arrays. You should initialize such arrays with valid times prior to use.
CTime( const CTime& ); Constructs a CTime object from another CTime value.
CTime( time_t ); Constructs a CTime object from a time_t type.
CTime( int, int, etc.); Constructs a CTime object from local time components with each component constrained to the following ranges:
Component Range nYear 1970–2038* nMonth 1–12 nDay 1–31 nHour no constraint nMin no constraint nSec no constraint *The upper date limit is 1/18/2038. For a wider range of dates, see COleDateTime.
This constructor makes the appropriate conversion to UTC. The Debug version of the Microsoft Foundation Class Library asserts if one or more of the year, month, or day components is out of range. It is your responsibility to validate the arguments prior to calling.
CTime( WORD, WORD ); Constructs a CTime object from the specified MS-DOS date and time values.
CTime( const SYSTEMTIME& ); Constructs a CTime object from a SYSTEMTIME structure.
CTime( const FILETIME& ); Constructs a CTime object from a FILETIME structure. You most likely will not use CTimeFILETIME initialization directly. If you use a CFile object to manipulate a file, CFile::GetStatus retrieves the file time stamp for you via a CTime object initialized with a FILETIME structure.
For more information on the time_t data type, see the function in the Run-Time Library Reference.
For more information, see the and structure in the Win32 SDK Programmer’s Reference.
For more information, see the entry in the Win32 SDK documentation.
Example
// example for CTime::CTime
time_t osBinaryTime; // C run-time time (defined in <time.h>)
time( &osBinaryTime ) ; // Get the current time from the
// operating system.
CTime time1; // Empty CTime. (0 is illegal time value.)
CTime time2 = time1; // Copy constructor.
CTime time3( osBinaryTime ); // CTime from C run-time time
CTime time4( 1999, 3, 19, 22, 15, 0 ); // 10:15PM March 19, 1999
CTime Overview | Class Members | Hierarchy Chart
See Also CTime::GetTime, GetCurrentTime, operator =