libcommonc++  0.7
TimeSpan Class Reference

A span of time (a delta), represented in milliseconds. More...

#include <TimeSpan.h++>

Public Member Functions

 TimeSpan (int64_t span=INT64_CONST(0))
 Construct a TimeSpan for the given number of milliseconds. More...
 
 TimeSpan (int days, int hours, int minutes, int seconds, int msec=0)
 Construct a TimeSpan in terms of days, hours, minutes, seconds, and/or milliseconds. More...
 
 TimeSpan (const TimeSpan &other)
 Copy constructor. More...
 
 ~TimeSpan ()
 Destructor. More...
 
void setSpan (int days, int hours, int minutes, int seconds, int msec=0)
 Set the timespan. More...
 
void setSpan (int64_t seconds)
 Set the timespan in seconds. More...
 
int64_t getSpan () const
 Get the timespan, in milliseconds. More...
 
void setDays (int days)
 Set the days component of the timespan. More...
 
void addDays (int days)
 Add days to the timespan. More...
 
void subtractDays (int days)
 Subtract days from the timespan. More...
 
int getDays () const
 Get the days component of the timespan. More...
 
void setHours (int hours)
 Set the hours component of the timespan. More...
 
void addHours (int hours)
 Add hours to the timespan. More...
 
void subtractHours (int hours)
 Subtract hours from the timespan. More...
 
int getHours () const
 Get the hours component of the timespan. More...
 
void setMinutes (int minutes)
 Set the minutes component of the timespan. More...
 
void addMinutes (int minutes)
 Add minutes to the timespan. More...
 
void subtractMinutes (int minutes)
 Subtract minutes from the timespan. More...
 
int getMinutes () const
 Get the minutes component of the timespan. More...
 
void setSeconds (int seconds)
 Set the seconds component of the timespan. More...
 
void addSeconds (int seconds)
 Add seconds to the timespan. More...
 
void subtractSeconds (int seconds)
 Subtract seconds from the timespan. More...
 
int getSeconds () const
 Get the seconds component of the timespan. More...
 
void setMilliseconds (int msec)
 Set the milliseconds component of the timespan. More...
 
void addMilliseconds (int msec)
 Add milliseconds to the timespan. More...
 
void subtractMilliseconds (int msec)
 Subtract milliseconds from the timespan. More...
 
int getMilliseconds () const
 Get the milliseconds component of the timespan. More...
 
TimeSpanoperator= (const TimeSpan &other)
 
bool operator== (const TimeSpan &other) const
 
bool operator< (const TimeSpan &other) const
 
bool operator<= (const TimeSpan &other) const
 
bool operator!= (const TimeSpan &other) const
 
bool operator> (const TimeSpan &other) const
 
bool operator>= (const TimeSpan &other) const
 
TimeSpanoperator+= (const TimeSpan &span)
 
TimeSpanoperator+= (int seconds)
 
TimeSpanoperator-= (const TimeSpan &span)
 
TimeSpanoperator-= (int seconds)
 
TimeSpan operator- () const
 
int64_t toSeconds () const
 Get the timespan in seconds. More...
 
 operator int64_t () const
 Get the timespan in milliseconds. More...
 
int64_t toMilliseconds () const
 Get the timespan in milliseconds. More...
 
String toString () const
 Get a String representation of the TimeSpan. More...
 

Static Public Attributes

static const int msInSecond = 1000
 The number of milliseconds in a second. More...
 
static const int msInMinute = 60000
 The number of milliseconds in a minute. More...
 
static const int msInHour = 3600000
 The number of milliseconds in an hour. More...
 
static const int msInDay = 86400000
 The number of milliseconds in a day. More...
 

Detailed Description

A span of time (a delta), represented in milliseconds.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ TimeSpan() [1/3]

TimeSpan ( int64_t  span = INT64_CONST(0))

Construct a TimeSpan for the given number of milliseconds.

Parameters
spanThe span, in milliseconds.

◆ TimeSpan() [2/3]

TimeSpan ( int  days,
int  hours,
int  minutes,
int  seconds,
int  msec = 0 
)

Construct a TimeSpan in terms of days, hours, minutes, seconds, and/or milliseconds.

◆ TimeSpan() [3/3]

TimeSpan ( const TimeSpan other)

Copy constructor.

◆ ~TimeSpan()

~TimeSpan ( )

Destructor.

Member Function Documentation

◆ addDays()

void addDays ( int  days)

Add days to the timespan.

◆ addHours()

void addHours ( int  hours)

Add hours to the timespan.

◆ addMilliseconds()

void addMilliseconds ( int  msec)

Add milliseconds to the timespan.

◆ addMinutes()

void addMinutes ( int  minutes)

Add minutes to the timespan.

◆ addSeconds()

void addSeconds ( int  seconds)

Add seconds to the timespan.

◆ getDays()

int getDays ( ) const
inline

Get the days component of the timespan.

◆ getHours()

int getHours ( ) const
inline

Get the hours component of the timespan.

◆ getMilliseconds()

int getMilliseconds ( ) const
inline

Get the milliseconds component of the timespan.

◆ getMinutes()

int getMinutes ( ) const
inline

Get the minutes component of the timespan.

◆ getSeconds()

int getSeconds ( ) const
inline

Get the seconds component of the timespan.

◆ getSpan()

int64_t getSpan ( ) const
inline

Get the timespan, in milliseconds.

◆ operator int64_t()

operator int64_t ( ) const
inline

Get the timespan in milliseconds.

◆ operator!=()

bool operator!= ( const TimeSpan other) const
inline

◆ operator+=() [1/2]

TimeSpan & operator+= ( const TimeSpan span)

◆ operator+=() [2/2]

TimeSpan & operator+= ( int  seconds)

◆ operator-()

TimeSpan operator- ( ) const

◆ operator-=() [1/2]

TimeSpan & operator-= ( const TimeSpan span)

◆ operator-=() [2/2]

TimeSpan & operator-= ( int  seconds)

◆ operator<()

bool operator< ( const TimeSpan other) const
inline

◆ operator<=()

bool operator<= ( const TimeSpan other) const
inline

◆ operator=()

TimeSpan & operator= ( const TimeSpan other)

◆ operator==()

bool operator== ( const TimeSpan other) const
inline

◆ operator>()

bool operator> ( const TimeSpan other) const
inline

◆ operator>=()

bool operator>= ( const TimeSpan other) const
inline

◆ setDays()

void setDays ( int  days)

Set the days component of the timespan.

◆ setHours()

void setHours ( int  hours)

Set the hours component of the timespan.

◆ setMilliseconds()

void setMilliseconds ( int  msec)

Set the milliseconds component of the timespan.

◆ setMinutes()

void setMinutes ( int  minutes)

Set the minutes component of the timespan.

◆ setSeconds()

void setSeconds ( int  seconds)

Set the seconds component of the timespan.

◆ setSpan() [1/2]

void setSpan ( int  days,
int  hours,
int  minutes,
int  seconds,
int  msec = 0 
)

Set the timespan.

◆ setSpan() [2/2]

void setSpan ( int64_t  seconds)

Set the timespan in seconds.

◆ subtractDays()

void subtractDays ( int  days)

Subtract days from the timespan.

◆ subtractHours()

void subtractHours ( int  hours)

Subtract hours from the timespan.

◆ subtractMilliseconds()

void subtractMilliseconds ( int  msec)

Subtract milliseconds from the timespan.

◆ subtractMinutes()

void subtractMinutes ( int  minutes)

Subtract minutes from the timespan.

◆ subtractSeconds()

void subtractSeconds ( int  seconds)

Subtract seconds from the timespan.

◆ toMilliseconds()

int64_t toMilliseconds ( ) const
inline

Get the timespan in milliseconds.

◆ toSeconds()

int64_t toSeconds ( ) const
inline

Get the timespan in seconds.

◆ toString()

String toString ( ) const

Get a String representation of the TimeSpan.

Member Data Documentation

◆ msInDay

const int msInDay = 86400000
static

The number of milliseconds in a day.

◆ msInHour

const int msInHour = 3600000
static

The number of milliseconds in an hour.

◆ msInMinute

const int msInMinute = 60000
static

The number of milliseconds in a minute.

◆ msInSecond

const int msInSecond = 1000
static

The number of milliseconds in a second.


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