SourcePro C++ 13.0 |
SourcePro® C++ API Reference Guide |
Product Documentation: SourcePro C++ Documentation Home |
Represents a time span in number of seconds. More...
#include <rw/db/duration.h>
Public Member Functions | |
RWDBDuration () | |
RWDBDuration (int yr, int mth=0, int day=0, int hr=0, int min=0, int sec=0, int msec=0) | |
RWDBDuration (double seconds) | |
RWDBDuration (const RWDBDuration &d) | |
void | addDays (int days) |
void | addHours (int hours) |
void | addMilliseconds (int milliseconds) |
void | addMinutes (int minutes) |
void | addRWMonths (int months) |
void | addRWYears (int years) |
void | addSeconds (int seconds) |
void | addWeeks (int weeks) |
double | asDays () const |
double | asHours () const |
double | asMilliseconds () const |
double | asMinutes () const |
double | asRWMonths () const |
double | asRWYears () const |
double | asSeconds () const |
RWCString | asString () const |
double | asWeeks () const |
RWspace | binaryStoreSize () const |
int | compareTo (const RWDBDuration *d) const |
unsigned | hash () const |
bool | isEqual (const RWDBDuration *d) const |
RWDBDuration & | operator*= (double factor) |
RWDBDuration & | operator+= (const RWDBDuration &duration) |
RWDBDuration & | operator+= (double seconds) |
RWDBDuration | operator- () const |
RWDBDuration & | operator-= (const RWDBDuration &duration) |
RWDBDuration & | operator-= (double seconds) |
RWDBDuration & | operator/= (double divisor) |
RWDBDuration & | operator= (const RWDBDuration &dur) |
void | restoreFrom (RWFile &file) |
void | restoreFrom (RWvistream &vis) |
void | saveOn (RWFile &file) const |
void | saveOn (RWvostream &vos) const |
Static Public Attributes | |
static const double | DUR_MILLISECONDS_PER_SEC |
static const double | DUR_SECONDS_PER_DAY |
static const double | DUR_SECONDS_PER_HR |
static const double | DUR_SECONDS_PER_MIN |
static const double | DUR_SECONDS_PER_RWMTH |
static const double | DUR_SECONDS_PER_RWYR |
static const double | DUR_SECONDS_PER_WEEK |
Friends | |
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- (RWDBDuration &a, const RWDBDuration &b) |
RWDBDuration | operator- (RWDBDuration &duration, double seconds) |
RWDBDuration | operator- (const RWDBDateTime &a, const RWDBDateTime &b) |
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:
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.
RWDBDuration::RWDBDuration | ( | ) |
Default constructor. Constructs an RWDBDuration of zero length.
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::RWDBDuration | ( | double | seconds | ) |
Constructs an RWDBDuration that takes a time span stored in a double as a number of seconds.
RWDBDuration::RWDBDuration | ( | const RWDBDuration & | d | ) |
Copy constructor. RWDBDuration obeys value semantics.
void RWDBDuration::addDays | ( | int | days | ) |
Adds the given number of days to self.
void RWDBDuration::addHours | ( | int | hours | ) |
Adds the given number of hours to self.
void RWDBDuration::addMilliseconds | ( | int | milliseconds | ) |
Adds the given number of milliseconds to self.
void RWDBDuration::addMinutes | ( | int | minutes | ) |
Adds the given number of minutes to self.
void RWDBDuration::addRWMonths | ( | int | months | ) |
Adds the given number of months to self.
void RWDBDuration::addRWYears | ( | int | years | ) |
Adds the given number of years to self.
void RWDBDuration::addSeconds | ( | int | seconds | ) |
Adds the given number of seconds to self.
void RWDBDuration::addWeeks | ( | int | weeks | ) |
Adds the given number of weeks to self.
double RWDBDuration::asDays | ( | ) | const |
Returns self converted to days.
double RWDBDuration::asHours | ( | ) | const |
Returns self converted to hours.
double RWDBDuration::asMilliseconds | ( | ) | const |
Returns self converted to milliseconds.
double RWDBDuration::asMinutes | ( | ) | const |
Returns self converted to minutes.
double RWDBDuration::asRWMonths | ( | ) | const |
Returns self converted to months.
double RWDBDuration::asRWYears | ( | ) | const |
Returns self converted to years.
double RWDBDuration::asSeconds | ( | ) | const |
Returns self converted to seconds.
RWCString RWDBDuration::asString | ( | ) | const |
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.
double RWDBDuration::asWeeks | ( | ) | const |
Returns self converted to weeks.
RWspace RWDBDuration::binaryStoreSize | ( | ) | const |
Returns the number of bytes required to store self.
int RWDBDuration::compareTo | ( | const RWDBDuration * | d | ) | const |
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.
unsigned RWDBDuration::hash | ( | ) | const |
Returns a value suitable for hashing.
bool RWDBDuration::isEqual | ( | const RWDBDuration * | d | ) | const |
Returns true
if compareTo(this, d) == 0
, otherwise returns false
.
RWDBDuration& RWDBDuration::operator*= | ( | double | factor | ) |
Multiplies self by factor and returns the result.
RWDBDuration& RWDBDuration::operator+= | ( | const RWDBDuration & | duration | ) |
Adds duration to self and returns the result.
RWDBDuration& RWDBDuration::operator+= | ( | double | seconds | ) |
Adds seconds to self and returns the result.
RWDBDuration RWDBDuration::operator- | ( | ) | const |
Unary minus. Returns the negation of self.
RWDBDuration& RWDBDuration::operator-= | ( | const RWDBDuration & | duration | ) |
Subtracts duration from self and returns the result.
RWDBDuration& RWDBDuration::operator-= | ( | double | seconds | ) |
Subtracts seconds from self and returns the result.
RWDBDuration& RWDBDuration::operator/= | ( | double | divisor | ) |
Divides self by divisor and returns the result.
RWDBDuration& RWDBDuration::operator= | ( | const RWDBDuration & | dur | ) |
Assignment operator. RWDBDuration obeys value semantics.
void RWDBDuration::restoreFrom | ( | RWFile & | file | ) |
Reads file, replacing contents of self.
void RWDBDuration::restoreFrom | ( | RWvistream & | vis | ) |
Reads vis, replacing contents of self.
void RWDBDuration::saveOn | ( | RWFile & | file | ) | const |
Writes the contents of self to file.
void RWDBDuration::saveOn | ( | RWvostream & | vos | ) | const |
Writes the contents of self to vos.
|
friend |
Returns true
if a and b are not exactly equal, otherwise returns false
.
|
friend |
Returns the result of multiplying duration by factor.
|
friend |
Returns the result of adding a and b.
|
friend |
Adds seconds to duration and returns the result.
|
friend |
Returns the result of subtracting b from a.
|
friend |
Subtracts seconds from duration and returns the result.
|
friend |
RWDBDuration((<RWDateTime_instance1> - <RWDateTime_instance2>)/1000.0);
.Returns the duration between RWDBDateTime objects a and b.
|
friend |
Returns the result of dividing duration by divisor.
|
friend |
Returns true
if a is less than b, otherwise returns false
.
|
friend |
Returns true
if a is less than or equal to b, otherwise returns false
.
|
friend |
Returns true
if a and b are exactly equal, otherwise returns false
.
|
friend |
Returns true
if a is greater than b, otherwise returns false
.
|
friend |
Returns true
if a is greater than or equal to b, otherwise returns false
.
|
static |
Static constant double
with value 1000.0
, used in arithmetic operations involving the imprecise quantities months and years.
|
static |
Static constant double
with value 86400.0
, used in arithmetic operations involving the imprecise quantities months and years.
|
static |
Static constant double
with value 3600.0
, used in arithmetic operations involving the imprecise quantities months and years.
|
static |
Static constant double
with value 60.0
, used in arithmetic operations involving the imprecise quantities months and years.
|
static |
Static constant double
with value 2419200.0
, used in arithmetic operations involving the imprecise quantities months and years.
|
static |
Static constant double
with value 29030400.0
, used in arithmetic operations involving the imprecise quantities months and years.
|
static |
Static constant double
with value 604800.0
, used in arithmetic operations involving the imprecise quantities months and years.
Copyright © 2014 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.