SourcePro Core : Essential Tools Module User's Guide : Date and Time Classes : RWDateTime : RWDateTime Sentinels : The “Invalid” Sentinel and Other Invalid Instances
The “Invalid” Sentinel and Other Invalid Instances
The Essential Tools Module allows for RWDateTime instances with an “invalid” state that can be compared to other RWDateTime instances and can be persisted. The default RWDateTime constructor constructs an invalid instance, and other construction techniques are available, including the RWDateTime::invalidSentinel constant. You can pass this constant to the RWDateTime(rwint64) constructor to create instances of the minimum and maximum RWDateTime as needed, or you can use it to compare directly with the millisecond count returned by RWDateTime::milliSeconds().
No other operations work, other than persisting the invalid object and using it in comparisons of equality and inequality. Arithmetic manipulation of an invalid RWDateTime results in an invalid RWDateTime. Attempts to use the part extraction functions (day(), month(), extract(), etc.) result in an RWInternalErr being thrown. The asString() family of functions always return the string "#INVALID#" when called with an invalid RWDateTime.
The following examples show several ways to construct an RWDateTime with an invalid state:
 
// construct dt1 with invalid state:
RWDateTime dt1;
 
// construct dt2 with invalid state:
RWDateTime dt2(RWDateTime::invalid);
 
// construct dt3 with invalid state:
RWDateTime dt3(RWDateTime::invalidSentinel);
 
// construct dt4 with invalid state:
RWDateTime dt4(RWDate(29,02,1997));