Tools.h++ Manual
7-2 104011 Tandem Computers Incorporated
7
7.2 Constructors
A
RWTime
may be constructed in several ways:
1. Construct a
RWTime
with the local time:
RWTime t;
2. Construct a
RWTime
with today's date, at the specified local hour (0–23),
minute (0–59) and second (0–59):
RWTime t(16, 45, 0); //today 16:45:00
3. Construct a
RWTime
for a given date and local time:
RWDate d(2, "June", 1952);
RWTime t(d, 16, 45, 0); // 6/2/52 16:45:003.
4. Construct a
RWTime
for a given date and time zone:
RWDate d(2, “June”, 1952);
RWTime t(d, 16, 45, 0, RWZone::utc()); // 6/2/52
16:45:00
7.3 Member functions
Class
RWTime
has member functions to compare, store, restore, add and
subtract
RWTime
s. An
RWTime
may return hour, minute or second, or fill a
struct tm for any time zone. A complete list of member functions is included
in Class Reference, Part 2
For example, a code fragment to output the hour in local and Universal (GMT)
zones, and then the complete local time and date, is:
RWTime t;
cout << t.hour() << endl;
cout << t.hour(RWZone::utc()) << endl;
cout << t.asString(‘c’) << endl;
Here is how you find out when daylight savings time starts for the current year
and local time zone: