Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Tools Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWDate (deprecated)

Module:  Essential Tools Module   Group:  Date and Time Classes


Does not inherit

Local Index

Members

Non-Members

Synopsis

#include <rw/rwdate.h>
RWDate a;   // Construct today's date

Description


NOTE -- RWDate is deprecated and is no longer supported. Be aware that it may be removed in a future release. Please use RWDateTime instead. RWDateTime combines the functionality of RWDate and RWTime, but with a much greater range and millisecond accuracy.

Class RWDate represents a date, stored as a Julian day number. The member function isValid() can be used to determine whether an RWDate is a valid date. For example, isValid() would return false for the date 29 February 1991 because 1991 is not a leap year. See the chapter on date and time classes in the Essential Tools Module User's Guide.


NOTE -- If you are converting an RWDate to an RWTime, be aware that the RWTime object cannot represent dates before 1 Jan 1901, and can represent dates only up to the year 2037.

RWDates can be converted to and from RWTimes, and to and from the Standard C Library type struct tm defined in <time.h>.

We recommend creating programs that use 4-digit year specifiers.

Note that because the default constructor for this class creates an instance holding the current date, constructing a large array of RWDate may be slow.

Those with access to the C++ Standard Library-based versions of the Essential Tools Module template collections should consider the following:

Thanks to the smart allocation scheme of the standard collections, the above declaration results in only one call to the default constructor followed by 5000 invocations of the copy constructor. In the case of RWDate, the copy constructor amounts to an assignment of one long to another, resulting in faster creation than the simple array.

Persistence

Simple

Example

Program output (where the number of days since ENIAC was turned on obviously depends on the date the program is run):

Public Constructors

RWDate();
RWDate(const RWDate&);
RWDate(unsigned day, unsigned year);
RWDate(unsigned day, unsigned month, unsigned year);
RWDate(unsigned day, const char* mon, unsigned year,
       const RWLocale& locale = RWLocale::global());
RWDate(istream& s,const RWLocale& locale = 
       RWLocale::global());
RWDate(const RWCString& str, 
       const RWLocale& locale = RWLocale::global());
RWDate(const RWTime& t, 
       const RWZone& zone = RWZone::local());
RWDate(const struct tm*);
RWDate(unsigned long jd);

Public Member Operators

RWDate&
operator=(const RWDate&);
RWDate
operator++();
RWDate
operator--();
RWDate
operator++(int);
RWDate
operator--(int);
RWDate&
operator+=(unsigned long s);
RWDate&
operator-=(unsigned long s);

Public Member Functions

RWCString
asString(char format = 'x', 
         const RWLocale& = RWLocale::global()) const;
RWCString
asString(const char* format, 
         const RWLocale& = RWLocale::global()) const;
bool
between(const RWDate& a, const RWDate& b) const;
size_t
binaryStoreSize() const;
int
compareTo(const RWDate* d) const;
unsigned
day() const;
unsigned
dayOfMonth() const;
void
extract(struct tm*) const;
unsigned
firstDayOfMonth() const;
unsigned
firstDayOfMonth(unsigned month) const;
unsigned
hash() const;
bool
isValid() const;

NOTE -- The next two functions let you manipulate the date via Julian days. Note that the Julian day number is not the same as a date according to the Julian calendar. The Julian day number is calculated using Algorithm 199 from Communications of the ACM, Volume 6, No. 8, (Aug. 1963), p. 444 and is valid for any valid Gregorian date in the Gregorian calendar. The Essential Tools Module User's Guide provides more information.
unsigned long
julian() const;
void
julian(unsigned long j);
bool
leap() const;
RWDate
max(const RWDate& t) const;
RWDate
min(const RWDate& t) const;
unsigned
month() const;
RWCString
monthName(const RWLocale& = RWLocale::global()) const;
RWDate
next(unsigned dayNum) const;
RWDate
next(const char* dayName, 
     const RWLocale& = RWLocale::global()) const;
RWDate
previous(unsigned dayNum) const;
RWDate
previous(const char* dayName, 
         const RWLocale& = RWLocale::global()) const;
RWCString
weekDayName(const RWLocale& = RWLocale::global()) const;
unsigned
weekDay() const;
unsigned
year() const;

Static Public Member Functions

static unsigned
dayOfWeek(const char* dayName, 
          const RWLocale& = RWLocale::global());
static unsigned
daysInMonthYear(unsigned month, unsigned year);
static unsigned
daysInYear(unsigned year);
static bool
dayWithinMonth(unsigned monthNum, unsigned dayNum,
               unsigned year);
static unsigned
hash(const RWDate& d);
static unsigned
indexOfMonth(const char* monthName,
             const RWLocale& = RWLocale::global());
static unsigned long
jday(unsigned mon, unsigned day, unsigned year);
static RWCString
nameOfMonth(unsigned monNum, 
            const RWLocale& = RWLocale::global());
static bool
leapYear(unsigned year);
static RWDate
now();
static RWCString
weekDayName(unsigned const RWLocale& = RWLocale::global());

Related Global Operators

bool
operator<(const RWDate& d1, const RWDate& d2);
bool
operator<=(const RWDate& d1, const RWDate& d2);
bool
operator>(const RWDate& d1, const RWDate& d2);
bool
operator>=(const RWDate& d1, const RWDate& d2);
bool
operator==(const RWDate& d1, const RWDate& d2);
bool
operator!=(const RWDate& d1, const RWDate& d2);
RWDate
operator+(const RWDate& d, unsigned long s);
RWDate
operator+(unsigned long s, const RWDate& d);
unsigned long
operator-(const RWDate& d1, const RWDate& d2);
RWDate
operator-(const RWDate& d, unsigned long s);
ostream&
operator<<(ostream& s, const RWDate& d);
istream&
operator>>(istream& s, RWDate& t);
RWvostream&
operator<<(RWvostream&, const RWDate& date);
RWFile&
operator<<(RWFile&,     const RWDate& date);
RWvistream&
operator>>(RWvistream&, RWDate& date);
RWFile&
operator>>(RWFile&,     RWDate& date);


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright 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.
Contact Rogue Wave about documentation or support issues.