Represents a time span in number of seconds.
More...
#include <rw/db/duration.h>
|
bool | operator!= (const RWDBDuration &a, const RWDBDuration &b) |
|
RWDBDuration | operator* (RWDBDuration &duration, double factor) |
|
RWDBDuration | operator+ (RWDBDuration &a, const RWDBDuration &b) |
|
RWDBDuration | operator+ (RWDBDuration &duration, double seconds) |
|
RWDBDuration | operator- (const RWDBDateTime &a, const RWDBDateTime &b) |
|
RWDBDuration | operator- (RWDBDuration &a, const RWDBDuration &b) |
|
RWDBDuration | operator- (RWDBDuration &duration, double seconds) |
|
RWDBDuration | operator/ (RWDBDuration &duration, double divisor) |
|
bool | operator< (const RWDBDuration &a, const RWDBDuration &b) |
|
bool | operator<= (const RWDBDuration &a, const RWDBDuration &b) |
|
bool | operator== (const RWDBDuration &a, const RWDBDuration &b) |
|
bool | operator> (const RWDBDuration &a, const RWDBDuration &b) |
|
bool | operator>= (const RWDBDuration &a, const RWDBDuration &b) |
|
RWDBDuration represents a time span, stored in a double
as number of seconds.
RWDBDuration supports arithmetic operations involving the imprecise quantities months and years. As a reminder, the terms RWMonth and RWYear are used in some member function names. The following conversions are used:
((double)3600.0);
((double)86400.0);
((double)604800.0);
((double)2419200.0);
((double)29030400.0);
static const double DUR_SECONDS_PER_WEEK
Definition duration.h:414
static const double DUR_SECONDS_PER_RWYR
Definition duration.h:427
static const double DUR_MILLISECONDS_PER_SEC
Definition duration.h:390
static const double DUR_SECONDS_PER_MIN
Definition duration.h:396
static const double DUR_SECONDS_PER_RWMTH
Definition duration.h:420
static const double DUR_SECONDS_PER_HR
Definition duration.h:402
static const double DUR_SECONDS_PER_DAY
Definition duration.h:408
For example, adding one RWMonth to an RWDBDuration adds four weeks' worth of seconds to the duration, regardless of the number of weeks in any particular month.
- Synopsis
#include <rw/db/duration.h>
Represents a time span in number of seconds.
Definition duration.h:66
◆ RWDBDuration() [1/4]
RWDBDuration::RWDBDuration |
( |
| ) |
|
Default constructor. Constructs an RWDBDuration of zero length.
◆ RWDBDuration() [2/4]
RWDBDuration::RWDBDuration |
( |
int | yr, |
|
|
int | mth = 0, |
|
|
int | day = 0, |
|
|
int | hr = 0, |
|
|
int | min = 0, |
|
|
int | sec = 0, |
|
|
int | msec = 0 ) |
Constructs an RWDBDuration that is the sum of the supplied parts, according to the conversions listed above.
◆ RWDBDuration() [3/4]
RWDBDuration::RWDBDuration |
( |
double | seconds | ) |
|
Constructs an RWDBDuration that takes a time span stored in a double as a number of seconds.
◆ RWDBDuration() [4/4]
◆ addDays()
void RWDBDuration::addDays |
( |
int | days | ) |
|
Adds the given number of days to self.
◆ addHours()
void RWDBDuration::addHours |
( |
int | hours | ) |
|
Adds the given number of hours to self.
◆ addMilliseconds()
void RWDBDuration::addMilliseconds |
( |
int | milliseconds | ) |
|
Adds the given number of milliseconds to self.
◆ addMinutes()
void RWDBDuration::addMinutes |
( |
int | minutes | ) |
|
Adds the given number of minutes to self.
◆ addRWMonths()
void RWDBDuration::addRWMonths |
( |
int | months | ) |
|
Adds the given number of months to self.
◆ addRWYears()
void RWDBDuration::addRWYears |
( |
int | years | ) |
|
Adds the given number of years to self.
◆ addSeconds()
void RWDBDuration::addSeconds |
( |
int | seconds | ) |
|
Adds the given number of seconds to self.
◆ addWeeks()
void RWDBDuration::addWeeks |
( |
int | weeks | ) |
|
Adds the given number of weeks to self.
◆ asDays()
double RWDBDuration::asDays |
( |
| ) |
const |
Returns self converted to days.
◆ asHours()
double RWDBDuration::asHours |
( |
| ) |
const |
Returns self converted to hours.
◆ asMilliseconds()
double RWDBDuration::asMilliseconds |
( |
| ) |
const |
Returns self converted to milliseconds.
◆ asMinutes()
double RWDBDuration::asMinutes |
( |
| ) |
const |
Returns self converted to minutes.
◆ asRWMonths()
double RWDBDuration::asRWMonths |
( |
| ) |
const |
Returns self converted to months.
◆ asRWYears()
double RWDBDuration::asRWYears |
( |
| ) |
const |
Returns self converted to years.
◆ asSeconds()
double RWDBDuration::asSeconds |
( |
| ) |
const |
Returns self converted to seconds.
◆ asString()
Returns a string of the format # interval
, where the interval is determined by the modularity of the duration, that is, days, seconds, etc. Applications should interpret the actual contents of the interval, and format a string appropriately.
◆ asWeeks()
double RWDBDuration::asWeeks |
( |
| ) |
const |
Returns self converted to weeks.
◆ binaryStoreSize()
RWspace RWDBDuration::binaryStoreSize |
( |
| ) |
const |
Returns the number of bytes required to store self.
◆ compareTo()
Returns -1
, 0
, or 1
depending upon whether self is less than, equal to, or greater than the RWDBDuration addressed by d.
As a precondition, d is tested to determine if it is a null pointer. If null, the method asserts in debug mode, and throws RWInternalErr in optimized builds.
◆ hash()
unsigned RWDBDuration::hash |
( |
| ) |
const |
Returns a value suitable for hashing.
◆ isEqual()
◆ operator*=()
Multiplies self by factor and returns the result.
◆ operator+=() [1/2]
Adds duration to self and returns the result.
◆ operator+=() [2/2]
Adds seconds to self and returns the result.
◆ operator-()
Unary minus. Returns the negation of self.
◆ operator-=() [1/2]
Subtracts duration from self and returns the result.
◆ operator-=() [2/2]
Subtracts seconds from self and returns the result.
◆ operator/=()
Divides self by divisor and returns the result.
◆ operator=()
◆ restoreFrom() [1/2]
void RWDBDuration::restoreFrom |
( |
RWFile & | file | ) |
|
Reads file, replacing contents of self.
◆ restoreFrom() [2/2]
void RWDBDuration::restoreFrom |
( |
RWvistream & | vis | ) |
|
Reads vis, replacing contents of self.
◆ saveOn() [1/2]
void RWDBDuration::saveOn |
( |
RWFile & | file | ) |
const |
Writes the contents of self to file.
◆ saveOn() [2/2]
void RWDBDuration::saveOn |
( |
RWvostream & | vos | ) |
const |
Writes the contents of self to vos.
◆ operator!=
Returns true
if a and b are not exactly equal, otherwise returns false
.
◆ operator*
Returns the result of multiplying duration by factor.
◆ operator+ [1/2]
Returns the result of adding a and b.
◆ operator+ [2/2]
Adds seconds to duration and returns the result.
◆ operator- [1/3]
◆ operator- [2/3]
Returns the result of subtracting b from a.
◆ operator- [3/3]
Subtracts seconds from duration and returns the result.
◆ operator/
Returns the result of dividing duration by divisor.
◆ operator<
Returns true
if a is less than b, otherwise returns false
.
◆ operator<=
Returns true
if a is less than or equal to b, otherwise returns false
.
◆ operator==
Returns true
if a and b are exactly equal, otherwise returns false
.
◆ operator>
Returns true
if a is greater than b, otherwise returns false
.
◆ operator>=
Returns true
if a is greater than or equal to b, otherwise returns false
.
◆ DUR_MILLISECONDS_PER_SEC
const double RWDBDuration::DUR_MILLISECONDS_PER_SEC |
|
static |
Static constant double
with value 1000.0
, used in arithmetic operations involving the imprecise quantities months and years.
◆ DUR_SECONDS_PER_DAY
const double RWDBDuration::DUR_SECONDS_PER_DAY |
|
static |
Static constant double
with value 86400.0
, used in arithmetic operations involving the imprecise quantities months and years.
◆ DUR_SECONDS_PER_HR
const double RWDBDuration::DUR_SECONDS_PER_HR |
|
static |
Static constant double
with value 3600.0
, used in arithmetic operations involving the imprecise quantities months and years.
◆ DUR_SECONDS_PER_MIN
const double RWDBDuration::DUR_SECONDS_PER_MIN |
|
static |
Static constant double
with value 60.0
, used in arithmetic operations involving the imprecise quantities months and years.
◆ DUR_SECONDS_PER_RWMTH
const double RWDBDuration::DUR_SECONDS_PER_RWMTH |
|
static |
Static constant double
with value 2419200.0
, used in arithmetic operations involving the imprecise quantities months and years.
◆ DUR_SECONDS_PER_RWYR
const double RWDBDuration::DUR_SECONDS_PER_RWYR |
|
static |
Static constant double
with value 29030400.0
, used in arithmetic operations involving the imprecise quantities months and years.
◆ DUR_SECONDS_PER_WEEK
const double RWDBDuration::DUR_SECONDS_PER_WEEK |
|
static |
Static constant double
with value 604800.0
, used in arithmetic operations involving the imprecise quantities months and years.