#include <cel_time.h>
List of all members.
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 |
Detailed Description
Time class wraps the standard C time_t and provides some utility functions.
Constructor & Destructor Documentation
| Celartem::Time::Time |
( |
std::time_t |
_t = 0 |
) |
[inline] |
This constructor initializes the time_t value by the specified value.
- Parameters:
-
Referenced by operator+().
| Celartem::Time::Time |
( |
const Time & |
_time |
) |
[inline] |
This constructor duplicates the Time instance.
- Parameters:
-
| _time | The instance to duplicate. |
| Celartem::Time::Time |
( |
const String & |
time |
) |
[inline] |
This constructor parses the specified string and initialize the instance by it.
- Parameters:
-
| time | A string that holds a valid date-time. |
| Celartem::Time::Time |
( |
const std::tm * |
_tm |
) |
[inline] |
This constructor converts the specified std::tm value into std::time_t and initialize the instance by it.
- Parameters:
-
| _tm | Pointer to a std::tm variable. |
| Celartem::Time::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 | |
|
) |
| | [inline] |
This constructor converts the specified date-time into std::time_t and initialize the instance by it.
- Parameters:
-
| 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. |
Member Function Documentation
| static Time Celartem::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] |
This constructor converts the specified date-time into std::time_t and initialize the instance by it.
- Parameters:
-
| 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'.
- Returns:
- The string notation of the time.
| void Celartem::Time::deserialize |
( |
Stream * |
inStream, |
|
|
size_t |
inLevel, |
|
|
Endian |
inEndian | |
|
) |
| | |
| static Time Celartem::Time::fromGMTStr |
( |
const String & |
inGMTStr |
) |
[static] |
This method returns the time in UTC from "YYYY-MM-DD hh:mm:ss" format.
| static Time Celartem::Time::getCurrentTime |
( |
|
) |
[static] |
This method gets the current time.
- Returns:
- Current Time.
| String Celartem::Time::getRFC822timeString |
( |
bool |
isLocalTime = true |
) |
const |
This method outputs string like "Mon, 13 Oct 2003 02:29:48 +0900" .
- Parameters:
-
| isLocalTime | Whether the output string is in local time or not. |
- Returns:
- The string notation of the time.
| void Celartem::Time::gmtime |
( |
std::tm * |
out_tm |
) |
const |
This method converts the time to std::tm in UTC.
- Parameters:
-
| 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.
- Parameters:
-
| out_tm | Pointer to the buffer that receives the std::tm value. |
| static Time Celartem::Time::mktime |
( |
const std::tm * |
_tm |
) |
[static] |
This method gets the specified time (in localtime).
- Parameters:
-
| _tm | Pointer to a std::tm value. |
- Returns:
- A Time instance.
Referenced by operator=(), Time(), and timelocal().
| bool Celartem::Time::operator!= |
( |
const Time & |
r |
) |
const [inline] |
This method compares the time with the specified time.
- Returns:
true if the time is not equal to the specified time value, otherwise return false .
| Time Celartem::Time::operator+ |
( |
ssize_t |
diff |
) |
const [inline] |
This method calculates the time of diff seconds later from the time.
- Returns:
- 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.
- Returns:
- The difference in seconds.
| bool Celartem::Time::operator< |
( |
const Time & |
r |
) |
const [inline] |
This method compares the time with the specified time.
- Returns:
true if the time is less than the specified time value, otherwise return false .
| bool Celartem::Time::operator<= |
( |
const Time & |
r |
) |
const [inline] |
This method compares the time with the specified time.
- Returns:
true if the time is no more than the specified time value, otherwise return false .
| Time& Celartem::Time::operator= |
( |
const String & |
time |
) |
[inline] |
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.
- Parameters:
-
| time | Reference to a string that holds valid date-time. |
- Returns:
- Reference to this instance.
| Time& Celartem::Time::operator= |
( |
std::time_t |
_t |
) |
[inline] |
This method duplicates the specified value.
- Parameters:
-
- Returns:
- Reference to this instance.
| Time& Celartem::Time::operator= |
( |
const std::tm * |
_tm |
) |
[inline] |
This method translates the input local time.
This method internally calls mktime function.
- Parameters:
-
| _tm | Pointer to a std::tm value. |
- Returns:
- Reference to this instance.
| Time& Celartem::Time::operator= |
( |
const Time & |
_time |
) |
[inline] |
This method duplicates the specified value.
- Parameters:
-
- Returns:
- Reference to this instance.
| bool Celartem::Time::operator== |
( |
const Time & |
r |
) |
const [inline] |
This method compares the time with the specified time.
- Returns:
true if the time is equal to the specified time value, otherwise return false .
| bool Celartem::Time::operator> |
( |
const Time & |
r |
) |
const [inline] |
This method compares the time with the specified time.
- Returns:
true if the time is larger than the specified time value, otherwise return false .
| bool Celartem::Time::operator>= |
( |
const Time & |
r |
) |
const [inline] |
This method compares the time with the specified time.
- Returns:
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.
- Parameters:
-
| inDateString | A string that holds the valid date-time. |
Referenced by operator=(), and Time().
| void Celartem::Time::serialize |
( |
Stream * |
inStream, |
|
|
size_t |
inLevel, |
|
|
Endian |
inEndian | |
|
) |
| | const |
| String Celartem::Time::strftime |
( |
const String & |
format |
) |
const |
This method converts the time into the string using specified format much like as strftime function.
- Parameters:
-
| format | A strftime date-time format. |
- Returns:
- The result string.
| static Time Celartem::Time::timegm |
( |
const std::tm * |
_tm |
) |
[static] |
This method gets the specified time (in UTC).
- Parameters:
-
| _tm | Pointer to a std::tm value. |
- Returns:
- A Time instance.
| static Time Celartem::Time::timelocal |
( |
const std::tm * |
_tm |
) |
[inline, static] |
This method gets the specified time (in localtime).
- Parameters:
-
| _tm | Pointer to a std::tm value. |
- Returns:
- A Time instance.
| String Celartem::Time::toGMTStr |
( |
|
) |
const |
This method returns the time in UTC in "YYYY-MM-DD hh:mm:ss" format.
- Returns:
- The UTC time in
"YYYY-MM-DD hh:mm:ss" format.
Member Data Documentation
The documentation for this struct was generated from the following file: