RWDateTime
An
RWDateTime may be constructed in several ways. Unlike
RWDate and the deprecated
RWTime described in
RWDate and
RWTime (deprecated), the
RWDateTime default constructor does not automatically set the time and date to the current time and date. This change provides an efficient way to construct large arrays of
RWDateTime. The current time and date can still be set by using a constructor. Simply include the enum value
RWDateTime::setCurrentTime in
RWDateTime’s constructor argument list. See the
SourcePro API Reference Guide for a complete description of
RWDateTime.
For example, to construct an
RWDateTime with today’s date and current time, use the following:
RWDateTime dt(RWDateTime::setCurrentTime); // today, current time
An
RWDateTime can also be constructed from a given date and/or a given time. Or you can use an
RWDateTime constructor that takes a string and the enum
RWDateTime::SetType, which indicates whether you are setting a date, a time, or both. By default, the constructor expects to set both the date and time. For example, to construct an
RWDateTime for a given date, where time is of no concern, use:
RWDateTime dt(“June 2, 1952”, RWDateTime::setDate,
RWLocale::global()); // sets date to 6/2/52, 00:00:00
Similarly, to construct an
RWDateTime for a given time:
RWDateTime dt(“10:00 pm”, RWDateTime::setTime, RWLocale::global());
// sets date and time to today, 22:00:00
Finally, to construct an
RWDateTime for a given date and time, you can use the following techniques. Note that when you initialize both the day and time, the date precedes the time and the two values are separated by a semicolon.
RWDateTime dt(“June 4, 1968; 10:51 am”,
RWDateTime::setBoth,
RWLocale::global()); // 6/4/68, 10:51:00
or
RWDateTime dt(4,6,1968,10,51,0); // 6/4/68, 10:51:00