Microsoft Foundation Classes (mfc.hlp) (
Table of Contents;
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
class CTime
◄Up► ◄Contents► ◄Index► ◄Back►
──Microsoft Foundation Classes──────────────────────────────────────────────
Description
A CTime object represents an absolute time and date. The CTime class
incorporates the ANSI time_t data type and its associated run-time
functions, including the ability to convert to and from a Gregorian date
and 24-hour time.
CTime values are based on universal coordinated time (UCT), which is
equivalent to Greenwich mean time (GMT). The local time zone is
controlled by the TZ environment variable.
See the <Run-Time Library Reference> for more information on the time_t
data type and the run-time functions that are used by CTime.
A companion class, ◄CTimeSpan►, represents a time interval──the
difference between two CTime objects.
#include <afx.h>
See Also
Run-time functions: asctime, _ftime, gmtime, localtime, strftime, time
Derivation
The CTime and CTimeSpan classes are not designed for derivation. Because
there are no virtual functions, the size of CTime and CTimeSpan objects
is exactly 4 bytes. Most member functions are inline.
Public Members
Construction/Destruction
◄CTime► Constructs CTime objects in various ways.
◄GetCurrentTime► Creates a CTime object that represents the current
time (static member function).
Extraction
◄GetTime► Returns a time_t that corresponds to this CTime
object.
◄GetYear► Returns the year that this CTime object represents.
◄GetMonth► Returns the month that this CTime object represents (1
through 12).
◄GetDay► Returns the day that this CTime object represents (1
through 31).
◄GetHour► Returns the hour that this CTime object represents (0
through 23).
◄GetMinute► Returns the minute that this CTime object represents (0
through 59).
◄GetSecond► Returns the second that this CTime object represents (0
through 59).
◄GetDayOfWeek► Returns the day of the week (1 for Sunday, 2 for
Monday, and so forth).
Conversion
◄GetGmtTm► Breaks down a CTime object into components──based on
UCT.
◄GetLocalTm► Breaks down a CTime object into components──based on the
local time zone.
◄Format► Converts a CTime object into a formatted string──based on
the local time zone.
◄FormatGmt► Converts a CTime object into a formatted string──based on
UCT.
Operators
◄operator =► Assigns new time values.
◄operators +, -► Add and subtract CTimeSpan and CTime
objects.
◄operators +=, -=► Add and subtract a CTimeSpan object to and
from this CTime object.
◄operators ==, < , etc.► Compare two absolute times.
Archive/Dump
◄operator <<► Outputs a CTime object to CArchive or CDumpContext.
◄operator >>► Inputs a CTime object from CArchive.
-♦-