Logo Search packages:      
Sourcecode: icu version File versions  Download package

OlsonTimeZone Class Reference

#include <olsontz.h>

Inheritance diagram for OlsonTimeZone:

BasicTimeZone TimeZone UObject UMemory

List of all members.


Detailed Description

A time zone based on the Olson database. Olson time zones change behavior over time. The raw offset, rules, presence or absence of daylight savings time, and even the daylight savings amount can all vary.

This class uses a resource bundle named "zoneinfo". Zoneinfo is a table containing different kinds of resources. In several places, zones are referred to using integers. A zone's integer is a number from 0..n-1, where n is the number of zones, with the zones sorted in lexicographic order.

1. Zones. These have keys corresponding to the Olson IDs, e.g., "Asia/Shanghai". Each resource describes the behavior of the given zone. Zones come in several formats, which are differentiated based on length.

a. Alias (int, length 1). An alias zone is an int resource. The integer is the zone number of the target zone. The key of this resource is an alternate name for the target zone. Aliases represent Olson links and ICU compatibility IDs.

b. Simple zone (array, length 3). The three subelements are:

i. An intvector of transitions. These are given in epoch seconds. This may be an empty invector (length 0). If the transtions list is empty, then the zone's behavior is fixed and given by the offset list, which will contain exactly one pair. Otherwise each transtion indicates a time after which (inclusive) the associated offset pair is in effect.

ii. An intvector of offsets. These are in pairs of raw offset / DST offset, in units of seconds. There will be at least one pair (length >= 2 && length % 2 == 0).

iii. A binary resource. This is of the same length as the transitions vector, so length may be zero. Each unsigned byte corresponds to one transition, and has a value of 0..n-1, where n is the number of pairs in the offset vector. This forms a map between transitions and offset pairs.

c. Simple zone with aliases (array, length 4). This is like a simple zone, but also contains a fourth element:

iv. An intvector of aliases. This list includes this zone itself, and lists all aliases of this zone.

d. Complex zone (array, length 5). This is like a simple zone, but contains two more elements:

iv. A string, giving the name of a rule. This is the "final rule", which governs the zone's behavior beginning in the "final year". The rule ID is given without leading underscore, e.g., "EU".

v. An intvector of length 2, containing the raw offset for the final rule (in seconds), and the final year. The final rule takes effect for years >= the final year.

e. Complex zone with aliases (array, length 6). This is like a complex zone, but also contains a sixth element:

vi. An intvector of aliases. This list includes this zone itself, and lists all aliases of this zone.

2. Rules. These have keys corresponding to the Olson rule IDs, with an underscore prepended, e.g., "_EU". Each resource describes the behavior of the given rule using an intvector, containing the onset list, the cessation list, and the DST savings. The onset and cessation lists consist of the month, dowim, dow, time, and time mode. The end result is that the 11 integers describing the rule can be passed directly into the SimpleTimeZone 13-argument constructor (the other two arguments will be the raw offset, taken from the complex zone element 5, and the ID string, which is not used), with the times and the DST savings multiplied by 1000 to scale from seconds to milliseconds.

3. Countries. These have keys corresponding to the 2-letter ISO country codes, with a percent sign prepended, e.g., "%US". Each resource is an intvector listing the zones associated with the given country. The special entry "%" corresponds to "no country", that is, the category of zones assigned to no country in the Olson DB.

4. Metadata. Metadata is stored under the key "_". It is an intvector of length three containing the number of zones resources, rule resources, and country resources. For the purposes of this count, the metadata entry itself is considered a rule resource, since its key begins with an underscore.

Definition at line 116 of file olsontz.h.


Public Types

enum  { kStandard = 0x01, kDaylight = 0x03, kFormer = 0x04, kLatter = 0x0C }
enum  EDisplayType {
  SHORT = 1, LONG, SHORT_GENERIC, LONG_GENERIC,
  SHORT_GMT, LONG_GMT, SHORT_COMMONLY_USED, GENERIC_LOCATION
}

Public Member Functions

virtual TimeZoneclone () const
virtual int32_t countTransitionRules (UErrorCode &status)
UnicodeStringgetDisplayName (UBool daylight, EDisplayType style, const Locale &locale, UnicodeString &result) const
UnicodeStringgetDisplayName (UBool daylight, EDisplayType style, UnicodeString &result) const
UnicodeStringgetDisplayName (const Locale &locale, UnicodeString &result) const
UnicodeStringgetDisplayName (UnicodeString &result) const
virtual int32_t getDSTSavings () const
virtual UClassID getDynamicClassID () const
UnicodeStringgetID (UnicodeString &ID) const
virtual UBool getNextTransition (UDate base, UBool inclusive, TimeZoneTransition &result)
virtual void getOffset (UDate date, UBool local, int32_t &rawOffset, int32_t &dstOffset, UErrorCode &ec) const
virtual int32_t getOffset (uint8_t era, int32_t year, int32_t month, int32_t day, uint8_t dayOfWeek, int32_t millis, int32_t monthLength, UErrorCode &ec) const
virtual int32_t getOffset (uint8_t era, int32_t year, int32_t month, int32_t day, uint8_t dayOfWeek, int32_t millis, UErrorCode &ec) const
virtual void getOffsetFromLocal (UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt, int32_t &rawoff, int32_t &dstoff, UErrorCode &ec)
virtual UBool getPreviousTransition (UDate base, UBool inclusive, TimeZoneTransition &result)
virtual int32_t getRawOffset () const
virtual void getSimpleRulesNear (UDate date, InitialTimeZoneRule *&initial, AnnualTimeZoneRule *&std, AnnualTimeZoneRule *&dst, UErrorCode &status)
virtual void getTimeZoneRules (const InitialTimeZoneRule *&initial, const TimeZoneRule *trsrules[], int32_t &trscount, UErrorCode &status)
virtual UBool hasEquivalentTransitions (BasicTimeZone &tz, UDate start, UDate end, UBool ignoreDstAmount, UErrorCode &ec)
virtual UBool hasSameRules (const TimeZone &other) const
virtual UBool inDaylightTime (UDate date, UErrorCode &ec) const
 OlsonTimeZone (const OlsonTimeZone &other)
 OlsonTimeZone (const UResourceBundle *top, const UResourceBundle *res, UErrorCode &ec)
UBool operator!= (const TimeZone &that) const
OlsonTimeZoneoperator= (const OlsonTimeZone &other)
virtual UBool operator== (const TimeZone &other) const
void setID (const UnicodeString &ID)
virtual void setRawOffset (int32_t offsetMillis)
virtual UBool useDaylightTime () const
virtual ~OlsonTimeZone ()

Static Public Member Functions

static void U_EXPORT2 adoptDefault (TimeZone *zone)
static int32_t U_EXPORT2 countEquivalentIDs (const UnicodeString &id)
static TimeZone *U_EXPORT2 createDefault (void)
static StringEnumeration *U_EXPORT2 createEnumeration (const char *country)
static StringEnumeration *U_EXPORT2 createEnumeration (int32_t rawOffset)
static StringEnumeration *U_EXPORT2 createEnumeration ()
static TimeZone *U_EXPORT2 createTimeZone (const UnicodeString &ID)
static UnicodeString &U_EXPORT2 getCanonicalID (const UnicodeString &id, UnicodeString &canonicalID, UBool &isSystemID, UErrorCode &status)
static UnicodeString &U_EXPORT2 getCanonicalID (const UnicodeString &id, UnicodeString &canonicalID, UErrorCode &status)
static const UnicodeString
U_EXPORT2 
getEquivalentID (const UnicodeString &id, int32_t index)
static const TimeZone *U_EXPORT2 getGMT (void)
static U_I18N_API UClassID
U_EXPORT2 
getStaticClassID ()
static const char *U_EXPORT2 getTZDataVersion (UErrorCode &status)
static void U_EXPORT2 operator delete (void *, void *) U_NO_THROW
static void U_EXPORT2 operator delete (void *p) U_NO_THROW
static void U_EXPORT2 operator delete[] (void *p) U_NO_THROW
static void *U_EXPORT2 operator new (size_t, void *ptr) U_NO_THROW
static void *U_EXPORT2 operator new (size_t size) U_NO_THROW
static void *U_EXPORT2 operator new[] (size_t size) U_NO_THROW
static void U_EXPORT2 setDefault (const TimeZone &zone)

Protected Types

enum  { kStdDstMask = kDaylight, kFormerLatterMask = kLatter }

Protected Member Functions

void getTimeZoneRulesAfter (UDate start, InitialTimeZoneRule *&initial, UVector *&transitionRules, UErrorCode &status)

Static Protected Member Functions

static UResourceBundleloadRule (const UResourceBundle *top, const UnicodeString &ruleid, UResourceBundle *oldbundle, UErrorCode &status)

Private Member Functions

void clearTransitionRules (void)
void constructEmpty ()
void deleteTransitionRules (void)
int32_t dstOffset (int16_t index) const
void getHistoricalOffset (UDate date, UBool local, int32_t NonExistingTimeOpt, int32_t DuplicatedTimeOpt, int32_t &rawoff, int32_t &dstoff) const
void initTransitionRules (UErrorCode &status)
 OlsonTimeZone ()
int32_t rawOffset (int16_t index) const
int32_t zoneOffset (int16_t index) const

Private Attributes

double finalMillis
int32_t finalYear
SimpleTimeZonefinalZone
SimpleTimeZonefinalZoneWithStartYear
TimeZoneTransitionfirstFinalTZTransition
TimeZoneTransitionfirstTZTransition
int16_t firstTZTransitionIdx
int16_t historicRuleCount
TimeArrayTimeZoneRule ** historicRules
InitialTimeZoneRuleinitialRule
int16_t transitionCount
UBool transitionRulesInitialized
const int32_t * transitionTimes
int16_t typeCount
const uint8_t * typeData
const int32_t * typeOffsets

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index