SourcePro 11.1 |
SourcePro® C++ API Reference Guide |
SourcePro C++ Documentation Home |
Abstract base class defining an interface to describe time zones. More...
#include <rw/tools/classiczone.h>
Public Types | |
enum | StdZone { NewZealand, CarolineIslands, MarianaIslands, Japan, China, Java, Kazakh, Pakistan, CaspianSea, Ukraine, Nile, Europe, Greenwich, Azores, Oscar, Greenland, Atlantic, USEastern, USCentral, USMountain, USPacific, Yukon, Hawaii, Bering } |
enum | DstRule { NoDST, NoAm, WeEu, OfficialEU } |
Public Member Functions | |
virtual int | timeZoneOffset () const =0 |
virtual int | altZoneOffset () const =0 |
virtual bool | daylightObserved () const =0 |
virtual RWCString | timeZoneName () const =0 |
virtual RWCString | altZoneName () const =0 |
virtual bool | isDaylight (const struct tm *tmbuf) const =0 |
virtual void | getBeginDaylight (struct tm *tmbuf) const =0 |
virtual void | getEndDaylight (struct tm *tmbuf) const =0 |
Static Public Member Functions | |
static const RWZone & | local () |
static const RWZone & | standard () |
static const RWZone & | utc () |
static const RWZone & | os () |
static const RWZone * | local (const RWZone *zone) |
static const RWZone * | standard (const RWZone *zone) |
static const RWDaylightRule * | dstRule (DstRule rule=NoAm) |
RWZone is an abstract base class that defines an interface for time zone issues, such as whether or not Daylight Saving Time (DST) is in use, the names and offsets from Greenwich Mean Time (GMT) (also known as Coordinated Universal Time, or UTC), for both standard and Daylight Saving Time, and the start and stop dates for DST, if used. Note that because it is an abstract base class, there is no way to actually enforce these goals -- the description here is merely the model of how a class derived from RWZone should act.
Most programs interact with RWZone only by passing an RWZone reference to SourcePro member functions that expect one.
DST rules are volatile, often reflecting geographical and political changes. In some cases, the hard-coded, table-driven struct RWDaylightRule does not accurately reflect the locale installed on your machine. RWZone::os() creates a new RWZoneSimple containing the daylight rule discovered from the underlying operating system. This way, the operating system itself defines the DST rules.
In many cases, you may want more explicit control of the DST rule for the intended RWZoneSimple. If so, you can build a DST rule with arbitrary begin and end times (see the RWDaylightRule below), and provide it as a parameter to RWZoneSimple.
#include <time.h> #include <rw/zone.h> (abstract base class)
None
#include <rw/zone.h> #include <rw/zone.h> #include <rw/tools/datetime.h> int main () { RWDateTime now(RWDateTime::setCurrentTime); std::cout << now.asString("%x %X", RWLocale::global(), RWZone::local()) << std::endl; std::cout << now.asString("%x %X", RWLocale::global(), RWZone::utc()) << std::endl; return 0; }
enum RWZone::DstRule |
Used by the static member function dstRule() and by constructors for classes derived from RWZone, including RWZoneSimple.
enum RWZone::StdZone |
Names the standard time zones. Its values are intended to be passed to constructors of classes derived from RWZone.
virtual RWCString RWZone::altZoneName | ( | ) | const [pure virtual] |
Returns the name of the DST zone represented, such as "PDT"
. Note that the current date and time have no effect on the return value.
Implemented in RWZoneSimple.
virtual int RWZone::altZoneOffset | ( | ) | const [pure virtual] |
Returns the number of seconds west of GMT for DST in this zone.
Implemented in RWZoneSimple.
virtual bool RWZone::daylightObserved | ( | ) | const [pure virtual] |
Returns true
if DST is observed for this zone.
Implemented in RWZoneSimple.
static const RWDaylightRule* RWZone::dstRule | ( | DstRule | rule = NoAm |
) | [static] |
Returns one of the built-in DST rules according to rule. This function is provided for convenience in constructing RWZoneSimple instances for time zones in which common DST rules are obeyed. RWZone has predefined names for these rules, defined under the enumerations section for this class. If DstRule NoDST
is provided, then 0
is returned. The result of calling dstRule() is normally passed to the RWZoneSimple constructor.
virtual void RWZone::getBeginDaylight | ( | struct tm * | tmbuf | ) | const [pure virtual] |
Returns with the struct tm
argument set to the local time that DST begins for the year specified by the tm_year
field of tmbuf. If DST is not observed, the members of tmbuf are all set to a negative value. Note that in the southern hemisphere, DST ends at an earlier date than it begins.
Implemented in RWZoneSimple.
virtual void RWZone::getEndDaylight | ( | struct tm * | tmbuf | ) | const [pure virtual] |
Returns with the struct tm
argument set to the local time that DST ends for the year specified by the tm_year
field of tmbuf. If DST is not observed, the members of tmbuf are all set to a negative value. Note that in the southern hemisphere, DST ends at an earlier date than it begins.
Implemented in RWZoneSimple.
virtual bool RWZone::isDaylight | ( | const struct tm * | tmbuf | ) | const [pure virtual] |
Returns true
if the time and date represented in the struct tm
argument is in the range of DST for this zone. The elements of tmbuf must all be self-consistent; in particular, the tm_wday
member must agree with the tm_year
, tm_mon
, and tm_day
members.
Implemented in RWZoneSimple.
Sets the RWZone to be returned by RWZone::local() to zone and returns the previous value.
static const RWZone& RWZone::local | ( | ) | [static] |
Returns a reference to an RWZone representing local time. By default, this is an instance of RWZoneSimple created with offsets and zone names from the operating system, with U.S. rules for DST, if observed. This is used as a default argument value to member functions of other classes where an RWZone argument is required.
static const RWZone& RWZone::os | ( | ) | [static] |
On the first call, determines DST rules for the years 1970 - 2038, from the underlying operating system. On subsequent calls, a cached copy is used. You can set the DST rules for these years by instantiating RWZone::local(&RWZone::os()).
Sets the RWZone to be returned by RWZone::standard() to zone and returns the previous value.
static const RWZone& RWZone::standard | ( | ) | [static] |
Returns a reference to an RWZone representing standard local time, with no DST corrections. By default, this is an instance of RWZoneSimple with offset and zone name from the operating system.
virtual RWCString RWZone::timeZoneName | ( | ) | const [pure virtual] |
Returns the name of the standard time zone represented, such as "PST"
. Note that the current date and time have no effect on the return value.
Implemented in RWZoneSimple.
virtual int RWZone::timeZoneOffset | ( | ) | const [pure virtual] |
Returns the number of seconds west of GMT for standard time in this zone. The number is negative for zones east of Greenwich, England.
Implemented in RWZoneSimple.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.