// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ********************************************************************** * Copyright (c) 2003-2013, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Author: Alan Liu * Created: July 21 2003 * Since: ICU 2.8 ********************************************************************** */ #ifndef OLSONTZ_H #define OLSONTZ_H #include "unicode/utypes.h" #if !UCONFIG_NO_FORMATTING #include "unicode/basictz.h" #include "umutex.h" struct UResourceBundle; U_NAMESPACE_BEGIN class SimpleTimeZone; /** * A time zone based on the Olson tz 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 two different formats. * * a. Zone (table). A zone is a table resource contains several * type of resources below: * * - typeOffsets:intvector (Required) * * Sets of UTC raw/dst offset pairs in seconds. Entries at * 2n represents raw offset and 2n+1 represents dst offset * paired with the raw offset at 2n. The very first pair represents * the initial zone offset (before the first transition) always. * * - trans:intvector (Optional) * * List of transition times represented by 32bit seconds from the * epoch (1970-01-01T00:00Z) in ascending order. * * - transPre32/transPost32:intvector (Optional) * * List of transition times before/after 32bit minimum seconds. * Each time is represented by a pair of 32bit integer. * * - typeMap:bin (Optional) * * Array of bytes representing the mapping between each transition * time (transPre32/trans/transPost32) and its corresponding offset * data (typeOffsets). * * - finalRule:string (Optional) * * If a recurrent transition rule is applicable to a zone forever * after the final transition time, finalRule represents the rule * in Rules data. * * - finalRaw:int (Optional) * * When finalRule is available, finalRaw is required and specifies * the raw (base) offset of the rule. * * - finalYear:int (Optional) * * When finalRule is available, finalYear is required and specifies * the start year of the rule. * * - links:intvector (Optional) * * When this zone data is shared with other zones, links specifies * all zones including the zone itself. Each zone is referenced by * integer index. * * b. Link (int, length 1). A link 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. This data * is corresponding to Link data in the tz database. * * * 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. Regions. An array specifies mapping between zones and regions. * Each item is either a 2-letter ISO country code or "001" * (UN M.49 - World). This data is generated from "zone.tab" * in the tz database. */ class U_I18N_API OlsonTimeZone: public BasicTimeZone { … }; inline int16_t OlsonTimeZone::transitionCount() const { … } inline double OlsonTimeZone::transitionTime(int16_t transIdx) const { … } inline int32_t OlsonTimeZone::zoneOffsetAt(int16_t transIdx) const { … } inline int32_t OlsonTimeZone::rawOffsetAt(int16_t transIdx) const { … } inline int32_t OlsonTimeZone::dstOffsetAt(int16_t transIdx) const { … } inline int32_t OlsonTimeZone::initialRawOffset() const { … } inline int32_t OlsonTimeZone::initialDstOffset() const { … } inline const char16_t* OlsonTimeZone::getCanonicalID() const { … } U_NAMESPACE_END #endif // !UCONFIG_NO_FORMATTING #endif // OLSONTZ_H //eof