Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ******************************************************************************* |
michael@0 | 3 | * Copyright (C) 2007-2013, International Business Machines Corporation and |
michael@0 | 4 | * others. All Rights Reserved. |
michael@0 | 5 | ******************************************************************************* |
michael@0 | 6 | */ |
michael@0 | 7 | #ifndef BASICTZ_H |
michael@0 | 8 | #define BASICTZ_H |
michael@0 | 9 | |
michael@0 | 10 | /** |
michael@0 | 11 | * \file |
michael@0 | 12 | * \brief C++ API: ICU TimeZone base class |
michael@0 | 13 | */ |
michael@0 | 14 | |
michael@0 | 15 | #include "unicode/utypes.h" |
michael@0 | 16 | |
michael@0 | 17 | #if !UCONFIG_NO_FORMATTING |
michael@0 | 18 | |
michael@0 | 19 | #include "unicode/timezone.h" |
michael@0 | 20 | #include "unicode/tzrule.h" |
michael@0 | 21 | #include "unicode/tztrans.h" |
michael@0 | 22 | |
michael@0 | 23 | U_NAMESPACE_BEGIN |
michael@0 | 24 | |
michael@0 | 25 | // forward declarations |
michael@0 | 26 | class UVector; |
michael@0 | 27 | |
michael@0 | 28 | /** |
michael@0 | 29 | * <code>BasicTimeZone</code> is an abstract class extending <code>TimeZone</code>. |
michael@0 | 30 | * This class provides some additional methods to access time zone transitions and rules. |
michael@0 | 31 | * All ICU <code>TimeZone</code> concrete subclasses extend this class. |
michael@0 | 32 | * @stable ICU 3.8 |
michael@0 | 33 | */ |
michael@0 | 34 | class U_I18N_API BasicTimeZone: public TimeZone { |
michael@0 | 35 | public: |
michael@0 | 36 | /** |
michael@0 | 37 | * Destructor. |
michael@0 | 38 | * @stable ICU 3.8 |
michael@0 | 39 | */ |
michael@0 | 40 | virtual ~BasicTimeZone(); |
michael@0 | 41 | |
michael@0 | 42 | /** |
michael@0 | 43 | * Gets the first time zone transition after the base time. |
michael@0 | 44 | * @param base The base time. |
michael@0 | 45 | * @param inclusive Whether the base time is inclusive or not. |
michael@0 | 46 | * @param result Receives the first transition after the base time. |
michael@0 | 47 | * @return TRUE if the transition is found. |
michael@0 | 48 | * @stable ICU 3.8 |
michael@0 | 49 | */ |
michael@0 | 50 | virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const = 0; |
michael@0 | 51 | |
michael@0 | 52 | /** |
michael@0 | 53 | * Gets the most recent time zone transition before the base time. |
michael@0 | 54 | * @param base The base time. |
michael@0 | 55 | * @param inclusive Whether the base time is inclusive or not. |
michael@0 | 56 | * @param result Receives the most recent transition before the base time. |
michael@0 | 57 | * @return TRUE if the transition is found. |
michael@0 | 58 | * @stable ICU 3.8 |
michael@0 | 59 | */ |
michael@0 | 60 | virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const = 0; |
michael@0 | 61 | |
michael@0 | 62 | /** |
michael@0 | 63 | * Checks if the time zone has equivalent transitions in the time range. |
michael@0 | 64 | * This method returns true when all of transition times, from/to standard |
michael@0 | 65 | * offsets and DST savings used by this time zone match the other in the |
michael@0 | 66 | * time range. |
michael@0 | 67 | * @param tz The <code>BasicTimeZone</code> object to be compared with. |
michael@0 | 68 | * @param start The start time of the evaluated time range (inclusive) |
michael@0 | 69 | * @param end The end time of the evaluated time range (inclusive) |
michael@0 | 70 | * @param ignoreDstAmount |
michael@0 | 71 | * When true, any transitions with only daylight saving amount |
michael@0 | 72 | * changes will be ignored, except either of them is zero. |
michael@0 | 73 | * For example, a transition from rawoffset 3:00/dstsavings 1:00 |
michael@0 | 74 | * to rawoffset 2:00/dstsavings 2:00 is excluded from the comparison, |
michael@0 | 75 | * but a transtion from rawoffset 2:00/dstsavings 1:00 to |
michael@0 | 76 | * rawoffset 3:00/dstsavings 0:00 is included. |
michael@0 | 77 | * @param ec Output param to filled in with a success or an error. |
michael@0 | 78 | * @return true if the other time zone has the equivalent transitions in the |
michael@0 | 79 | * time range. |
michael@0 | 80 | * @stable ICU 3.8 |
michael@0 | 81 | */ |
michael@0 | 82 | virtual UBool hasEquivalentTransitions(const BasicTimeZone& tz, UDate start, UDate end, |
michael@0 | 83 | UBool ignoreDstAmount, UErrorCode& ec) const; |
michael@0 | 84 | |
michael@0 | 85 | /** |
michael@0 | 86 | * Returns the number of <code>TimeZoneRule</code>s which represents time transitions, |
michael@0 | 87 | * for this time zone, that is, all <code>TimeZoneRule</code>s for this time zone except |
michael@0 | 88 | * <code>InitialTimeZoneRule</code>. The return value range is 0 or any positive value. |
michael@0 | 89 | * @param status Receives error status code. |
michael@0 | 90 | * @return The number of <code>TimeZoneRule</code>s representing time transitions. |
michael@0 | 91 | * @stable ICU 3.8 |
michael@0 | 92 | */ |
michael@0 | 93 | virtual int32_t countTransitionRules(UErrorCode& status) const = 0; |
michael@0 | 94 | |
michael@0 | 95 | /** |
michael@0 | 96 | * Gets the <code>InitialTimeZoneRule</code> and the set of <code>TimeZoneRule</code> |
michael@0 | 97 | * which represent time transitions for this time zone. On successful return, |
michael@0 | 98 | * the argument initial points to non-NULL <code>InitialTimeZoneRule</code> and |
michael@0 | 99 | * the array trsrules is filled with 0 or multiple <code>TimeZoneRule</code> |
michael@0 | 100 | * instances up to the size specified by trscount. The results are referencing the |
michael@0 | 101 | * rule instance held by this time zone instance. Therefore, after this time zone |
michael@0 | 102 | * is destructed, they are no longer available. |
michael@0 | 103 | * @param initial Receives the initial timezone rule |
michael@0 | 104 | * @param trsrules Receives the timezone transition rules |
michael@0 | 105 | * @param trscount On input, specify the size of the array 'transitions' receiving |
michael@0 | 106 | * the timezone transition rules. On output, actual number of |
michael@0 | 107 | * rules filled in the array will be set. |
michael@0 | 108 | * @param status Receives error status code. |
michael@0 | 109 | * @stable ICU 3.8 |
michael@0 | 110 | */ |
michael@0 | 111 | virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial, |
michael@0 | 112 | const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) const = 0; |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * Gets the set of time zone rules valid at the specified time. Some known external time zone |
michael@0 | 116 | * implementations are not capable to handle historic time zone rule changes. Also some |
michael@0 | 117 | * implementations can only handle certain type of rule definitions. |
michael@0 | 118 | * If this time zone does not use any daylight saving time within about 1 year from the specified |
michael@0 | 119 | * time, only the <code>InitialTimeZone</code> is returned. Otherwise, the rule for standard |
michael@0 | 120 | * time and daylight saving time transitions are returned in addition to the |
michael@0 | 121 | * <code>InitialTimeZoneRule</code>. The standard and daylight saving time transition rules are |
michael@0 | 122 | * represented by <code>AnnualTimeZoneRule</code> with <code>DateTimeRule::DOW</code> for its date |
michael@0 | 123 | * rule and <code>DateTimeRule::WALL_TIME</code> for its time rule. Because daylight saving time |
michael@0 | 124 | * rule is changing time to time in many time zones and also mapping a transition time rule to |
michael@0 | 125 | * different type is lossy transformation, the set of rules returned by this method may be valid |
michael@0 | 126 | * for short period of time. |
michael@0 | 127 | * The time zone rule objects returned by this method is owned by the caller, so the caller is |
michael@0 | 128 | * responsible for deleting them after use. |
michael@0 | 129 | * @param date The date used for extracting time zone rules. |
michael@0 | 130 | * @param initial Receives the <code>InitialTimeZone</code>, always not NULL. |
michael@0 | 131 | * @param std Receives the <code>AnnualTimeZoneRule</code> for standard time transitions. |
michael@0 | 132 | * When this time time zone does not observe daylight saving times around the |
michael@0 | 133 | * specified date, NULL is set. |
michael@0 | 134 | * @param dst Receives the <code>AnnualTimeZoneRule</code> for daylight saving time |
michael@0 | 135 | * transitions. When this time zone does not observer daylight saving times |
michael@0 | 136 | * around the specified date, NULL is set. |
michael@0 | 137 | * @param status Receives error status code. |
michael@0 | 138 | * @stable ICU 3.8 |
michael@0 | 139 | */ |
michael@0 | 140 | virtual void getSimpleRulesNear(UDate date, InitialTimeZoneRule*& initial, |
michael@0 | 141 | AnnualTimeZoneRule*& std, AnnualTimeZoneRule*& dst, UErrorCode& status) const; |
michael@0 | 142 | |
michael@0 | 143 | |
michael@0 | 144 | #ifndef U_HIDE_INTERNAL_API |
michael@0 | 145 | /** |
michael@0 | 146 | * The time type option bit flags used by getOffsetFromLocal |
michael@0 | 147 | * @internal |
michael@0 | 148 | */ |
michael@0 | 149 | enum { |
michael@0 | 150 | kStandard = 0x01, |
michael@0 | 151 | kDaylight = 0x03, |
michael@0 | 152 | kFormer = 0x04, |
michael@0 | 153 | kLatter = 0x0C |
michael@0 | 154 | }; |
michael@0 | 155 | #endif /* U_HIDE_INTERNAL_API */ |
michael@0 | 156 | |
michael@0 | 157 | /** |
michael@0 | 158 | * Get time zone offsets from local wall time. |
michael@0 | 159 | * @internal |
michael@0 | 160 | */ |
michael@0 | 161 | virtual void getOffsetFromLocal(UDate date, int32_t nonExistingTimeOpt, int32_t duplicatedTimeOpt, |
michael@0 | 162 | int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) const; |
michael@0 | 163 | |
michael@0 | 164 | protected: |
michael@0 | 165 | |
michael@0 | 166 | #ifndef U_HIDE_INTERNAL_API |
michael@0 | 167 | /** |
michael@0 | 168 | * The time type option bit masks used by getOffsetFromLocal |
michael@0 | 169 | * @internal |
michael@0 | 170 | */ |
michael@0 | 171 | enum { |
michael@0 | 172 | kStdDstMask = kDaylight, |
michael@0 | 173 | kFormerLatterMask = kLatter |
michael@0 | 174 | }; |
michael@0 | 175 | #endif /* U_HIDE_INTERNAL_API */ |
michael@0 | 176 | |
michael@0 | 177 | /** |
michael@0 | 178 | * Default constructor. |
michael@0 | 179 | * @stable ICU 3.8 |
michael@0 | 180 | */ |
michael@0 | 181 | BasicTimeZone(); |
michael@0 | 182 | |
michael@0 | 183 | /** |
michael@0 | 184 | * Construct a timezone with a given ID. |
michael@0 | 185 | * @param id a system time zone ID |
michael@0 | 186 | * @stable ICU 3.8 |
michael@0 | 187 | */ |
michael@0 | 188 | BasicTimeZone(const UnicodeString &id); |
michael@0 | 189 | |
michael@0 | 190 | /** |
michael@0 | 191 | * Copy constructor. |
michael@0 | 192 | * @param source the object to be copied. |
michael@0 | 193 | * @stable ICU 3.8 |
michael@0 | 194 | */ |
michael@0 | 195 | BasicTimeZone(const BasicTimeZone& source); |
michael@0 | 196 | |
michael@0 | 197 | /** |
michael@0 | 198 | * Gets the set of TimeZoneRule instances applicable to the specified time and after. |
michael@0 | 199 | * @param start The start date used for extracting time zone rules |
michael@0 | 200 | * @param initial Receives the InitialTimeZone, always not NULL |
michael@0 | 201 | * @param transitionRules Receives the transition rules, could be NULL |
michael@0 | 202 | * @param status Receives error status code |
michael@0 | 203 | */ |
michael@0 | 204 | void getTimeZoneRulesAfter(UDate start, InitialTimeZoneRule*& initial, UVector*& transitionRules, |
michael@0 | 205 | UErrorCode& status) const; |
michael@0 | 206 | }; |
michael@0 | 207 | |
michael@0 | 208 | U_NAMESPACE_END |
michael@0 | 209 | |
michael@0 | 210 | #endif /* #if !UCONFIG_NO_FORMATTING */ |
michael@0 | 211 | |
michael@0 | 212 | #endif // BASICTZ_H |
michael@0 | 213 | |
michael@0 | 214 | //eof |