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