#include <cel_time.h>
Public Member Functions | |
Time (std::time_t _t=0) | |
Time (const Time &_time) | |
Time (const String &time) | |
Time (const std::tm *_tm) | |
Time (size_t year, size_t month, size_t day, size_t hour=0, size_t minute=0, size_t seconds=0, bool isUTC=false) | |
Time & | operator= (std::time_t _t) |
Time & | operator= (const Time &_time) |
Time & | operator= (const std::tm *_tm) |
Time & | operator= (const String &time) |
void | gmtime (std::tm *out_tm) const |
void | localtime (std::tm *out_tm) const |
String | strftime (const String &format) const |
bool | operator< (const Time &r) const |
bool | operator<= (const Time &r) const |
bool | operator> (const Time &r) const |
bool | operator>= (const Time &r) const |
bool | operator== (const Time &r) const |
bool | operator!= (const Time &r) const |
ssize_t | operator- (const Time &r) const |
Time | operator+ (ssize_t diff) const |
String | ctime () const |
String | getRFC822timeString (bool isLocalTime=true) const |
void | parseDateString (const String &inDateString) |
void | serialize (Stream *inStream, size_t inLevel, Endian inEndian) const |
void | deserialize (Stream *inStream, size_t inLevel, Endian inEndian) |
String | toGMTStr () const |
Static Public Member Functions | |
static Time | getCurrentTime () |
static Time | mktime (const std::tm *_tm) |
static Time | timelocal (const std::tm *_tm) |
static Time | timegm (const std::tm *_tm) |
static Time | createTime (size_t year, size_t month, size_t day, size_t hour=0, size_t minute=0, size_t seconds=0, bool isUTC=false) |
static Time | fromGMTStr (const String &inGMTStr) |
Public Attributes | |
std::time_t | t |
Time class wraps the standard C time_t
and provides some utility functions.
|
inline |
This constructor initializes the time_t value by the specified value.
_t | The time_t value. |
Referenced by operator+().
|
inline |
This constructor duplicates the Time instance.
_time | The instance to duplicate. |
|
inline |
This constructor parses the specified string and initialize the instance by it.
time | A string that holds a valid date-time. |
|
inline |
This constructor converts the specified std::tm
value into std::time_t
and initialize the instance by it.
_tm | Pointer to a std::tm variable. |
|
inline |
This constructor converts the specified date-time into std::time_t
and initialize the instance by it.
year | Year. To specify 2005, set 2005 to this. |
month | Month. January is 1. |
day | Day of the month. 1st is 1. |
hour | Hour in 0 - 23. |
minute | Minute in 0 - 59 |
seconds | Seconds in 0 - 60 (in some special case, 60 is meaningful.) |
bool | isUTC Whether the time is specified in UTC or not. true to translate time as UTC; otherwise as localtime. |
|
static |
This constructor converts the specified date-time into std::time_t
and initialize the instance by it.
year | Year. To specify 2005, set 2005 to this. |
month | Month. January is 1. |
day | Day of the month. 1st is 1. |
hour | Hour in 0 - 23. |
minute | Minute in 0 - 59 |
seconds | Seconds in 0 - 60 (in some special case, 60 is meaningful.) |
bool | isUTC Whether the time is specified in UTC or not. true to translate time as UTC; otherwise as localtime. |
Referenced by Time().
String Celartem::Time::ctime | ( | ) | const |
This methods is identical to ANSI C ctime except it removes trailing '\n'.
This method is just a helper function to deal with SerializableData template. For more information, see SerializableData.
This method returns the time in UTC from "YYYY-MM-DD hh:mm:ss"
format.
|
static |
This method gets the current time.
String Celartem::Time::getRFC822timeString | ( | bool | isLocalTime = true | ) | const |
This method outputs string like "Mon, 13 Oct 2003 02:29:48 +0900"
.
isLocalTime | Whether the output string is in local time or not. |
void Celartem::Time::gmtime | ( | std::tm * | out_tm | ) | const |
This method converts the time to std::tm
in UTC.
out_tm | Pointer to the buffer that receives the std::tm value. |
void Celartem::Time::localtime | ( | std::tm * | out_tm | ) | const |
This method converts the time to std::tm
in localtime.
out_tm | Pointer to the buffer that receives the std::tm value. |
|
static |
This method gets the specified time (in localtime).
_tm | Pointer to a std::tm value. |
Referenced by operator=(), Time(), and timelocal().
|
inline |
This method compares the time with the specified time.
true
if the time is not equal to the specified time value, otherwise return false
.
|
inline |
This method calculates the time of diff seconds later from the time.
ssize_t Celartem::Time::operator- | ( | const Time & | r | ) | const |
This method calculates the time between the time and the specified time in seconds.
|
inline |
This method compares the time with the specified time.
true
if the time is less than the specified time value, otherwise return false
.
|
inline |
This method compares the time with the specified time.
true
if the time is no more than the specified time value, otherwise return false
.
|
inline |
This method duplicates the specified value.
_t | A std::time_t value. |
This method duplicates the specified value.
_time | A Time value. |
|
inline |
This method translates the input local time.
This method internally calls mktime function.
_tm | Pointer to a std::tm value. |
This method converts the specified string into the Time value using parseDateString function.
Please note that usually this method tries to parse the time as local time.
time | Reference to a string that holds valid date-time. |
|
inline |
This method compares the time with the specified time.
true
if the time is equal to the specified time value, otherwise return false
.
|
inline |
This method compares the time with the specified time.
true
if the time is larger than the specified time value, otherwise return false
.
|
inline |
This method compares the time with the specified time.
true
if the time is no less than the specified time value, otherwise return false
. void Celartem::Time::parseDateString | ( | const String & | inDateString | ) |
This method parses the specified string and set the time to this instance.
Please note that usually this method tries to parse the time as local time.
inDateString | A string that holds the valid date-time. |
Referenced by operator=(), and Time().
This method is just a helper function to deal with SerializableData template. For more information, see SerializableData.
This method converts the time into the string using specified format much like as strftime
function.
format | A strftime date-time format. |
|
static |
This method gets the specified time (in UTC).
_tm | Pointer to a std::tm value. |
|
inlinestatic |
This method gets the specified time (in localtime).
_tm | Pointer to a std::tm value. |
String Celartem::Time::toGMTStr | ( | ) | const |
This method returns the time in UTC in "YYYY-MM-DD hh:mm:ss"
format.
"YYYY-MM-DD hh:mm:ss"
format. std::time_t Celartem::Time::t |
You can access to the variable directly.
Please note that this value stores the time in UTC.
Referenced by operator!=(), operator+(), operator<(), operator<=(), operator=(), operator==(), operator>(), and operator>=().