Tools.h++ Manual

104011 Tandem Computers Incorporated 7-1
Using Class RWTime 7
Class
RWTime
represents a time, stored as the number of seconds since 1
January 1901 UTC. While UTC is a widely accepted time standard, it is not the
usual time reference that most people use in their day-to-day lives. We tell
time with a “local” time which may or may not observe daylight savings time
(DST). In addition, DST may or may not actually be in effect.
Hence, when we create an
RWTime
object, we are unlikely to do so with UTC.
More likely, the time we give it will be with respect to some other time zone.
For
RWTime
to do the job properly, it must know which time zone you mean.
By default, it uses a global “local” time, set by
RWZone::local()
. The same
issue arises when you get the time back out to be printed: in which time zone
do you want it to be printed? Again, the default is the global local time.
7.1 Setting the time zone
The question naturally arises, how does the library determine this local time?
The UNIX operating system provides for setting the local time zone and for
establishing whether daylight savings time is locally observed. Class
RWTime
uses various system calls to determine these values and sets itself accordingly.
Class
RWTime
should function properly in North America, or if daylight
savings time is not observed in your area. In places not governed by U.S.
daylight savings time rules, you may need to re-initialize the local time
zone—see “RWZone” on page 233 in Chapter 21, “Class Reference.”