libcamgm
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Friends | Related Functions | List of all members
ca_mgm::Date Class Reference

#include <Date.hpp>

Public Types

typedef time_t ValueType
 

Public Member Functions

 Date ()
 
 Date (ValueType date_r)
 
 Date (const std::string &seconds_r)
 
 Date (const std::string &date_str, const std::string &format, bool utc=false)
 
 operator ValueType () const
 
std::string form (const std::string &format_r, bool utc=false) const
 
std::string asString () const
 
std::string asSeconds () const
 
Arithmetic operations.

+ - * / are provided via conversion to time_t.

Dateoperator+= (const time_t rhs)
 
Dateoperator-= (const time_t rhs)
 
Dateoperator*= (const time_t rhs)
 
Dateoperator/= (const time_t rhs)
 
Dateoperator++ ()
 
Dateoperator-- ()
 
Date operator++ (int)
 
Date operator-- (int)
 

Static Public Member Functions

static Date now ()
 

Private Attributes

ValueType _date
 

Friends

std::ostream & operator<< (std::ostream &str, const Date &obj)
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &str, const Date &obj)
 

Detailed Description

Store and operate on date (time_t).

Member Typedef Documentation

typedef time_t ca_mgm::Date::ValueType

Constructor & Destructor Documentation

ca_mgm::Date::Date ( )
inline

Default ctor: 0

Referenced by Date().

ca_mgm::Date::Date ( ValueType  date_r)
inline

Ctor taking time_t value.

References Date().

ca_mgm::Date::Date ( const std::string &  seconds_r)

Ctor taking time_t value as string.

ca_mgm::Date::Date ( const std::string &  date_str,
const std::string &  format,
bool  utc = false 
)

Ctor from a date_str formatted using format.

Exceptions
DateFormatExceptionin case date_str cannot be parsed according to format.

Member Function Documentation

std::string ca_mgm::Date::asSeconds ( ) const
inline

Convert to string representation of calendar time in numeric form (like "1029255142").

References form().

std::string ca_mgm::Date::asString ( ) const
inline

Default string representation of Date. The preferred date and time representation for the current locale.

References form().

Referenced by operator<<().

std::string ca_mgm::Date::form ( const std::string &  format_r,
bool  utc = false 
) const

Return string representation according to format.

See also
'man strftime' (which is used internaly) for valid conversion specifiers in format.
Returns
An empty string on illegal format.

Referenced by asSeconds(), asString(), and operator--().

static Date ca_mgm::Date::now ( )
inlinestatic

Return the current time.

ca_mgm::Date::operator ValueType ( ) const
inline

Conversion to time_t.

References _date.

Date& ca_mgm::Date::operator*= ( const time_t  rhs)
inline

References _date.

Date& ca_mgm::Date::operator++ ( )
inline

References _date.

Date ca_mgm::Date::operator++ ( int  )
inline

References _date.

Date& ca_mgm::Date::operator+= ( const time_t  rhs)
inline

References _date.

Date& ca_mgm::Date::operator-- ( )
inline

References _date.

Date ca_mgm::Date::operator-- ( int  )
inline

References _date, and form().

Date& ca_mgm::Date::operator-= ( const time_t  rhs)
inline

References _date.

Date& ca_mgm::Date::operator/= ( const time_t  rhs)
inline

References _date.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  str,
const Date obj 
)
friend
std::ostream & operator<< ( std::ostream &  str,
const Date obj 
)
related

Stream output

References asString().

Member Data Documentation

ValueType ca_mgm::Date::_date
private

Calendar time. The number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).

Referenced by operator ValueType(), operator*=(), operator++(), operator+=(), operator--(), operator-=(), and operator/=().


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