RWDateTime
As mentioned in RWDateTime, class RWDateTime from the Essential Tools Module is the primary date and time class of SourcePro DB. It is used to hold a date and a time, primarily in association with moving data in and out of DATETIME (or similar) columns in databases.
Compatibility with SourcePro DB is provided to instances that are initialized, either to RWDateTime::null or to a valid datetime. Once an instance of RWDateTime is initialized, it can be used like any other datatype. SourcePro DB performs any formatting or binding automatically in a locale neutral manner. The programmer does not have to address localization issues with regard to getting this datatype in and out of the database.
However, getting a valid RWDateTime value from users in various locales can be tricky. The next example demonstrates how to take a string representing a localized date time value and convert it into an RWDateTime instance. Following the conversion, the RWDateTime is streamed to standard output to demonstrate output in various locales.
Example 22 – Converting a localized date/time value into an RWDateTime instance
 
void
demoI18NDateTimes()
{
RWCString germanDateString("04.05.98");
RWCString germanTimeString("16:26:42");
 
RWLocaleSnapshot germany("de");
//If we're already in a german locale
//the next line will work as an alternate
//RWLocale& germany = *RWLocale::global();
 
struct tm aTimeStruct;
germany.stringToDate(germanDateString, &aTimeStruct);
germany.stringToTime(germanTimeString, &aTimeStruct);
 
RWDateTime aDateTime(&aTimeStruct);
 
cout << "in France: "
<< aDateTime.asString('\0', RWZone::local(),
RWLocaleSnapshot("fr"))
<< endl;
cout << "in the US: "
<< aDateTime.asString('\0', RWZone::local(),
RWLocaleSnapshot("en_US"))
<< endl;
}
The output for this example should look like this:
 
in France: 04.05.98 16:26:42.000
in the US: 05/04/98 16:26:42.000