TimeSpan Class Reference

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

#include <TimeSpan.h++>

List of all members.

Public Member Functions

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

Static Public Attributes

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

Detailed Description

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

Author:
Mark Lindner

Constructor & Destructor Documentation

TimeSpan ( int64_t  span = INT64_CONST(0)  )  throw ()

Construct a TimeSpan for the given number of milliseconds.

Parameters:
span The span, in milliseconds.
TimeSpan ( int  days,
int  hours,
int  minutes,
int  seconds,
int  msec = 0 
) throw ()

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

TimeSpan ( const TimeSpan other  )  throw ()

Copy constructor.

~TimeSpan (  )  throw ()

Destructor.


Member Function Documentation

void addDays ( int  days  )  throw ()

Add days to the timespan.

void addHours ( int  hours  )  throw ()

Add hours to the timespan.

void addMilliseconds ( int  msec  )  throw ()

Add milliseconds to the timespan.

void addMinutes ( int  minutes  )  throw ()

Add minutes to the timespan.

void addSeconds ( int  seconds  )  throw ()

Add seconds to the timespan.

int getDays (  )  const throw () [inline]

Get the days component of the timespan.

int getHours (  )  const throw () [inline]

Get the hours component of the timespan.

int getMilliseconds (  )  const throw () [inline]

Get the milliseconds component of the timespan.

int getMinutes (  )  const throw () [inline]

Get the minutes component of the timespan.

int getSeconds (  )  const throw () [inline]

Get the seconds component of the timespan.

int64_t getSpan (  )  const throw () [inline]

Get the timespan, in milliseconds.

operator int64_t (  )  const throw () [inline]

Get the timespan in milliseconds.

bool operator!= ( const TimeSpan other  )  const throw () [inline]
TimeSpan & operator+= ( int  seconds  )  throw ()
TimeSpan & operator+= ( const TimeSpan span  )  throw ()
TimeSpan operator- (  )  const throw ()
TimeSpan & operator-= ( int  seconds  )  throw ()
TimeSpan & operator-= ( const TimeSpan span  )  throw ()
bool operator< ( const TimeSpan other  )  const throw () [inline]
bool operator<= ( const TimeSpan other  )  const throw () [inline]
TimeSpan & operator= ( const TimeSpan other  )  throw ()
bool operator== ( const TimeSpan other  )  const throw () [inline]
bool operator> ( const TimeSpan other  )  const throw () [inline]
bool operator>= ( const TimeSpan other  )  const throw () [inline]
void setDays ( int  days  )  throw ()

Set the days component of the timespan.

void setHours ( int  hours  )  throw ()

Set the hours component of the timespan.

void setMilliseconds ( int  msec  )  throw ()

Set the milliseconds component of the timespan.

void setMinutes ( int  minutes  )  throw ()

Set the minutes component of the timespan.

void setSeconds ( int  seconds  )  throw ()

Set the seconds component of the timespan.

void setSpan ( int64_t  seconds  )  throw ()

Set the timespan in seconds.

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

Set the timespan.

void subtractDays ( int  days  )  throw ()

Subtract days from the timespan.

void subtractHours ( int  hours  )  throw ()

Subtract hours from the timespan.

void subtractMilliseconds ( int  msec  )  throw ()

Subtract milliseconds from the timespan.

void subtractMinutes ( int  minutes  )  throw ()

Subtract minutes from the timespan.

void subtractSeconds ( int  seconds  )  throw ()

Subtract seconds from the timespan.

int64_t toMilliseconds (  )  const throw () [inline]

Get the timespan in milliseconds.

int64_t toSeconds (  )  const throw () [inline]

Get the timespan in seconds.

String toString (  )  const

Get a String representation of the TimeSpan.


Member Data Documentation

const int msInDay = 86400000 [static]

The number of milliseconds in a day.

const int msInHour = 3600000 [static]

The number of milliseconds in an hour.

const int msInMinute = 60000 [static]

The number of milliseconds in a minute.

const int msInSecond = 1000 [static]

The number of milliseconds in a second.


The documentation for this class was generated from the following files:
Generated on Sat Nov 26 16:49:09 2011 for libcommonc++ by  doxygen 1.6.3