The “Null” Sentinel
Sometimes it is convenient to have an RWDateTime that is valid yet holds no specific value. The Essential Tools Module includes the “null” state sentinel for this purpose. You can construct a null RWDateTime or use the constant RWDateTime::nullSentinel in construction by passing the constant RWDateTime::nullSentinel to the RWDateTime(rwint64) constructor. You can also use the constant in direct comparisons with the millisecond count returned by RWDateTime::milliSeconds().
Comparison operations for equality and inequality do work, with an RWDateTime in a “null” state always being less than a valid RWDateTime. Arithmetic manipulation of a null RWDateTime results in an invalid RWDateTime. Attempts to use any part extraction functions (day(), month(), extract(), etc.) result in an RWInternalErr being thrown. The asString() family of functions always return the string NULL when called for a null RWDateTime.
The following examples show how to construct an RWDateTime with a null state, and demonstrate what happens when it is used in an arithmetic operation:
 
// construct dt1 with null state:
RWDateTime dt1(RWDateTime::null);
 
// construct dt2 with null state
RWDateTime dt2(RWDateTime::nullSentinel);
 
// attempted arithmetic manipulation:
assert(dt2.isValid());
dt2.incrementMillisecond(23); // dt2 set to invalid state
assert(dt2.isValid()); // invalid