#include <mcs.hh>
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.
Definition at line 2880 of file mcs.hh.
Public Member Functions | |
DateTime () | |
Constructor. | |
void | now () |
Set the current datetime value. | |
operator string () const | |
Wrapper to sval(). | |
operator struct tm () const | |
Wrapper to tval(). | |
operator time_t () const | |
Wrapper to tval(). | |
DateTime & | operator= (struct tm <m) |
Wrapper to settmval(). | |
DateTime & | operator= (string s) |
Wrapper to setsval(string). | |
DateTime & | operator= (time_t t) |
Wrapper to settval(time_t). | |
void | setMysqlBuffer (MYSQL_TIME *mysql) |
Set a pointer to a MYSQL_TIME structure. | |
void | setsval (string s) |
Parse a string to extract a datetime value. | |
void | setTimeMode (enum TimeMode tm) |
Set operational time mode. | |
void | settmval (struct tm <m) |
Assign a struct tm value. | |
void | settval (time_t t) |
Assign a time_t value. | |
string | sval () const |
Retrieve a string representation of the datetime value. | |
struct tm | tmval () const |
Retrieve a struct tm object. | |
time_t | tval () const |
Retrieve a time_t value. | |
Private Member Functions | |
time_t | getTime () const |
Return stored time. | |
void | to_MYSQL_TIME () |
Update linked MYSQL_TIME structure (if any) with internal value. | |
Static Private Member Functions | |
static const char * | parseTime (const char *s, struct tm *tm) |
Parse a string to extract datetime information. | |
Private Attributes | |
MYSQL_TIME * | mysql |
Pointer to linked MYSQL_TIME structure. | |
time_t | time |
Internal storage (seconds elapsed since 1970-01-01 00:00:00 UTC). | |
enum TimeMode | timemode |
Operational time mode. |
time_t mcs::DateTime::getTime | ( | ) | const [private] |
mcs::DateTime::operator string | ( | ) | const [inline] |
mcs::DateTime::operator struct tm | ( | ) | const [inline] |
mcs::DateTime::operator time_t | ( | ) | const [inline] |
DateTime& mcs::DateTime::operator= | ( | struct tm & | ltm | ) | [inline] |
DateTime& mcs::DateTime::operator= | ( | string | s | ) | [inline] |
DateTime& mcs::DateTime::operator= | ( | time_t | t | ) | [inline] |
const char * mcs::DateTime::parseTime | ( | const char * | s, | |
struct tm * | tm | |||
) | [static, private] |
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 [read] |
void mcs::DateTime::to_MYSQL_TIME | ( | ) | [private] |
time_t mcs::DateTime::tval | ( | ) | const |
MYSQL_TIME* mcs::DateTime::mysql [private] |
time_t mcs::DateTime::time [private] |
enum TimeMode mcs::DateTime::timemode [private] |
![]() |
MCS (My Customizable Server) ver. 0.3.3-alpha3
|