RWDate
See the
SourcePro API Reference Guide for a complete description of
RWDate.
NOTE: RWDate is unable to store dates prior to 1 Jan 1901.
An
RWDate represents a particular date with no associated time, time zone or DST transitions. It is just a date — such as date of birth — so it does not change depending on the time zone or locale in which it is used. Calculations that happen on a value in this class are on the granularity of days. If you need a date and a time, use
RWDateTime.
You can construct an
RWDate in several ways:
With the current date:
RWDate d;
This is the default constructor for
RWDate. Because this method of construction must check the system date each time it creates an instance of an
RWDate, constructing a large array of
RWDate can be very slow. You should consider using
RWDateTime in such cases.
For a given day of the month (1-31), month number (1-12) and year. Although the class supports 2-digit year specifiers, we urge you to use the 4-digit variety if possible to avoid confusion:
RWDate d1(1, 24, 2001) // 1/24/2001
RWDate d2(1, 24, 01) // 1/24/1901 (oops!)
Using locale-specific strings. If you do nothing, a default locale using United States conventions and names is applied:
RWDate d1(10, “June”, 2001); // 6/10/2001
Using French month names. Assuming your system supports a French locale, you could construct an
RWDate with the following:
RWDate d2(“10 Juin 2025”) // 6/10/2025
For detailed examples on using locales, see
Chapter 7.
NOTE: Note that the default format for an
RWDate on many systems and in many locales contains only a two-digit year. You can enforce the use of a four-digit year by defining the build macro
RW_CENTURY_REQD in RCB when building the libraries. See
About Two or Four Digit Years in the section on
RWDateTime.