Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

RWDBDuration


RWDBDuration RWCollectable

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/db/duration.h>

RWDBDuration d;      // construct zero length duration
RWDBDuration d(2,4); // construct duration of 2 years 
                     // and 4 months

Description

RWDBDuration represents a time span, stored in a double as a 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:

#define RWDB_MILLISECONDS_PER_SEC ((double)1000.0)
#define RWDB_SECONDS_PER_MIN      ((double)60.0)
#define RWDB_SECONDS_PER_HR       (RWDB_SECONDS_PER_MIN *
                                   60.0)
#define RWDB_SECONDS_PER_DAY      (RWDB_SECONDS_PER_HR *
                                   24.0)
#define RWDB_SECONDS_PER_WEEK     (RWDB_SECONDS_PER_DAY *
                                   7.0)
#define RWDB_SECONDS_PER_RWMTH    (RWDB_SECONDS_PER_WEEK *
                                   4.0)
#define RWDB_SECONDS_PER_RWYR     (RWDB_SECONDS_PER_RWMTH *
                                   12.0)

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.

Public Enum and Defines

enum DurationType {
    milliseconds,
    seconds,
    minutes,
    hours,
    days,
    weeks,
    months,
    years
};

Public Constructors

RWDBDuration();
RWDBDuration(double numSec);
RWDBDuration(int years, int rwmonths = 0, 
             int days = 0, int hours = 0, 
             int minutes = 0,
             int seconds = 0,
             int milliseconds = 0);
RWDBDuration(const RWDBDuration& d);

Public Member Functions

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;
double
asWeeks() const;
RWCString
asString() const;
RWspace
binaryStoreSize() const;
int
compareTo(const RWDBDuration* d) const;
unsigned
hash() const;
RWBoolean
isEqual(const RWDBDuration* d) const;
void
restoreFrom(RWFile& file);
void
restoreFrom(RWvistream& vis);
void
saveOn(RWFile& file) const;
void
saveOn(RWvostream& vos) const;

Public Member Operators

RWDBDuration&
operator=(const RWDBDuration& dur);
RWDBDuration
operator-();
RWDBDuration&
operator+=(const RWDBDuration& duration);
RWDBDuration&
operator+=(double seconds);
RWDBDuration&
operator-=(const RWDBDuration& duration);
RWDBDuration&
operator-=(double seconds);
RWDBDuration&
operator*=(double factor);
RWDBDuration&
operator/=(double divisor);

Related Global Operators

RWBoolean
operator==(const RWDBDuration& a, const RWDBDuration& b);
RWBoolean
operator!=(const RWDBDuration& a, const RWDBDuration& b);
RWBoolean
operator>(const RWDBDuration& a, const RWDBDuration& b);
RWBoolean
operator>=(const RWDBDuration& a, const RWDBDuration& b);
RWBoolean
operator<(const RWDBDuration& a, const RWDBDuration& b);
RWBoolean
operator<=(const RWDBDuration& a, const RWDBDuration& b);
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*(RWDBDuration& duration, double factor);
RWDBDuration
operator/(RWDBDuration& duration, double divisor);
RWDBDuration
operator-(const RWDBDateTime& a, const RWDBDateTime& b);


Previous fileTop of DocumentContentsIndexNext file

©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.