Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Celartem::Time Struct Reference

#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)
 
Timeoperator= (std::time_t _t)
 
Timeoperator= (const Time &_time)
 
Timeoperator= (const std::tm *_tm)
 
Timeoperator= (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
_tThe time_t value.

Referenced by operator+().

Celartem::Time::Time ( const Time _time)
inline

This constructor duplicates the Time instance.

Parameters
_timeThe instance to duplicate.
Celartem::Time::Time ( const String time)
inline

This constructor parses the specified string and initialize the instance by it.

Parameters
timeA 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
_tmPointer 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
yearYear. To specify 2005, set 2005 to this.
monthMonth. January is 1.
dayDay of the month. 1st is 1.
hourHour in 0 - 23.
minuteMinute in 0 - 59
secondsSeconds in 0 - 60 (in some special case, 60 is meaningful.)
boolisUTC 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
yearYear. To specify 2005, set 2005 to this.
monthMonth. January is 1.
dayDay of the month. 1st is 1.
hourHour in 0 - 23.
minuteMinute in 0 - 59
secondsSeconds in 0 - 60 (in some special case, 60 is meaningful.)
boolisUTC 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 
)

This method is just a helper function to deal with SerializableData template. For more information, see SerializableData.

See Also
SerializableData,Serializable, DataStore
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
isLocalTimeWhether 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_tmPointer 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_tmPointer 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
_tmPointer 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= ( std::time_t  _t)
inline

This method duplicates the specified value.

Parameters
_tA std::time_t value.
Returns
Reference to this instance.
Time& Celartem::Time::operator= ( const Time _time)
inline

This method duplicates the specified value.

Parameters
_timeA Time value.
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
_tmPointer to a std::tm value.
Returns
Reference to this instance.
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
timeReference to a string that holds valid date-time.
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
inDateStringA string that holds the valid date-time.

Referenced by operator=(), and Time().

void Celartem::Time::serialize ( Stream inStream,
size_t  inLevel,
Endian  inEndian 
) const

This method is just a helper function to deal with SerializableData template. For more information, see SerializableData.

See Also
SerializableData,Serializable, DataStore
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
formatA 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
_tmPointer to a std::tm value.
Returns
A Time instance.
static Time Celartem::Time::timelocal ( const std::tm *  _tm)
inlinestatic

This method gets the specified time (in localtime).

Parameters
_tmPointer 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

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>=().


The documentation for this struct was generated from the following file:

Cuminas DjVu SDK 3.0.33103
This document is made with doxygen 1.8.5 at Sun Dec 15 2013 19:38:06.
Cuminas Logo