Represents time spans up to microsecond resolution. More...

#include <cxxtools/timespan.h>

Public Member Functions

 Timespan ()
 Creates a zero Timespan.
 Timespan (int64_t microseconds)
 Creates a Timespan.
 Timespan (long seconds, long microseconds)
 Creates a Timespan.
 Timespan (int days, int hours, int minutes, int seconds, int microseconds)
 Creates a Timespan.
 Timespan (const Timespan &timespan)
 Creates a Timespan from another one.
 ~Timespan ()
 Destroys the Timespan.
Timespanoperator= (const Timespan &timespan)
 Assignment operator.
Timespanoperator= (int64_t microseconds)
 Assignment operator.
Timespanset (int days, int hours, int minutes, int seconds, int microseconds)
 Assigns a new span.
Timespanset (long seconds, long microseconds)
 Assigns a new span.
void swap (Timespan &timespan)
 Swaps the Timespan with another one.
bool operator== (const Timespan &ts) const
bool operator!= (const Timespan &ts) const
bool operator> (const Timespan &ts) const
bool operator>= (const Timespan &ts) const
bool operator< (const Timespan &ts) const
bool operator<= (const Timespan &ts) const
bool operator== (int64_t microseconds) const
bool operator!= (int64_t microseconds) const
bool operator> (int64_t microseconds) const
bool operator>= (int64_t microseconds) const
bool operator< (int64_t microseconds) const
bool operator<= (int64_t microseconds) const
Timespan operator+ (const Timespan &d) const
Timespan operator- (const Timespan &d) const
Timespanoperator+= (const Timespan &d)
Timespanoperator-= (const Timespan &d)
Timespan operator+ (int64_t microseconds) const
Timespan operator- (int64_t microseconds) const
Timespanoperator+= (int64_t microseconds)
Timespanoperator-= (int64_t microseconds)
int days () const
 Returns the number of days.
int hours () const
 Returns the number of hours (0 to 23).
int totalHours () const
 Returns the total number of hours.
int minutes () const
 Returns the number of minutes (0 to 59).
int totalMinutes () const
 Returns the total number of minutes.
int seconds () const
 Returns the number of seconds (0 to 59).
int totalSeconds () const
 Returns the total number of seconds.
int msecs () const
 Returns the number of milliseconds (0 to 999).
int64_t totalMSecs () const
 Returns the total number of milliseconds.
int64_t totalUSecs () const
 Returns the total number of microseconds.
int microseconds () const
 Returns the fractions of a millisecond in microseconds (0 to 999).
int useconds () const
 Returns the fractions of a second in microseconds (0 to 999).
int64_t toUSecs () const
 Returns the total number of microseconds.

Static Public Member Functions

static Timespan gettimeofday ()
 returns the current time as a timespan value.

Static Public Attributes

static const int64_t Milliseconds = 1000
 The number of microseconds in a millisecond.
static const int64_t Seconds = 1000 * Timespan::Milliseconds
static const int64_t Minutes = 60 * Timespan::Seconds
static const int64_t Hours = 60 * Timespan::Minutes
static const int64_t Days = 24 * Timespan::Hours

Detailed Description

Represents time spans up to microsecond resolution.

Constructor & Destructor Documentation

cxxtools::Timespan::Timespan ( )
inline

Creates a zero Timespan.

cxxtools::Timespan::Timespan ( int64_t  microseconds)
inline

Creates a Timespan.

cxxtools::Timespan::Timespan ( long  seconds,
long  microseconds 
)
inline

Creates a Timespan.

Useful for creating a Timespan from a struct timeval.

cxxtools::Timespan::Timespan ( int  days,
int  hours,
int  minutes,
int  seconds,
int  microseconds 
)
inline

Creates a Timespan.

cxxtools::Timespan::Timespan ( const Timespan timespan)
inline

Creates a Timespan from another one.

cxxtools::Timespan::~Timespan ( )
inline

Destroys the Timespan.

Member Function Documentation

int cxxtools::Timespan::days ( ) const
inline

Returns the number of days.

static Timespan cxxtools::Timespan::gettimeofday ( )
static

returns the current time as a timespan value.

int cxxtools::Timespan::hours ( ) const
inline

Returns the number of hours (0 to 23).

int cxxtools::Timespan::microseconds ( ) const
inline

Returns the fractions of a millisecond in microseconds (0 to 999).

int cxxtools::Timespan::minutes ( ) const
inline

Returns the number of minutes (0 to 59).

int cxxtools::Timespan::msecs ( ) const
inline

Returns the number of milliseconds (0 to 999).

bool cxxtools::Timespan::operator!= ( const Timespan ts) const
inline
bool cxxtools::Timespan::operator!= ( int64_t  microseconds) const
inline
Timespan cxxtools::Timespan::operator+ ( const Timespan d) const
inline
Timespan cxxtools::Timespan::operator+ ( int64_t  microseconds) const
inline
Timespan & cxxtools::Timespan::operator+= ( const Timespan d)
inline
Timespan & cxxtools::Timespan::operator+= ( int64_t  microseconds)
inline
Timespan cxxtools::Timespan::operator- ( const Timespan d) const
inline
Timespan cxxtools::Timespan::operator- ( int64_t  microseconds) const
inline
Timespan & cxxtools::Timespan::operator-= ( const Timespan d)
inline
Timespan & cxxtools::Timespan::operator-= ( int64_t  microseconds)
inline
bool cxxtools::Timespan::operator< ( const Timespan ts) const
inline
bool cxxtools::Timespan::operator< ( int64_t  microseconds) const
inline
bool cxxtools::Timespan::operator<= ( const Timespan ts) const
inline
bool cxxtools::Timespan::operator<= ( int64_t  microseconds) const
inline
Timespan & cxxtools::Timespan::operator= ( const Timespan timespan)
inline

Assignment operator.

Timespan & cxxtools::Timespan::operator= ( int64_t  microseconds)
inline

Assignment operator.

bool cxxtools::Timespan::operator== ( const Timespan ts) const
inline
bool cxxtools::Timespan::operator== ( int64_t  microseconds) const
inline
bool cxxtools::Timespan::operator> ( const Timespan ts) const
inline
bool cxxtools::Timespan::operator> ( int64_t  microseconds) const
inline
bool cxxtools::Timespan::operator>= ( const Timespan ts) const
inline
bool cxxtools::Timespan::operator>= ( int64_t  microseconds) const
inline
int cxxtools::Timespan::seconds ( ) const
inline

Returns the number of seconds (0 to 59).

Timespan & cxxtools::Timespan::set ( int  days,
int  hours,
int  minutes,
int  seconds,
int  microseconds 
)
inline

Assigns a new span.

Timespan & cxxtools::Timespan::set ( long  seconds,
long  microseconds 
)
inline

Assigns a new span.

Useful for assigning from a struct timeval.

void cxxtools::Timespan::swap ( Timespan timespan)
inline

Swaps the Timespan with another one.

int cxxtools::Timespan::totalHours ( ) const
inline

Returns the total number of hours.

int cxxtools::Timespan::totalMinutes ( ) const
inline

Returns the total number of minutes.

int64_t cxxtools::Timespan::totalMSecs ( ) const
inline

Returns the total number of milliseconds.

int cxxtools::Timespan::totalSeconds ( ) const
inline

Returns the total number of seconds.

int64_t cxxtools::Timespan::totalUSecs ( ) const
inline

Returns the total number of microseconds.

int64_t cxxtools::Timespan::toUSecs ( ) const
inline

Returns the total number of microseconds.

int cxxtools::Timespan::useconds ( ) const
inline

Returns the fractions of a second in microseconds (0 to 999).

Member Data Documentation

const int64_t cxxtools::Timespan::Days = 24 * Timespan::Hours
static
const int64_t cxxtools::Timespan::Hours = 60 * Timespan::Minutes
static
const int64_t cxxtools::Timespan::Milliseconds = 1000
static

The number of microseconds in a millisecond.

The number of microseconds in a second. The number of microseconds in a minute. The number of microseconds in a hour. The number of microseconds in a day.

const int64_t cxxtools::Timespan::Minutes = 60 * Timespan::Seconds
static
const int64_t cxxtools::Timespan::Seconds = 1000 * Timespan::Milliseconds
static

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