Tools.h++ Manual
21-90 104011 Tandem Computers Incorporated
21
RWDate
Synopsis
#include <rw/rwdate.h>
RWDate a; // Construct today's date
Description 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.
RWDate
's can be converted to and from
RWTime
's, and to and from the
Standard C library type
struct tm
defined in
<time.h>
.
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. If
this is an issue, declare your arrays with a class derived from
RWDate
that
provides a faster constructor.
class FastDate : public RWDate
{
public:
FastDate() : RWDate(0) {;}
//Constructs an “invalid” date by default
};
Example
#include <rw/rwdate.h>
#include <rw/rstream.h>
main()
{
// Today's date
RWDate d;
// Last Sunday's date:
RWDate lastSunday = d.previous("Sunday");
cout << d << endl << lastSunday << endl;
}