altZoneName() altZoneOffset() daylightObserved() DstRule |
dstRule() getBeginDaylight() getEndDaylight() isDaylight() |
local() os() standard() StdZone |
timeZoneName() timeZoneOffset() utc() |
#include <rwsf/core/TimeZone.h>
rwsf::TimeZone is an abstract base class. It defines an interface for time zone issues such as whether or not Daylight Saving Time is in use, the names and offsets from GMT (also known as UTC) for both standard and Daylight Saving Times, and the start and stop dates for Daylight Saving Time, 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 rwsf::TimeZone should act.
Most programs interact with rwsf::TimeZone only by passing an rwsf::TimeZone reference to an rwsf::DateTime member function that expects one.
Daylight saving-time rules are volatile, often reflecting geographical and political changes. In some cases, the hard-coded table-driven struct DaylightRule does not accurately reflect the locale installed on your machine. rwsf::TimeZone::os() creates a new rwsf::TimeZoneSimple containing the daylight rule discovered from the underlying operating system. The onus of correctness for this DST rule is on the operating system itself.
In many cases, you may want more explicit control of the DST rule for the intended rwsf::TimeZoneSimple. If so, you can build a DST rule with arbitrary begin and end times (see the DaylightRule below), and provide it as a parameter to rwsf::TimeZoneSimple.
enum DstRule {//supported Daylight Savings Time jurisdictions: NoDST, // Daylight Savings Time never observed NoAm, // North America (US, Canada) WeEu, // Much of Western Europe, excluding the UK OfficialEU // Official European Union DST rules. };
Used by the static member function dstRule(), described below, and by constructors for classes derived from rwsf::TimeZone, including rwsf::TimeZoneSimple.
enum StdZone { NewZealand = -12, CarolineIslands, MarianaIslands, Japan, China, Java, Kazakh, Pakistan, CaspianSea, Ukraine, Nile, Europe, Greenwich, Azores, Oscar, Greenland, Atlantic, USEastern, USCentral, USMountain, USPacific, Yukon, Hawaii, Bering };
Provided to name the standard time zones. Its values are intended to be passed to constructors of classes derived from rwsf::TimeZone.
virtual long timeZoneOffset() const = 0;
Returns the number of seconds west of GMT for standard time in this zone. The number is negative for zones east of Greenwich, England.
virtual long altZoneOffset() const = 0;
Returns the number of seconds west of GMT for Daylight Saving Time in this zone.
virtual bool daylightObserved() const = 0;
Returns true if Daylight Saving Time is observed for this zone.
virtual bool isDaylight(const struct tm* tspec) const = 0;
Returns true if the time and date represented in the struct tm argument is in the range of Daylight Saving Time for this zone. The elements of the tm argument must all be self-consistent; in particular, the tm_wday member must agree with the tm_year, tm_mon, and tm_day members.
virtual void getBeginDaylight(struct tm*) const = 0; virtual void getEndDaylight (struct tm*) const = 0;
Return with the struct tm argument set to the local time that Daylight Saving Time begins, or ends, for the year indicated by the tm_year member passed in. If Daylight Saving Time is not observed, the struct tm members are all set to a negative value. Note that in the southern hemisphere, Daylight Saving Time ends at an earlier date than it begins.
virtual std::string timeZoneName() const = 0; virtual std::string altZoneName() const = 0;
Return the name of, respectively, the standard and Daylight Saving Time zones represented, such as PST and PDT. Note that the current date and time have no effect on the return values of these functions.
static const TimeZone& local();
Returns a reference to an rwsf::TimeZone representing local time. By default this will be an instance of rwsf::TimeZoneSimple created with offsets and zone names from the operating system, with U.S. rules for Daylight Saving Time if observed. This is used as the default argument value for rwsf::DateTime functions that take an rwsf::TimeZone.
static const TimeZone& os();
Determines the current daylight saving rule from the underlying operating system. You can set a daylight saving rule for the current year by instantiating TimeZone::local( &TimeZone::os() ).
static const TimeZone& standard();
Returns a reference to an rwsf::TimeZone representing standard local time, with no Daylight Saving Time corrections. By default this is an instance of rwsf::TimeZoneSimple with offset and zone name from the operating system.
static const TimeZone& utc();
Returns a reference to an rwsf::TimeZone representing GMT (UTC) universal time.
static const TimeZone* local(const TimeZone*); static const TimeZone* standard(const TimeZone*);
These functions allow the values returned by the other functions above to be set. Each returns the previous value.
static const DaylightRule* dstRule(DstRule rule = NoAm);
Returns one of the built-in Daylight Saving Time rules according to rule. Function dstRule() is provided for convenience in constructing rwsf::TimeZoneSimple instances for time zones in which common Daylight Saving Time rules are obeyed. rwsf::TimeZone has predefined names for these rules, defined under "Enumerations" for this class. If DstRule NoDST is given, then 0 is returned. The result of calling dstRule() is normally passed to the rwsf::TimeZoneSimple constructor.
©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks and HydraSDO is a trademark of Quovadx, 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.