The details of RW_CENTURY_REQD

Article ID: 978
Last updated: 01 Feb, 2008
Article ID: 978
Last updated: 01 Feb, 2008
Revision: 1
Views: 4205
Posted: 08 Dec, 1999
by Dean J.
Updated: 01 Feb, 2008
by Dean J.
Problem


Software Parts Manager (SPM) asks customer about RW_CENTRUY_REQD macro during the Build phase of Tools.h++. Failure to use this macro can manifest itself with coredumps or assertion failures when two digit dates are entered (see below)


Cause


The SPM is prompting the user to answer whether or not it should enable the RW_CENTURY_REQD macro. This macro, when enabled will tell Tools.h++ to fail at runtime if a two digit date is entered into any RWDate or RWDBDate object. This is intentional and is to ensure four digit dates are entered (for Y2K compliance).


Action


This macro guards certain parts of the Tools (RWDate and RWLocale) and DBTools (RWDBDate) code that, when set to 1 (enabled) will run code testing for four digit years (>= 100). In the debug version, this is coded as an assertion (assert date >= 100). In release, this assertion fails at runtime with a core.

Customers receiving cores or assertion failures when a two digit date is entered should check if the RW_CENTURY_REQD macro is set. If it is, they should only provide four digit years to the program.

Please note that this is an assertion, not an exception. This means that it cannot be caught by an error handler routine. This makes the macro useful with inhouse code testing but almost impossible to implement in user code where any user can enter a two digit number for a year and get a core dump. This should, of course, be checked by the developer with an if statement before the end user can fail this assertion (i.e. before the value is given to RWDate).

This article was:   Helpful | Not helpful
Report an issue
Article ID: 978
Last updated: 01 Feb, 2008
Revision: 1
Views: 4205
Posted: 08 Dec, 1999 by Dean J.
Updated: 01 Feb, 2008 by Dean J.

Others in this category