Combined Date and Time value. More...

#include <cxxtools/datetime.h>

Public Member Functions

 DateTime ()
 DateTime (int year, unsigned month, unsigned day, unsigned hour=0, unsigned minute=0, unsigned second=0, unsigned msec=0)
 DateTime (const DateTime &dateTime)
DateTimeoperator= (const DateTime &dateTime)
 ~DateTime ()
DateTimeoperator= (unsigned julianDay)
void set (int year, unsigned month, unsigned day, unsigned hour=0, unsigned min=0, unsigned sec=0, unsigned msec=0)
void get (int &year, unsigned &month, unsigned &day, unsigned &hour, unsigned &min, unsigned &sec, unsigned &msec) const
const Datedate () const
const Datedate ()
DateTimesetDate (const Date &date)
const Timetime () const
const Timetime ()
DateTimesetTime (const Time &time)
unsigned day () const
 Returns the day-part of the date.
unsigned month () const
 Returns the month-part of the date.
int year () const
 Returns the year-part of the date.
unsigned hour () const
 Returns the hour-part of the Time.
unsigned minute () const
 Returns the minute-part of the Time.
unsigned second () const
 Returns the second-part of the Time.
unsigned msec () const
 Returns the millisecond-part of the Time.
int64_t msecsSinceEpoch () const
 Returns the milliseconds relative to the Unix-epoch.
std::string toIsoString () const
bool operator== (const DateTime &rhs) const
bool operator!= (const DateTime &rhs) const
DateTimeoperator+= (const Timespan &ts)
 Assignment by sum operator.
DateTimeoperator-= (const Timespan &ts)
 Assignment by difference operator.
bool operator< (const DateTime &dt) const
bool operator<= (const DateTime &dt) const
bool operator> (const DateTime &dt) const
bool operator>= (const DateTime &dt) const

Static Public Member Functions

static DateTime fromJulianDays (unsigned julianDays)
static DateTime fromMSecsSinceEpoch (const int64_t msecsSinceEpoch)
 Creates a DateTime object relative to the Unix epoch.
static DateTime fromIsoString (const std::string &s)
static bool isValid (int year, unsigned month, unsigned day, unsigned hour, unsigned minute, unsigned second, unsigned msec)

Friends

Timespan operator- (const DateTime &first, const DateTime &second)
DateTime operator+ (const DateTime &dt, const Timespan &ts)
DateTime operator- (const DateTime &dt, const Timespan &ts)

Detailed Description

Combined Date and Time value.

Constructor & Destructor Documentation

cxxtools::DateTime::DateTime ( )
inline
cxxtools::DateTime::DateTime ( int  year,
unsigned  month,
unsigned  day,
unsigned  hour = 0,
unsigned  minute = 0,
unsigned  second = 0,
unsigned  msec = 0 
)
inline
cxxtools::DateTime::DateTime ( const DateTime dateTime)
inline
cxxtools::DateTime::~DateTime ( )
inline

Member Function Documentation

const Date& cxxtools::DateTime::date ( ) const
inline
const Date& cxxtools::DateTime::date ( )
inline
unsigned cxxtools::DateTime::day ( ) const
inline

Returns the day-part of the date.

DateTime cxxtools::DateTime::fromIsoString ( const std::string &  s)
inlinestatic
static DateTime cxxtools::DateTime::fromJulianDays ( unsigned  julianDays)
inlinestatic
static DateTime cxxtools::DateTime::fromMSecsSinceEpoch ( const int64_t  msecsSinceEpoch)
inlinestatic

Creates a DateTime object relative to the Unix epoch.

The DateTime will be relative to the unix-epoch (Jan 1st 1970) by the milli-seconds specified by msecsSinceEpoch. The construction does not take care of any time zones. I.e. the milliseconds will be treated as if they were in the same time zone as the reference (January 1st 1970). Thus specifying a "time-zoned" millisecond value will lead to a "time-zoned" DateTime. And accordingly a "GMT" millisecond value will lead to a "GMT" DateTime.

void cxxtools::DateTime::get ( int &  year,
unsigned &  month,
unsigned &  day,
unsigned &  hour,
unsigned &  min,
unsigned &  sec,
unsigned &  msec 
) const
inline
unsigned cxxtools::DateTime::hour ( ) const
inline

Returns the hour-part of the Time.

bool cxxtools::DateTime::isValid ( int  year,
unsigned  month,
unsigned  day,
unsigned  hour,
unsigned  minute,
unsigned  second,
unsigned  msec 
)
inlinestatic
unsigned cxxtools::DateTime::minute ( ) const
inline

Returns the minute-part of the Time.

unsigned cxxtools::DateTime::month ( ) const
inline

Returns the month-part of the date.

unsigned cxxtools::DateTime::msec ( ) const
inline

Returns the millisecond-part of the Time.

int64_t cxxtools::DateTime::msecsSinceEpoch ( ) const

Returns the milliseconds relative to the Unix-epoch.

The calculation does currently not take care of any time zones. I.e. the milliseconds will be calculated as if they were in the same time zone as the reference (January 1st 1970). Thus calling this API on a "time-zoned" DateTime will lead to a "time-zoned" millisecond value. And accordingly calling this API on a "GMT" DateTime will lead to a "GMT" millisecond value.

bool cxxtools::DateTime::operator!= ( const DateTime rhs) const
inline
DateTime& cxxtools::DateTime::operator+= ( const Timespan ts)

Assignment by sum operator.

DateTime& cxxtools::DateTime::operator-= ( const Timespan ts)

Assignment by difference operator.

bool cxxtools::DateTime::operator< ( const DateTime dt) const
inline
bool cxxtools::DateTime::operator<= ( const DateTime dt) const
inline
DateTime & cxxtools::DateTime::operator= ( const DateTime dateTime)
inline
DateTime & cxxtools::DateTime::operator= ( unsigned  julianDay)
inline
bool cxxtools::DateTime::operator== ( const DateTime rhs) const
inline
bool cxxtools::DateTime::operator> ( const DateTime dt) const
inline
bool cxxtools::DateTime::operator>= ( const DateTime dt) const
inline
unsigned cxxtools::DateTime::second ( ) const
inline

Returns the second-part of the Time.

void cxxtools::DateTime::set ( int  year,
unsigned  month,
unsigned  day,
unsigned  hour = 0,
unsigned  min = 0,
unsigned  sec = 0,
unsigned  msec = 0 
)
inline
DateTime& cxxtools::DateTime::setDate ( const Date date)
inline
DateTime& cxxtools::DateTime::setTime ( const Time time)
inline
const Time& cxxtools::DateTime::time ( ) const
inline
const Time& cxxtools::DateTime::time ( )
inline
std::string cxxtools::DateTime::toIsoString ( ) const
inline
int cxxtools::DateTime::year ( ) const
inline

Returns the year-part of the date.

Friends And Related Function Documentation

DateTime operator+ ( const DateTime dt,
const Timespan ts 
)
friend
Timespan operator- ( const DateTime first,
const DateTime second 
)
friend
DateTime operator- ( const DateTime dt,
const Timespan ts 
)
friend

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