Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress C++ API Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

rwsf::TimeZoneSimple


rwsf::TimeZoneSimplerwsf::TimeZone

Local Index

Members

Header File

#include rwsf/core/TimeZone.h

Description

rwsf::TimeZoneSimple is an implementation of the abstract interface defined by class rwsf::TimeZone. It implements a simple Daylight Saving Time 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 DaylightRule, which is discussed later in this class.

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. 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.

Direct use of DaylightRule affords the most general interface to rwsf::TimeZoneSimple. However, a much simpler programmatic interface is offered, as illustrated by the examples below.

Three instances of rwsf::TimeZoneSimple are automatically constructed at program startup, to represent GMT, Standard, and local time. They are available via calls to the static member functions TimeZone::utc(), TimeZone::standard(), and TimeZone::local(), respectively.

These member functions are set up according to the time zone facilities provided in the execution environment (typically defined by the environment variable TZ). By default, if DST is observed at all, then the local zone instance will use U.S. (TimeZone::NoAm) Daylight Saving Time rules.

Note for developers outside North America: for some time zones this default will not be correct because these time zones rely on the C standard global variable _daylight. This variable is set whenever any alternate time zone rule is available, whether it represents Daylight Saving Time or not. Also the periods of history affected by Daylight Saving Time may be different in your time zone from those in North America, causing the North American rule to be erroneously invoked. The best way to ensure that these default time zones are correct is to construct an rwsf::TimeZoneSimple using an appropriate DaylightRule and initialize TimeZone::local() and TimeZone::std() with this value.

Other instances of rwsf::TimeZoneSimple may be constructed to represent other time zones, and may be installed globally using rwsf::TimeZone static member functions TimeZone::local(const TimeZone*) and TimeZone::standard(const TimeZone*).

Public Constructors

TimeZoneSimple(const DaylightRule * rule,
    long tzoff,
    const std::string & tz_name,
    long altoff,
    const std::string & altname);
TimeZoneSimple(long tzoff,
    const std::string & tz_name);
TimeZoneSimple(StdZone zone,
    const DaylightRule * rule);
TimeZoneSimple(StdZone zone,
    DstRule = NoAm);

Public Member Functions

std::string
altZoneName() const;
long
altZoneOffset() const;
bool
daylightObserved() const;
void
getBeginDaylight(struct tm *) const;
void
getEndDaylight(struct tm *) const;
bool
isDaylight(const struct tm * tmbuf) const;
std::string
timeZoneName() const;
long
timeZoneOffset() const;


Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.