RWDate
RWDate is a class from the Essential Tools Module that can also be used as a database datatype. The DB Interface Module can handle any formatting issues without intervention when getting this type in and out of a database, as it can for
RWDateTime. Of course, as in
RWDateTime, the trick is getting localized information from a user to initialize an instance of
RWDate. The Essential Tools Module gives several options.
First, there is a constructor that takes a reference to an
istream and a reference to an
RWLocale. This allows direct initialization of the
RWDate instance from the istream.
A second technique is shown in the example below. A string initialized with a representation of a localized date is created and then converted to an
RWDate with the assistance of an
RWLocale reference.
void
demoI18NDate()
{
RWDate aDate("26 Mai 1998", RWLocaleSnapshot("de"));
cout << "in the US: "
<< aDate.asString("%d %b %Y", RWLocaleSnapshot("en_US"))
<< endl;
cout << "in France: "
<< aDate.asString("%d %b %Y", RWLocaleSnapshot("fr"))
<< endl;
}
The output for this example should be:
in the US: 26 May 1998
in France: 26 mai 1998