Duration Class Reference

The Duration class represents a period of elapsed time between two events. More...

#include <duration.h>

List of all members.

Public Member Functions

 Duration ()
 Constructs a Duration with an initial value of 0.
 Duration (quint64 nanoSecs)
 Constructs a Duration with the given number of nanoseconds.
 Duration (const QString &duration)
 Constructs a copy of the other Duration.
int nanoSecs () const
 Returns the number of nanoseconds in the duration.
int seconds () const
 Returns the number of seconds in the duration.
int minutes () const
 Returns the number of minutes in the duration.
int hours () const
 Returns the number of hours in the duration.
int days () const
 Returns the number of days in the duration.
int weeks () const
 Returns the number of weeks in the duration.
int years () const
 Returns the number of years in the duration.
QString toString () const
 Returns a string representation of the duration using the following format: Y W D H M S.
quint64 toNanoSeconds () const
 Returns the Duration expressed in nanoseconds.
bool operator== (const Duration &other) const
 Returns true if this Duration is equal to the other Duration.

Static Public Member Functions

static bool isDuration (const QString &duration)
 Returns true if the string format used to represent the Duration is valid i.e. Y W D H M S , each being optional.

Static Public Attributes

static const qint64 NANOSECS_PER_MSEC = Q_INT64_C(1000000)
 Convenient time conversions.
static const qint64 NANOSECS_PER_SEC = 1000*NANOSECS_PER_MSEC
static const qint64 NANOSECS_PER_MIN = 60*NANOSECS_PER_SEC
static const qint64 NANOSECS_PER_HOUR = 60*NANOSECS_PER_MIN
static const qint64 NANOSECS_PER_DAY = 24*NANOSECS_PER_HOUR
static const qint64 NANOSECS_PER_WEEK = 7*NANOSECS_PER_DAY
static const qint64 SECS_PER_DAY = Q_INT64_C(86400)
static const qint64 MSECS_PER_DAY = 1000*SECS_PER_DAY
static const qint64 DAYS_PER_YEAR = 365
static const qint64 DAYS_PER_WEEK = 7

Private Attributes

quint64 totalNanoSecs_p
int nanoSecs_p
 the duration expressed in nanoseconds
int seconds_p
 the number of nanoseconds in the duration
int minutes_p
 the number of seconds in the duration
int hours_p
 the number of minutes in the duration
int days_p
 the number of hours in the duration
int weeks_p
 the number of days in the duration
int years_p
 the number of weeks in the duration


Detailed Description

The Duration class represents a period of elapsed time between two events.

A Duration object is created either by giving the number of nanoseconds explicitly or a string representation of a Duration.

The Duration object assumes the following definitions:

A year = 52 weeks and 1 day OR 365 days

A week = 7 days

A day = 24 hours

A hour = 60 minutes

A minute = 60 seconds

A second = 10e9 nanoseconds


Constructor & Destructor Documentation

Duration::Duration (  ) 

Constructs a Duration with an initial value of 0.

Duration::Duration ( quint64  nanoSecs  ) 

Constructs a Duration with the given number of nanoseconds.

Duration::Duration ( const QString &  duration  ) 

Constructs a copy of the other Duration.


Member Function Documentation

int Duration::nanoSecs (  )  const

Returns the number of nanoseconds in the duration.

int Duration::seconds (  )  const

Returns the number of seconds in the duration.

int Duration::minutes (  )  const

Returns the number of minutes in the duration.

int Duration::hours (  )  const

Returns the number of hours in the duration.

int Duration::days (  )  const

Returns the number of days in the duration.

int Duration::weeks (  )  const

Returns the number of weeks in the duration.

int Duration::years (  )  const

Returns the number of years in the duration.

QString Duration::toString (  )  const

Returns a string representation of the duration using the following format: Y W D H M S.

quint64 Duration::toNanoSeconds (  )  const

Returns the Duration expressed in nanoseconds.

bool Duration::operator== ( const Duration other  )  const

Returns true if this Duration is equal to the other Duration.

bool Duration::isDuration ( const QString &  duration  )  [static]

Returns true if the string format used to represent the Duration is valid i.e. Y W D H M S , each being optional.


Member Data Documentation

const qint64 Duration::NANOSECS_PER_MSEC = Q_INT64_C(1000000) [static]

Convenient time conversions.

const qint64 Duration::NANOSECS_PER_SEC = 1000*NANOSECS_PER_MSEC [static]

const qint64 Duration::NANOSECS_PER_MIN = 60*NANOSECS_PER_SEC [static]

const qint64 Duration::NANOSECS_PER_HOUR = 60*NANOSECS_PER_MIN [static]

const qint64 Duration::NANOSECS_PER_DAY = 24*NANOSECS_PER_HOUR [static]

const qint64 Duration::NANOSECS_PER_WEEK = 7*NANOSECS_PER_DAY [static]

const qint64 Duration::SECS_PER_DAY = Q_INT64_C(86400) [static]

const qint64 Duration::MSECS_PER_DAY = 1000*SECS_PER_DAY [static]

const qint64 Duration::DAYS_PER_YEAR = 365 [static]

const qint64 Duration::DAYS_PER_WEEK = 7 [static]

quint64 Duration::totalNanoSecs_p [private]

int Duration::nanoSecs_p [private]

the duration expressed in nanoseconds

int Duration::seconds_p [private]

the number of nanoseconds in the duration

int Duration::minutes_p [private]

the number of seconds in the duration

int Duration::hours_p [private]

the number of minutes in the duration

int Duration::days_p [private]

the number of hours in the duration

int Duration::weeks_p [private]

the number of days in the duration

int Duration::years_p [private]

the number of weeks in the duration


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

Generated on Sun Apr 21 16:11:51 2013 for libcontextsubscriber by  doxygen 1.5.6