These constructors create a new instance of a CTime object initialized with the specified absolute time
based on the current time zone.
CTime( );
CTime(
time_t time );
CTime(
int nYear,
int nMonth,
int nDay,
int nHour,
int nMin,
int nSec,
int nDST = –1 );
CTime(
WORD wDosDate,
WORD wDosTime, |
int nDST = –1 );
CTime(
const CTime& timeSrc );
CTime( const SYSTEMTIME& sysTime,
int nDST = –1 );
CTime( const FILETIME& fileTime,
int nDST = –1 )
Parameters
timeSrc
Indicates a CTime object that already exists.
time
Specifies a time_t time value, which is the number of seconds after January 1, 1970 UTC. Be aware that this will be adjusted to your local time. So if you create a CTime object by passing a parameter of 0, CTime::GetMonth will return 12 if you are in New York.
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. MFC for Windows CE only supports nDST set to a value less than 0, this is the default. It will automatically detect whether standard time or daylight savings time is in effect.
wDosDate, wDosTime
Specifies the MS-DOS date and time values to be converted to a date/time value and copied into the new CTime object.
sysTime
Specifies a SYSTEMTIME structure to be converted to a date/time value and copied into the new CTime object.
fileTime
Specifies a FILETIME structure to be converted to a date/time value and copied into the new CTime object.
Remarks
Each constructor is described below:
CTime( )
Constructs an uninitialized CTime object. This constructor allows you to define CTime object arrays. You should initialize such arrays with valid times prior to use.
CTime( time_t ), Constructs a CTime object from a time_t type.
CTime( const CTime& )
Constructs a CTime object from another CTime value.
CTime( int, int, etc.)
Constructs a CTime object from local time components with each component constrained to the following ranges: Component Range
nYear 1970–2999
nMonth 1–12
nDay 1–31
nHour no constraint
nMin no constraint
nSec no constraint
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 CTime FILETIME 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.
Example
// example for CTime::CTime
time_t osBinaryTime
// C run-time time (defined in <time.h>)
osBinaryTime = WCE_FCTN(time) (NULL)
// 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
Requirements
Windows CE versions: 1.0 and later
Header file: Declared in Afx.h
Platform: H/PC Pro, Palm-size PC, Pocket PC
See Also