SourcePro® 2022.1 |
SourcePro® API Reference Guide |
A basic, concrete time zone implementation of the abstract class RWZone, based on the Daylight Saving Time (DST) rules defined in struct
RWDaylightRule.
More...
#include <rw/tools/zone.h>
Public Member Functions | |
RWZoneSimple (const RWDaylightRule *rule, long int stdoff, const RWCString &stdname, long int altoff, const RWCString &altname) | |
RWZoneSimple (long int tzoff, const RWCString &tzname) | |
RWZoneSimple (RWZone::StdZone zone, const RWDaylightRule *rule) | |
RWZoneSimple (RWZone::StdZone zone, RWZone::DstRule=RWZone::NoAm) | |
RWZoneSimple (const RWZoneSimple &zone) | |
RWZoneSimple (RWZoneSimple &&zone) | |
virtual RWCString | altZoneName () const |
virtual int | altZoneOffset () const |
virtual bool | daylightObserved () const |
virtual void | getBeginDaylight (struct tm *) const |
virtual void | getEndDaylight (struct tm *) const |
virtual bool | isDaylight (const struct tm *) const |
RWZoneSimple & | operator= (const RWZoneSimple &) |
RWZoneSimple & | operator= (RWZoneSimple &&zone) |
void | swap (RWZoneSimple &rhs) |
virtual RWCString | timeZoneName () const |
virtual int | timeZoneOffset () const |
Public Member Functions inherited from RWZone | |
virtual rwint64 | fromTM (const struct tm *tmbuf) const |
virtual RWCString | name (const struct tm *tmbuf) const |
virtual int | offset (const struct tm *tmbuf) const |
virtual void | toTM (rwint64 msec, struct tm *tmbuf, int *tzOffset, RWCString *tzName) const |
Additional Inherited Members | |
Public Types inherited from RWZone | |
enum | DstRule { NoDST, NoAm, WeEu, OfficialEU } |
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 } |
Static Public Member Functions inherited from RWZone | |
static const RWDaylightRule * | dstRule (DstRule rule=NoAm) |
static const RWZone & | local () |
static const RWZone * | local (const RWZone *zone) |
static const RWZone & | os () |
static const RWZone & | standard () |
static const RWZone * | standard (const RWZone *zone) |
static const RWZone & | utc () |
RWZoneSimple is an implementation of the abstract interface defined by class RWZone. It implements a simple DST rule sufficient to represent all historical U.S. conventions and many European and Asian conventions. It is table-driven and depends on parameters given by the struct
RWDaylightRule.
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.
Direct use of RWDaylightRule affords the most general interface to RWZoneSimple. However, a much simpler programmatic interface is offered, as illustrated by the examples below.
Instances of RWZoneSimple may be constructed to represent other time zones, and may be installed globally using the RWZone static member function RWZone::local(const RWZone*).
To install US Central time as your global "local" time use:
To install Hawaiian time (where Daylight Saving Time is not observed), use:
Likewise for Japan, use:
For France:
RWZone has predefined values for the RWZone::DstRule rules
Here are the rules used internally for the RWZone::NoAm, RWZone::WeEu, and RWZone::OfficialEU values of RWZone::DstRule. First, here are the rules for the RWZone::NoAm value:
And here are the rules for the RWZone::WeEu value:
And here are the rules for the RWZone::OfficialEU value:
Given these definitions,
is equivalent to the first example given above and repeated here:
Daylight Saving Time systems that cannot be represented with RWDaylightRule and RWZoneSimple must be modeled by deriving from RWZone and implementing its virtual functions.
For example, under Britain's Summer Time rules, alternate timekeeping begins the morning after the third Saturday in April, unless that is Easter (in which case it begins the week before) or unless the Council decides on some other time for that year. In some years Summer Time has been two hours ahead, or has extended through winter without a break. British Summer Time clearly deserves an RWZone class all its own.
|
inline |
Constructs an RWZoneSimple instance in which DST is computed according to the provided rule. If rule is zero, DST is not observed.
rule | The DST rule |
stdoff | The offset from GMT (in seconds, positive if west of 0 degrees longitude) |
stdname | The name of Standard time |
altoff | The offset (typically equal to tzoff - 600 ) to define when DST is in effect |
altname | Alternative name for the time zone when DST is in effect, for example, MDT for Mountain Daylight Time. |
RWZoneSimple::RWZoneSimple | ( | long int | tzoff, |
const RWCString & | tzname | ||
) |
Constructs an RWZoneSimple instance in which DST is not observed. Argument tzoff is the offset from GMT (in seconds, positive if west of 0 degrees longitude) and tzname is the name of the zone.
RWZoneSimple::RWZoneSimple | ( | RWZone::StdZone | zone, |
const RWDaylightRule * | rule | ||
) |
Constructs an RWZoneSimple instance in which offsets and names are specified by the StdZone
argument. DST is computed according to the rule argument, if non-zero; otherwise, DST is not observed.
RWZoneSimple::RWZoneSimple | ( | RWZone::StdZone | zone, |
RWZone::DstRule | = RWZone::NoAm |
||
) |
Constructs an RWZoneSimple instance using internal RWDaylightRule instances. This is the simplest interface to RWZoneSimple. The argument zone is the time zone for which an RWZoneSimple is to be constructed. The second argument defines the DST rule to follow. North America's DST rules are the default.
RWZoneSimple::RWZoneSimple | ( | const RWZoneSimple & | zone | ) |
Copy constructor.
RWZoneSimple::RWZoneSimple | ( | RWZoneSimple && | zone | ) |
Move constructor. The constructed instance takes ownership of the data owned by zone.
|
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.
Implements RWZone.
|
virtual |
Returns the number of seconds west of GMT for DST in this zone.
Implements RWZone.
|
virtual |
Returns true
if DST is observed for this zone.
Implements RWZone.
|
virtual |
Sets the struct tm
tmbuf to the local time representing the first transition to daylight saving time (DST) for the year specified by the tm_year
field of tmbuf. If a daylight transition does not occur in the specified year, 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.
Implements RWZone.
|
virtual |
Sets the struct tm
tmbuf to the local time representing the first transition away from daylight saving time (DST) for the year specified by the tm_year
field of tmbuf. If a daylight transition does not occur in the specified year, 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.
Implements RWZone.
|
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.
Implements RWZone.
RWZoneSimple& RWZoneSimple::operator= | ( | const RWZoneSimple & | ) |
Assignment operator.
RWZoneSimple& RWZoneSimple::operator= | ( | RWZoneSimple && | zone | ) |
Move assignment. Self takes ownership of the data owned by zone.
void RWZoneSimple::swap | ( | RWZoneSimple & | rhs | ) |
Swaps the data owned by self with the data owned by rhs.
|
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.
Implements RWZone.
|
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.
Implements RWZone.
Copyright © 2022 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |