frepple::utils::TimePeriod Class Reference

This class represents a time duration with an accuracy of one second. More...

#include <utils.h>

List of all members.

Public Member Functions

 operator long () const
 operator string () const
bool operator! () const
bool operator!= (const TimePeriod &b) const
void operator+= (const TimePeriod &l)
void operator-= (const TimePeriod &l)
bool operator< (const TimePeriod &b) const
bool operator< (const long &b) const
bool operator<= (const TimePeriod &b) const
bool operator<= (const long &b) const
bool operator== (const TimePeriod &b) const
bool operator> (const TimePeriod &b) const
bool operator> (const long &b) const
bool operator>= (const TimePeriod &b) const
bool operator>= (const long &b) const
void parse (const char *)
 TimePeriod (const char *s)
 TimePeriod (const long l=0)

Static Public Attributes

static const TimePeriod MAX
static const TimePeriod MIN

Friends

ostream & operator<< (ostream &, const TimePeriod &)

Detailed Description

This class represents a time duration with an accuracy of one second.

The duration can be both positive and negative.

Definition at line 1626 of file utils.h.


Constructor & Destructor Documentation

frepple::utils::TimePeriod::TimePeriod ( const long  l = 0  )  [inline]

Default constructor and constructor with timeperiod passed.

Definition at line 1631 of file utils.h.

frepple::utils::TimePeriod::TimePeriod ( const char *  s  )  [inline]

Constructor from a character string.
See the parse() method for details on the format of the argument.

Definition at line 1636 of file utils.h.


Member Function Documentation

frepple::utils::TimePeriod::operator long (  )  const [inline]

This conversion operator creates a long value from a timeperiod.

Definition at line 1678 of file utils.h.

frepple::utils::TimePeriod::operator string (  )  const [inline]

Converts the date to a string, formatted according to ISO 8601.

Definition at line 1681 of file utils.h.

bool frepple::utils::TimePeriod::operator! (  )  const [inline]

Returns true of the duration is equal to 0.

Definition at line 1675 of file utils.h.

bool frepple::utils::TimePeriod::operator!= ( const TimePeriod b  )  const [inline]

Inequality operator.

Definition at line 1666 of file utils.h.

void frepple::utils::TimePeriod::operator+= ( const TimePeriod l  )  [inline]

Increase the timeperiod.

Definition at line 1669 of file utils.h.

void frepple::utils::TimePeriod::operator-= ( const TimePeriod l  )  [inline]

Decrease the timeperiod.

Definition at line 1672 of file utils.h.

bool frepple::utils::TimePeriod::operator< ( const TimePeriod b  )  const [inline]

Comparison between periods of time.

Definition at line 1651 of file utils.h.

bool frepple::utils::TimePeriod::operator< ( const long &  b  )  const [inline]

Comparison between periods of time.

Definition at line 1639 of file utils.h.

bool frepple::utils::TimePeriod::operator<= ( const TimePeriod b  )  const [inline]

Comparison between periods of time.

Definition at line 1657 of file utils.h.

bool frepple::utils::TimePeriod::operator<= ( const long &  b  )  const [inline]

Comparison between periods of time.

Definition at line 1645 of file utils.h.

bool frepple::utils::TimePeriod::operator== ( const TimePeriod b  )  const [inline]

Equality operator.

Definition at line 1663 of file utils.h.

bool frepple::utils::TimePeriod::operator> ( const TimePeriod b  )  const [inline]

Comparison between periods of time.

Definition at line 1654 of file utils.h.

bool frepple::utils::TimePeriod::operator> ( const long &  b  )  const [inline]

Comparison between periods of time.

Definition at line 1642 of file utils.h.

bool frepple::utils::TimePeriod::operator>= ( const TimePeriod b  )  const [inline]

Comparison between periods of time.

Definition at line 1660 of file utils.h.

bool frepple::utils::TimePeriod::operator>= ( const long &  b  )  const [inline]

Comparison between periods of time.

Definition at line 1648 of file utils.h.

void frepple::utils::TimePeriod::parse ( const char *  s  ) 

Function that parses a input string to a time value.
The string format is following the ISO 8601 specification for durations: [-]P[nY][nM][nW][nD][T[nH][nM][nS]]
Some examples to illustrate how the string is converted to a timeperiod, expressed in seconds:
P1Y = 1 year = 365 days = 31536000 seconds P1M = 365/12 days = 2628000 seconds P1W = 1 week = 7 days = 604800 seconds -P1D = -1 day = -86400 seconds PT1H = 1 hour = 3600 seconds -PT1000000S = 1000000 seconds P1M1WT1H = 1 month + 1 week + 1 hour = 3236400 seconds It pretty strictly checks the spec, with a few exceptions:

  • A week field ('W') may coexist with other units.
  • Decimal values are not supported.
  • The alternate format as a date and time is not supported.

Definition at line 143 of file date.cpp.


Friends And Related Function Documentation

ostream& operator<< ( ostream &  ,
const TimePeriod  
) [friend]

Member Data Documentation

The maximum value for a timeperiod.

Definition at line 1708 of file utils.h.

The minimum value for a timeperiod.

Definition at line 1711 of file utils.h.


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

Documentation generated for frePPLe by  doxygen