utl::Duration Class Reference
[Date/Time]

Duration of time. More...

#include <Duration.h>

Inheritance diagram for utl::Duration:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 Duration (double seconds)
 Constructor.
 Duration (const String &str)
 Constructor.
 Duration (uint_t days, uint_t hours, uint_t minutes, double seconds)
 Constructor.
virtual String toString () const
 Get a string representation.
uint_t getDays () const
 Get the number of days.
uint_t getHours () const
 Get the number of hours.
uint_t getMinutes () const
 Get the number of minutes.
double getSeconds () const
 Get the number of seconds.
virtual Number< double > & set (const String &str)
 Set with a format string.
void set (uint_t days, uint_t hours, uint_t minutes, double seconds)
 Set a new duration.
void setUnit (uint_t unit, uint_t num=1)
 Set to a multiple of a given unit.
Duration operator+ (const Duration &rhs) const
 Add the given duration to self and return the result.
Duration operator- (const Duration &rhs) const
 Subtract the given duration from self and return the result.

Static Public Attributes

static const Duration oneDay
 Duration of one day.
static const Duration oneHour
 Duration of one hour.
static const Duration oneHalfHour
 Duration of half an hour.
static const Duration oneMinute
 Duration of one minute.
static const Duration oneSecond
 Duration of one second.


Detailed Description

Duration of time.

String Representation Formatting

The format string takes the form:

   [<numDays> d] [<numHours> h] [<numMinutes> m] [<numSeconds> s]

The following are examples of valid format strings:

Author:
Adam McKee

Definition at line 40 of file Duration.h.


Constructor & Destructor Documentation

utl::Duration::Duration ( double  seconds  )  [inline]

Constructor.

Parameters:
seconds number of seconds

Definition at line 49 of file Duration.h.

utl::Duration::Duration ( const String str  )  [inline]

Constructor.

Parameters:
str format string

Definition at line 56 of file Duration.h.

utl::Duration::Duration ( uint_t  days,
uint_t  hours,
uint_t  minutes,
double  seconds 
) [inline]

Constructor.

Parameters:
days number of days
hours number of hours
minutes number of minutes
seconds number of seconds

Definition at line 66 of file Duration.h.


Member Function Documentation

virtual String utl::Duration::toString (  )  const [virtual]

Get a string representation.

Reimplemented from utl::Float.

uint_t utl::Duration::getDays (  )  const [inline]

Get the number of days.

Definition at line 72 of file Duration.h.

uint_t utl::Duration::getHours (  )  const [inline]

Get the number of hours.

Definition at line 76 of file Duration.h.

uint_t utl::Duration::getMinutes (  )  const [inline]

Get the number of minutes.

Definition at line 84 of file Duration.h.

double utl::Duration::getSeconds (  )  const [inline]

Get the number of seconds.

Definition at line 92 of file Duration.h.

virtual Number<double>& utl::Duration::set ( const String str  )  [virtual]

Set with a format string.

Reimplemented from utl::Float.

void utl::Duration::set ( uint_t  days,
uint_t  hours,
uint_t  minutes,
double  seconds 
)

Set a new duration.

Parameters:
days number of days
hours number of hours
minutes number of minutes
seconds number of seconds

void utl::Duration::setUnit ( uint_t  unit,
uint_t  num = 1 
)

Set to a multiple of a given unit.

Parameters:
unit (see tm_unit_t)
num multiple of the given unit

Duration utl::Duration::operator+ ( const Duration rhs  )  const [inline]

Add the given duration to self and return the result.

Returns:
self plus rhs
Parameters:
rhs duration to add

Definition at line 119 of file Duration.h.

Duration utl::Duration::operator- ( const Duration rhs  )  const [inline]

Subtract the given duration from self and return the result.

Returns:
self minus rhs
Parameters:
rhs duration to subtract

Definition at line 127 of file Duration.h.


Member Data Documentation

Duration of one day.

Definition at line 131 of file Duration.h.

Duration of one hour.

Definition at line 133 of file Duration.h.

Duration of half an hour.

Definition at line 135 of file Duration.h.

Duration of one minute.

Definition at line 137 of file Duration.h.

Duration of one second.

Definition at line 139 of file Duration.h.


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

Generated on Tue May 26 16:53:32 2009 for libUTL++ by  doxygen 1.5.6