kplato

#include <kptduration.h>

Public Types

enum  Format {
  Format_DayTime , Format_Day , Format_Hour , Format_HourFraction ,
  Format_i18nDayTime , Format_i18nDay , Format_i18nHour , Format_i18nHourFraction
}
 
enum  Unit {
  Unit_d , Unit_h , Unit_m , Unit_s ,
  Unit_ms
}
 

Public Member Functions

 Duration (const Duration &d)
 
 Duration (unsigned d, unsigned h, unsigned m, unsigned s=0, unsigned ms=0)
 
 Duration (TQ_INT64 seconds)
 
void addMilliseconds (TQ_INT64 delta)
 
void addSeconds (TQ_INT64 delta)
 
void addMinutes (TQ_INT64 delta)
 
void addHours (TQ_INT64 delta)
 
void addDays (TQ_INT64 delta)
 
TQ_INT64 milliseconds () const
 
TQ_INT64 seconds () const
 
TQ_INT64 minutes () const
 
unsigned hours () const
 
unsigned days () const
 
void get (unsigned *days, unsigned *hours, unsigned *minutes, unsigned *seconds=0, unsigned *milliseconds=0) const
 
bool operator== (const Duration &d) const
 
bool operator== (TQ_INT64 d) const
 
bool operator!= (const Duration &d) const
 
bool operator!= (TQ_INT64 d) const
 
bool operator< (const Duration &d) const
 
bool operator< (TQ_INT64 d) const
 
bool operator<= (const Duration &d) const
 
bool operator<= (TQ_INT64 d) const
 
bool operator> (const Duration &d) const
 
bool operator> (TQ_INT64 d) const
 
bool operator>= (const Duration &d) const
 
bool operator>= (TQ_INT64 d) const
 
Duration & operator= (const Duration &d)
 
Duration operator* (int unit) const
 
Duration operator* (const double value) const
 
Duration operator/ (int unit) const
 
double operator/ (const Duration &d) const
 
Duration operator+ (const Duration &d) const
 
Duration & operator+= (const Duration &d)
 
Duration operator- (const Duration &d) const
 
Duration & operator-= (const Duration &d)
 
TQString toString (Format format=Format_DayTime) const
 
double toDouble (Unit u=Unit_ms) const
 

Static Public Member Functions

static Duration fromString (const TQString &s, Format format=Format_DayTime, bool *ok=0)
 

Static Public Attributes

static const Duration zeroDuration
 

Detailed Description

The duration class can be used to store a timespan in a convenient format.

The timespan can be in length in many many hours down to miliseconds.

Definition at line 34 of file kptduration.h.

Member Enumeration Documentation

◆ Format

DayTime = d hh:mm:ss.sss Day = d.ddd Hour = hh:mm HourFraction = h.fraction of an hour.

Definition at line 42 of file kptduration.h.

◆ Unit

enum KPlato::Duration::Unit

Definition at line 113 of file kptduration.h.

Constructor & Destructor Documentation

◆ Duration() [1/4]

KPlato::Duration::Duration ( )

Definition at line 35 of file kptduration.cpp.

◆ Duration() [2/4]

KPlato::Duration::Duration ( const Duration &  d)

Definition at line 39 of file kptduration.cpp.

◆ Duration() [3/4]

KPlato::Duration::Duration ( unsigned  d,
unsigned  h,
unsigned  m,
unsigned  s = 0,
unsigned  ms = 0 
)

Definition at line 43 of file kptduration.cpp.

◆ Duration() [4/4]

KPlato::Duration::Duration ( TQ_INT64  seconds)

Definition at line 51 of file kptduration.cpp.

◆ ~Duration()

KPlato::Duration::~Duration ( )

Definition at line 55 of file kptduration.cpp.

Member Function Documentation

◆ addDays()

void KPlato::Duration::addDays ( TQ_INT64  delta)
inline

Adds.

Parameters
deltato *this. If
delta> *this, *this is set to zeroDuration.

Definition at line 73 of file kptduration.h.

◆ addHours()

void KPlato::Duration::addHours ( TQ_INT64  delta)
inline

Adds.

Parameters
deltato *this. If
delta> *this, *this is set to zeroDuration.

Definition at line 68 of file kptduration.h.

◆ addMilliseconds()

void KPlato::Duration::addMilliseconds ( TQ_INT64  delta)
inline

Adds.

Parameters
deltato *this. If
delta> *this, *this is set to zeroDuration.

Definition at line 53 of file kptduration.h.

◆ addMinutes()

void KPlato::Duration::addMinutes ( TQ_INT64  delta)
inline

Adds.

Parameters
deltato *this. If
delta> *this, *this is set to zeroDuration.

Definition at line 63 of file kptduration.h.

◆ addSeconds()

void KPlato::Duration::addSeconds ( TQ_INT64  delta)
inline

Adds.

Parameters
deltato *this. If
delta> *this, *this is set to zeroDuration.

Definition at line 58 of file kptduration.h.

◆ days()

unsigned KPlato::Duration::days ( ) const
inline

Definition at line 80 of file kptduration.h.

◆ fromString()

Duration KPlato::Duration::fromString ( const TQString &  s,
Format  format = Format_DayTime,
bool *  ok = 0 
)
static

Definition at line 190 of file kptduration.cpp.

◆ get()

void KPlato::Duration::get ( unsigned *  days,
unsigned *  hours,
unsigned *  minutes,
unsigned *  seconds = 0,
unsigned *  milliseconds = 0 
) const

Definition at line 235 of file kptduration.cpp.

◆ hours()

unsigned KPlato::Duration::hours ( ) const
inline

Definition at line 79 of file kptduration.h.

◆ milliseconds()

TQ_INT64 KPlato::Duration::milliseconds ( ) const
inline

Definition at line 76 of file kptduration.h.

◆ minutes()

TQ_INT64 KPlato::Duration::minutes ( ) const
inline

Definition at line 78 of file kptduration.h.

◆ operator!=() [1/2]

bool KPlato::Duration::operator!= ( const Duration &  d) const
inline

Definition at line 85 of file kptduration.h.

◆ operator!=() [2/2]

bool KPlato::Duration::operator!= ( TQ_INT64  d) const
inline

Definition at line 86 of file kptduration.h.

◆ operator*() [1/2]

Duration KPlato::Duration::operator* ( const double  value) const

Definition at line 103 of file kptduration.cpp.

◆ operator*() [2/2]

Duration KPlato::Duration::operator* ( int  unit) const

Definition at line 81 of file kptduration.cpp.

◆ operator+()

Duration KPlato::Duration::operator+ ( const Duration &  d) const
inline

Definition at line 101 of file kptduration.h.

◆ operator+=()

Duration & KPlato::Duration::operator+= ( const Duration &  d)
inline

Definition at line 103 of file kptduration.h.

◆ operator-()

Duration KPlato::Duration::operator- ( const Duration &  d) const
inline

Definition at line 105 of file kptduration.h.

◆ operator-=()

Duration & KPlato::Duration::operator-= ( const Duration &  d)
inline

Definition at line 107 of file kptduration.h.

◆ operator/() [1/2]

double KPlato::Duration::operator/ ( const Duration &  d) const

Definition at line 109 of file kptduration.cpp.

◆ operator/() [2/2]

Duration KPlato::Duration::operator/ ( int  unit) const

Definition at line 92 of file kptduration.cpp.

◆ operator<() [1/2]

bool KPlato::Duration::operator< ( const Duration &  d) const
inline

Definition at line 87 of file kptduration.h.

◆ operator<() [2/2]

bool KPlato::Duration::operator< ( TQ_INT64  d) const
inline

Definition at line 88 of file kptduration.h.

◆ operator<=() [1/2]

bool KPlato::Duration::operator<= ( const Duration &  d) const
inline

Definition at line 89 of file kptduration.h.

◆ operator<=() [2/2]

bool KPlato::Duration::operator<= ( TQ_INT64  d) const
inline

Definition at line 90 of file kptduration.h.

◆ operator=()

Duration & KPlato::Duration::operator= ( const Duration &  d)
inline

Definition at line 95 of file kptduration.h.

◆ operator==() [1/2]

bool KPlato::Duration::operator== ( const Duration &  d) const
inline

Definition at line 83 of file kptduration.h.

◆ operator==() [2/2]

bool KPlato::Duration::operator== ( TQ_INT64  d) const
inline

Definition at line 84 of file kptduration.h.

◆ operator>() [1/2]

bool KPlato::Duration::operator> ( const Duration &  d) const
inline

Definition at line 91 of file kptduration.h.

◆ operator>() [2/2]

bool KPlato::Duration::operator> ( TQ_INT64  d) const
inline

Definition at line 92 of file kptduration.h.

◆ operator>=() [1/2]

bool KPlato::Duration::operator>= ( const Duration &  d) const
inline

Definition at line 93 of file kptduration.h.

◆ operator>=() [2/2]

bool KPlato::Duration::operator>= ( TQ_INT64  d) const
inline

Definition at line 94 of file kptduration.h.

◆ seconds()

TQ_INT64 KPlato::Duration::seconds ( ) const
inline

Definition at line 77 of file kptduration.h.

◆ toDouble()

double KPlato::Duration::toDouble ( Unit  u = Unit_ms) const
inline

Definition at line 114 of file kptduration.h.

◆ toString()

TQString KPlato::Duration::toString ( Format  format = Format_DayTime) const

Definition at line 117 of file kptduration.cpp.

Member Data Documentation

◆ zeroDuration

const Duration KPlato::Duration::zeroDuration
static

This is useful for occasions where we need a zero duration.

Definition at line 126 of file kptduration.h.


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