vtdata library
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
vtTime Class Reference

Public Member Functions

void SetDate (int year, int month, int day)
void GetDate (int &year, int &month, int &day) const
void SetTimeOfDay (int hr, int min, int sec)
void GetTimeOfDay (int &hr, int &min, int &sec) const
int GetSecondOfDay () const
time_t GetTime () const
const tm & GetTM () const
void Increment (int secs)
bool SetFromString (const vtString &str)
vtString GetAsString ()
void GetSystemTime ()

Protected Member Functions

void _UpdateTM ()

Protected Attributes

tm m_tm
time_t m_time

Detailed Description

This class encapsulates time (in increments of whole seconds.)

Time is stored both as a time_t value (integer seconds) and as a tm structure (year, month, day, hour, minute, second). The two values are kept in synch.

Implementation notes: The functions mktime() and localtime() are used to convert between time_t and tm. Although it seems as if this operating on "local" time, it isn't really; it is just a time value. These functions are used because they are the only bidirectional conversion functions exposed by the ANSI C library - the gmtime() function converts time_t to tm more directly, but there is no corresponding method to convert directly from tm to time_t.

Member Function Documentation

void vtTime::SetDate ( int  year,
int  month,
int  day 

Set the date components of a vtTime value.

yearE.g. 2001.
monthin the range of 1 to 12.
dayin the range of 1 to 31.