MCS
0.3.3-alpha7
|
A class to hold date time information. More...
#include <mcs.hh>
Public Member Functions | |
DateTime () | |
Constructor. More... | |
void | now () |
Set the current datetime value. More... | |
operator string () const | |
Wrapper to sval(). More... | |
operator struct tm () const | |
Wrapper to tval(). More... | |
operator time_t () const | |
Wrapper to tval(). More... | |
DateTime & | operator= (time_t t) |
Wrapper to settval(time_t) More... | |
DateTime & | operator= (string s) |
Wrapper to setsval(string) More... | |
DateTime & | operator= (struct tm <m) |
Wrapper to settmval() More... | |
void | setMysqlBuffer (MYSQL_TIME *mysql) |
Set a pointer to a MYSQL_TIME structure. More... | |
void | setsval (string s) |
Parse a string to extract a datetime value. More... | |
void | setTimeMode (enum TimeMode tm) |
Set operational time mode. More... | |
void | settmval (struct tm <m) |
Assign a struct tm value. More... | |
void | settval (time_t t) |
Assign a time_t value. More... | |
string | sval () const |
Retrieve a string representation of the datetime value. More... | |
struct tm | tmval () const |
Retrieve a struct tm object. More... | |
time_t | tval () const |
Retrieve a time_t value. More... | |
Private Member Functions | |
time_t | getTime () const |
Return stored time. More... | |
void | to_MYSQL_TIME () |
Update linked MYSQL_TIME structure (if any) with internal value. More... | |
Static Private Member Functions | |
static const char * | parseTime (const char *s, struct tm *tm) |
Parse a string to extract datetime information. More... | |
Private Attributes | |
MYSQL_TIME * | mysql |
Pointer to linked MYSQL_TIME structure. More... | |
time_t | time |
Internal storage (seconds elapsed since 1970-01-01 00:00:00 UTC). More... | |
enum TimeMode | timemode |
Operational time mode. More... | |
A class to hold date time information.
This class can be used to store a datetime value. Data are internally stored as the number of seconds elapsed since 1970-01-01 00:00:00 UTC, that is as a time_t value.
This class is also able to perform conversions between different data type related to temporal information: time_t, struct tm and string representation of a datetime.
The setTimeMode() method can be used to specify if input values should be considered to be expressed in UTC or in local time zone.
A MYSQL_TIME structure can be linked with this class that will be automatically updated each time the DateTime object is updated and vice-versa.
|
private |
|
inline |
|
inline |
|
inline |
|
inline |
Wrapper to settval(time_t)
|
inline |
Wrapper to setsval(string)
|
inline |
Wrapper to settmval()
|
staticprivate |
void mcs::DateTime::setMysqlBuffer | ( | MYSQL_TIME * | mysql | ) |
void mcs::DateTime::setsval | ( | string | s | ) |
void mcs::DateTime::setTimeMode | ( | enum TimeMode | tm | ) |
Set operational time mode.
The time mode controls the behaviour of the DateTime object in the following cases:
When the UTC mode is used each value is expressed in UTC, if the LOCAL mode is used each value is expressed in local time zone.
void mcs::DateTime::settmval | ( | struct tm & | ltm | ) |
Assign a struct tm value.
Actually the only used fields are:
void mcs::DateTime::settval | ( | time_t | t | ) |
string mcs::DateTime::sval | ( | ) | const |
struct tm mcs::DateTime::tmval | ( | ) | const |
|
private |
time_t mcs::DateTime::tval | ( | ) | const |
|
private |
|
private |
|
private |
![]() |
MCS (My Customizable Server) ver. 0.3.3-alpha7
|