The Date::String class is basically a regular String to store the ASCII representation
of a date. The only difference with a regular String is that the Date::String class
also stores the format in which the date string must be interpreted. Indeed
dates can be written in many different ways, and the date to string or string
to date converters need some help to be able either to write the date in an
accurate format, or to interperet a string accurately to assign the right values to a
Since the Date::String class publicly inherits from the String class all non
overloaded members of String can be used. Currently only the constructors and the
assignment operator are overloaded. See Section 2.9 for the complete reference to the
String class and its members.
class Date::String : public String
Date::String (const String& format);
Date::String (const Date::String& datestr);
Date::String& operator = (const Date::String& datestr);
Date::String& operator = (const String& string);
const String& format () const;
Table 3.3 gives the complete list of special fields a Date::String format string can
contain and how these fields are interpreted in the date to string and string to date
|%% ||Print the ’%’ symbol (escapes ’%’)||%
|%A ||Day of week, long format ||Friday
|%a ||Day of week, short format ||Fri
|%B ||Month name, long format ||April
|%b ||Month name, short format ||Apr
|%Y ||Year, full format ||2001
|%y ||Year, 2 digit format ||01
|%M ||Month, full format ||04
|%m ||Month, short format ||4
|%D ||Day, full format ||07
|%d ||Day, short format ||7
|Table 3.3: ||Date string fields.|
Destroys this date string. Releases all used memory resources.
Date::String (const String& format)
Constructs this date string with the given format. The given format argument
can contain fields from Table 3.3 which will be interpreted accordingly, as
well as regular symbols storeable in a String.
For example the format string
"Today is %B %d, %Y. Enjoy your %A."
or the string
"Date %Y-%M-%D (YYYY-MM-DD)"
are both valid format arguments.
Date::String (const Date::String& datestr)
Constructs this date string from the given datestr. All properties and data
stored in datestr are cloned into this.
Date::String& operator = (const Date::String& datestr)
Assigns the given datestr to this date string, and return a reference to this
for assignment chaining. All properties and data stored in datestr are cloned
Date::String& operator = (const String& string)
Assigns the given string to this date string, and return a reference to this for
assignment chaining. All properties and data stored in string are cloned into
this. This operator does not modify the format stored in this. This assignment
operator is normaly used to assign a String to a Date::String, the later
being then used with its format to assign or create a Date.
const String& format () const
Returns the format this date string was constructed with.