DB Interface Module User’s Guide : PART II Using the Basic Features : Chapter 7 The Data Model : The Value Layer : RWDBDateTime
RWDBDateTime
The deprecated class RWDBDateTime used to be the primary class for representing and manipulating dates and time in the DB Interface Module. It is now reimplemented on class RWDateTime of the Essential Tools Module of SourcePro Core.
RWDateTime has the following advantages over RWDBDateTime:
RWDBDateTime uses RWDateTime internally. Direct use of RWDateTime may result in increased application performance.
RWDateTime handles an operation’s manipulation of time operations more intuitively.
RWDBDateTime is still included in the SourcePro DB API, and can be used interchangeably with RWDateTime. Code written with RWDBDateTime need not be rewritten. However, Rogue Wave recommends developing new applications with class RWDateTime. For information on using RWDateTime in SourcePro DB, please see “RWDateTime” in this manual, and the entry for RWDateTime in the SourcePro C++ API Reference Guide.
To continue using RWDBDateTime, see the entry on RWDBDateTime in the SourcePro C++ API Reference Guide. If you are a previous user of RWDBDateTime, also see the following sections on changes to the RWDBDateTime API beginning with SourcePro DB 5.2.
Conversions between RWDBDateTime and RWDateTime
RWDBDateTime is now completely compatible with RWDateTime. Conversions are provided between the two classes, as in the following example:
 
RWDBDateTime datetime = RWDateTime(rwint64(0));
It is also possible to convert any RWDateTime instance to an RWDBDateTime instance:
 
RWDateTime datetime;
RWDBDateTime dbdatetime(datetime);
The way that RWDBDateTime stores dates was changed in SourcePro DB 5.2. It now carries the same limits and restrictions as RWDateTime. Please see the entry for class RWDateTime in the Essential Tools Module User's Guide.
Persistence
The RWDBDateTime methods saveOn() and restoreFrom() now save and restore the date in a different format than before SourcePro DB 5.2. The new format is more efficient in both time and space. To provide a migration path, the static method persistence() was provided to allow a change in the runtime behavior of the methods saveOn() and restoreFrom().
To read dates saved in the previous format, make the following call:
 
RWDBDateTime::persistence(RWDBDateTime::Legacy);
This sets the persistence model of the class to the legacy format. By default, dates are stored in a new format that is compatible with RWDateTime. To change the persistence model back to the default format, make the following call:
 
RWDBDateTime::persistence(RWDBDateTime::Default);
To determine the current persistence model, make the following call:
 
RWDBDateTime::Persistence persistence = RWDBDateTime::persistence();
After this call, the variable persistence can be compared to RWDBDateTime::Default and RWDBDateTime::Legacy.
As mentioned previously, the new persistence model is completely compatible with RWDateTime. For this reason, an instance of RWDBDateTime saved to a file can be read back as RWDateTime and vice versa.
64-bit Variables
RWDBDateTime is valid for thousands of years into the future. This means that several methods take 64-bit values as parameters in order to cover the full range of valid values. The methods that now take 64-bit values are: addMilliseconds(), addSeconds(), addMinutes(), and addHours(). Additionally, the method seconds() returns a 64-bit value. For example:
 
rwint64 num = RWDateTime::millisecsInDay * 100000;
RWDBDateTime datetime;
datetime.addMilliseconds(num);
rwint64 timeSince1901 = datetime.seconds();
For detailed information on functions that take 64-bit parameters, please see the entry for RWDBDateTime (deprecated) in the SourcePro C++ API Reference Guide.
Optional RWZone Parameter
Beginning with SourcePro DB 5.2, several RWDBDateTime (deprecated) methods now have a new optional parameter of type RWZone that allows a zone to be specified. For more information on these methods, please see the entries for RWDBDateTime and RWZone in the SourcePro C++ API Reference Guide.
Current Time
Beginning with SourcePro DB 5.2, when an instance of RWDBDateTime is set to the current time using the method now() or through the use of the default constructor, the milliseconds portion is no longer set to zero. The milliseconds portion now reflects the actual time.