jpayne@69
|
1 // © 2016 and later: Unicode, Inc. and others.
|
jpayne@69
|
2 // License & terms of use: http://www.unicode.org/copyright.html
|
jpayne@69
|
3 /*
|
jpayne@69
|
4 *******************************************************************************
|
jpayne@69
|
5 * Copyright (C) 2007-2008, International Business Machines Corporation and *
|
jpayne@69
|
6 * others. All Rights Reserved. *
|
jpayne@69
|
7 *******************************************************************************
|
jpayne@69
|
8 */
|
jpayne@69
|
9 #ifndef TZRULE_H
|
jpayne@69
|
10 #define TZRULE_H
|
jpayne@69
|
11
|
jpayne@69
|
12 /**
|
jpayne@69
|
13 * \file
|
jpayne@69
|
14 * \brief C++ API: Time zone rule classes
|
jpayne@69
|
15 */
|
jpayne@69
|
16
|
jpayne@69
|
17 #include "unicode/utypes.h"
|
jpayne@69
|
18
|
jpayne@69
|
19 #if U_SHOW_CPLUSPLUS_API
|
jpayne@69
|
20
|
jpayne@69
|
21 #if !UCONFIG_NO_FORMATTING
|
jpayne@69
|
22
|
jpayne@69
|
23 #include "unicode/uobject.h"
|
jpayne@69
|
24 #include "unicode/unistr.h"
|
jpayne@69
|
25 #include "unicode/dtrule.h"
|
jpayne@69
|
26
|
jpayne@69
|
27 U_NAMESPACE_BEGIN
|
jpayne@69
|
28
|
jpayne@69
|
29 /**
|
jpayne@69
|
30 * <code>TimeZoneRule</code> is a class representing a rule for time zone.
|
jpayne@69
|
31 * <code>TimeZoneRule</code> has a set of time zone attributes, such as zone name,
|
jpayne@69
|
32 * raw offset (UTC offset for standard time) and daylight saving time offset.
|
jpayne@69
|
33 *
|
jpayne@69
|
34 * @stable ICU 3.8
|
jpayne@69
|
35 */
|
jpayne@69
|
36 class U_I18N_API TimeZoneRule : public UObject {
|
jpayne@69
|
37 public:
|
jpayne@69
|
38 /**
|
jpayne@69
|
39 * Destructor.
|
jpayne@69
|
40 * @stable ICU 3.8
|
jpayne@69
|
41 */
|
jpayne@69
|
42 virtual ~TimeZoneRule();
|
jpayne@69
|
43
|
jpayne@69
|
44 /**
|
jpayne@69
|
45 * Clone this TimeZoneRule object polymorphically. The caller owns the result and
|
jpayne@69
|
46 * should delete it when done.
|
jpayne@69
|
47 * @return A copy of the object.
|
jpayne@69
|
48 * @stable ICU 3.8
|
jpayne@69
|
49 */
|
jpayne@69
|
50 virtual TimeZoneRule* clone() const = 0;
|
jpayne@69
|
51
|
jpayne@69
|
52 /**
|
jpayne@69
|
53 * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects
|
jpayne@69
|
54 * of different subclasses are considered unequal.
|
jpayne@69
|
55 * @param that The object to be compared with.
|
jpayne@69
|
56 * @return true if the given <code>TimeZoneRule</code> objects are semantically equal.
|
jpayne@69
|
57 * @stable ICU 3.8
|
jpayne@69
|
58 */
|
jpayne@69
|
59 virtual UBool operator==(const TimeZoneRule& that) const;
|
jpayne@69
|
60
|
jpayne@69
|
61 /**
|
jpayne@69
|
62 * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects
|
jpayne@69
|
63 * of different subclasses are considered unequal.
|
jpayne@69
|
64 * @param that The object to be compared with.
|
jpayne@69
|
65 * @return true if the given <code>TimeZoneRule</code> objects are semantically unequal.
|
jpayne@69
|
66 * @stable ICU 3.8
|
jpayne@69
|
67 */
|
jpayne@69
|
68 virtual UBool operator!=(const TimeZoneRule& that) const;
|
jpayne@69
|
69
|
jpayne@69
|
70 /**
|
jpayne@69
|
71 * Fills in "name" with the name of this time zone.
|
jpayne@69
|
72 * @param name Receives the name of this time zone.
|
jpayne@69
|
73 * @return A reference to "name"
|
jpayne@69
|
74 * @stable ICU 3.8
|
jpayne@69
|
75 */
|
jpayne@69
|
76 UnicodeString& getName(UnicodeString& name) const;
|
jpayne@69
|
77
|
jpayne@69
|
78 /**
|
jpayne@69
|
79 * Gets the standard time offset.
|
jpayne@69
|
80 * @return The standard time offset from UTC in milliseconds.
|
jpayne@69
|
81 * @stable ICU 3.8
|
jpayne@69
|
82 */
|
jpayne@69
|
83 int32_t getRawOffset(void) const;
|
jpayne@69
|
84
|
jpayne@69
|
85 /**
|
jpayne@69
|
86 * Gets the amount of daylight saving delta time from the standard time.
|
jpayne@69
|
87 * @return The amount of daylight saving offset used by this rule
|
jpayne@69
|
88 * in milliseconds.
|
jpayne@69
|
89 * @stable ICU 3.8
|
jpayne@69
|
90 */
|
jpayne@69
|
91 int32_t getDSTSavings(void) const;
|
jpayne@69
|
92
|
jpayne@69
|
93 /**
|
jpayne@69
|
94 * Returns if this rule represents the same rule and offsets as another.
|
jpayne@69
|
95 * When two <code>TimeZoneRule</code> objects differ only its names, this method
|
jpayne@69
|
96 * returns true.
|
jpayne@69
|
97 * @param other The <code>TimeZoneRule</code> object to be compared with.
|
jpayne@69
|
98 * @return true if the other <code>TimeZoneRule</code> is the same as this one.
|
jpayne@69
|
99 * @stable ICU 3.8
|
jpayne@69
|
100 */
|
jpayne@69
|
101 virtual UBool isEquivalentTo(const TimeZoneRule& other) const;
|
jpayne@69
|
102
|
jpayne@69
|
103 /**
|
jpayne@69
|
104 * Gets the very first time when this rule takes effect.
|
jpayne@69
|
105 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
106 * takes effect in milliseconds.
|
jpayne@69
|
107 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
108 * standard time.
|
jpayne@69
|
109 * @param result Receives the very first time when this rule takes effect.
|
jpayne@69
|
110 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
111 * "result" is unchanged.
|
jpayne@69
|
112 * @stable ICU 3.8
|
jpayne@69
|
113 */
|
jpayne@69
|
114 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
|
jpayne@69
|
115
|
jpayne@69
|
116 /**
|
jpayne@69
|
117 * Gets the final time when this rule takes effect.
|
jpayne@69
|
118 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
119 * takes effect in milliseconds.
|
jpayne@69
|
120 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
121 * standard time.
|
jpayne@69
|
122 * @param result Receives the final time when this rule takes effect.
|
jpayne@69
|
123 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
124 * "result" is unchanged.
|
jpayne@69
|
125 * @stable ICU 3.8
|
jpayne@69
|
126 */
|
jpayne@69
|
127 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
|
jpayne@69
|
128
|
jpayne@69
|
129 /**
|
jpayne@69
|
130 * Gets the first time when this rule takes effect after the specified time.
|
jpayne@69
|
131 * @param base The first start time after this base time will be returned.
|
jpayne@69
|
132 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
133 * takes effect in milliseconds.
|
jpayne@69
|
134 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
135 * standard time.
|
jpayne@69
|
136 * @param inclusive Whether the base time is inclusive or not.
|
jpayne@69
|
137 * @param result Receives The first time when this rule takes effect after
|
jpayne@69
|
138 * the specified base time.
|
jpayne@69
|
139 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
140 * "result" is unchanged.
|
jpayne@69
|
141 * @stable ICU 3.8
|
jpayne@69
|
142 */
|
jpayne@69
|
143 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
|
jpayne@69
|
144 UBool inclusive, UDate& result) const = 0;
|
jpayne@69
|
145
|
jpayne@69
|
146 /**
|
jpayne@69
|
147 * Gets the most recent time when this rule takes effect before the specified time.
|
jpayne@69
|
148 * @param base The most recent time before this base time will be returned.
|
jpayne@69
|
149 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
150 * takes effect in milliseconds.
|
jpayne@69
|
151 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
152 * standard time.
|
jpayne@69
|
153 * @param inclusive Whether the base time is inclusive or not.
|
jpayne@69
|
154 * @param result Receives The most recent time when this rule takes effect before
|
jpayne@69
|
155 * the specified base time.
|
jpayne@69
|
156 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
157 * "result" is unchanged.
|
jpayne@69
|
158 * @stable ICU 3.8
|
jpayne@69
|
159 */
|
jpayne@69
|
160 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
|
jpayne@69
|
161 UBool inclusive, UDate& result) const = 0;
|
jpayne@69
|
162
|
jpayne@69
|
163 protected:
|
jpayne@69
|
164
|
jpayne@69
|
165 /**
|
jpayne@69
|
166 * Constructs a <code>TimeZoneRule</code> with the name, the GMT offset of its
|
jpayne@69
|
167 * standard time and the amount of daylight saving offset adjustment.
|
jpayne@69
|
168 * @param name The time zone name.
|
jpayne@69
|
169 * @param rawOffset The UTC offset of its standard time in milliseconds.
|
jpayne@69
|
170 * @param dstSavings The amount of daylight saving offset adjustment in milliseconds.
|
jpayne@69
|
171 * If this ia a rule for standard time, the value of this argument is 0.
|
jpayne@69
|
172 * @stable ICU 3.8
|
jpayne@69
|
173 */
|
jpayne@69
|
174 TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
|
jpayne@69
|
175
|
jpayne@69
|
176 /**
|
jpayne@69
|
177 * Copy constructor.
|
jpayne@69
|
178 * @param source The TimeZoneRule object to be copied.
|
jpayne@69
|
179 * @stable ICU 3.8
|
jpayne@69
|
180 */
|
jpayne@69
|
181 TimeZoneRule(const TimeZoneRule& source);
|
jpayne@69
|
182
|
jpayne@69
|
183 /**
|
jpayne@69
|
184 * Assignment operator.
|
jpayne@69
|
185 * @param right The object to be copied.
|
jpayne@69
|
186 * @stable ICU 3.8
|
jpayne@69
|
187 */
|
jpayne@69
|
188 TimeZoneRule& operator=(const TimeZoneRule& right);
|
jpayne@69
|
189
|
jpayne@69
|
190 private:
|
jpayne@69
|
191 UnicodeString fName; // time name
|
jpayne@69
|
192 int32_t fRawOffset; // UTC offset of the standard time in milliseconds
|
jpayne@69
|
193 int32_t fDSTSavings; // DST saving amount in milliseconds
|
jpayne@69
|
194 };
|
jpayne@69
|
195
|
jpayne@69
|
196 /**
|
jpayne@69
|
197 * <code>InitialTimeZoneRule</code> represents a time zone rule
|
jpayne@69
|
198 * representing a time zone effective from the beginning and
|
jpayne@69
|
199 * has no actual start times.
|
jpayne@69
|
200 * @stable ICU 3.8
|
jpayne@69
|
201 */
|
jpayne@69
|
202 class U_I18N_API InitialTimeZoneRule : public TimeZoneRule {
|
jpayne@69
|
203 public:
|
jpayne@69
|
204 /**
|
jpayne@69
|
205 * Constructs an <code>InitialTimeZoneRule</code> with the name, the GMT offset of its
|
jpayne@69
|
206 * standard time and the amount of daylight saving offset adjustment.
|
jpayne@69
|
207 * @param name The time zone name.
|
jpayne@69
|
208 * @param rawOffset The UTC offset of its standard time in milliseconds.
|
jpayne@69
|
209 * @param dstSavings The amount of daylight saving offset adjustment in milliseconds.
|
jpayne@69
|
210 * If this ia a rule for standard time, the value of this argument is 0.
|
jpayne@69
|
211 * @stable ICU 3.8
|
jpayne@69
|
212 */
|
jpayne@69
|
213 InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
|
jpayne@69
|
214
|
jpayne@69
|
215 /**
|
jpayne@69
|
216 * Copy constructor.
|
jpayne@69
|
217 * @param source The InitialTimeZoneRule object to be copied.
|
jpayne@69
|
218 * @stable ICU 3.8
|
jpayne@69
|
219 */
|
jpayne@69
|
220 InitialTimeZoneRule(const InitialTimeZoneRule& source);
|
jpayne@69
|
221
|
jpayne@69
|
222 /**
|
jpayne@69
|
223 * Destructor.
|
jpayne@69
|
224 * @stable ICU 3.8
|
jpayne@69
|
225 */
|
jpayne@69
|
226 virtual ~InitialTimeZoneRule();
|
jpayne@69
|
227
|
jpayne@69
|
228 /**
|
jpayne@69
|
229 * Clone this InitialTimeZoneRule object polymorphically. The caller owns the result and
|
jpayne@69
|
230 * should delete it when done.
|
jpayne@69
|
231 * @return A copy of the object.
|
jpayne@69
|
232 * @stable ICU 3.8
|
jpayne@69
|
233 */
|
jpayne@69
|
234 virtual InitialTimeZoneRule* clone() const;
|
jpayne@69
|
235
|
jpayne@69
|
236 /**
|
jpayne@69
|
237 * Assignment operator.
|
jpayne@69
|
238 * @param right The object to be copied.
|
jpayne@69
|
239 * @stable ICU 3.8
|
jpayne@69
|
240 */
|
jpayne@69
|
241 InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right);
|
jpayne@69
|
242
|
jpayne@69
|
243 /**
|
jpayne@69
|
244 * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects
|
jpayne@69
|
245 * of different subclasses are considered unequal.
|
jpayne@69
|
246 * @param that The object to be compared with.
|
jpayne@69
|
247 * @return true if the given <code>TimeZoneRule</code> objects are semantically equal.
|
jpayne@69
|
248 * @stable ICU 3.8
|
jpayne@69
|
249 */
|
jpayne@69
|
250 virtual UBool operator==(const TimeZoneRule& that) const;
|
jpayne@69
|
251
|
jpayne@69
|
252 /**
|
jpayne@69
|
253 * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects
|
jpayne@69
|
254 * of different subclasses are considered unequal.
|
jpayne@69
|
255 * @param that The object to be compared with.
|
jpayne@69
|
256 * @return true if the given <code>TimeZoneRule</code> objects are semantically unequal.
|
jpayne@69
|
257 * @stable ICU 3.8
|
jpayne@69
|
258 */
|
jpayne@69
|
259 virtual UBool operator!=(const TimeZoneRule& that) const;
|
jpayne@69
|
260
|
jpayne@69
|
261 /**
|
jpayne@69
|
262 * Gets the time when this rule takes effect in the given year.
|
jpayne@69
|
263 * @param year The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
|
jpayne@69
|
264 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
265 * takes effect in milliseconds.
|
jpayne@69
|
266 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
267 * standard time.
|
jpayne@69
|
268 * @param result Receives the start time in the year.
|
jpayne@69
|
269 * @return true if this rule takes effect in the year and the result is set to
|
jpayne@69
|
270 * "result".
|
jpayne@69
|
271 * @stable ICU 3.8
|
jpayne@69
|
272 */
|
jpayne@69
|
273 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
|
jpayne@69
|
274
|
jpayne@69
|
275 /**
|
jpayne@69
|
276 * Returns if this rule represents the same rule and offsets as another.
|
jpayne@69
|
277 * When two <code>TimeZoneRule</code> objects differ only its names, this method
|
jpayne@69
|
278 * returns true.
|
jpayne@69
|
279 * @param that The <code>TimeZoneRule</code> object to be compared with.
|
jpayne@69
|
280 * @return true if the other <code>TimeZoneRule</code> is equivalent to this one.
|
jpayne@69
|
281 * @stable ICU 3.8
|
jpayne@69
|
282 */
|
jpayne@69
|
283 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
|
jpayne@69
|
284
|
jpayne@69
|
285 /**
|
jpayne@69
|
286 * Gets the very first time when this rule takes effect.
|
jpayne@69
|
287 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
288 * takes effect in milliseconds.
|
jpayne@69
|
289 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
290 * standard time.
|
jpayne@69
|
291 * @param result Receives the very first time when this rule takes effect.
|
jpayne@69
|
292 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
293 * "result" is unchanged.
|
jpayne@69
|
294 * @stable ICU 3.8
|
jpayne@69
|
295 */
|
jpayne@69
|
296 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
|
jpayne@69
|
297
|
jpayne@69
|
298 /**
|
jpayne@69
|
299 * Gets the final time when this rule takes effect.
|
jpayne@69
|
300 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
301 * takes effect in milliseconds.
|
jpayne@69
|
302 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
303 * standard time.
|
jpayne@69
|
304 * @param result Receives the final time when this rule takes effect.
|
jpayne@69
|
305 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
306 * "result" is unchanged.
|
jpayne@69
|
307 * @stable ICU 3.8
|
jpayne@69
|
308 */
|
jpayne@69
|
309 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
|
jpayne@69
|
310
|
jpayne@69
|
311 /**
|
jpayne@69
|
312 * Gets the first time when this rule takes effect after the specified time.
|
jpayne@69
|
313 * @param base The first start time after this base time will be returned.
|
jpayne@69
|
314 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
315 * takes effect in milliseconds.
|
jpayne@69
|
316 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
317 * standard time.
|
jpayne@69
|
318 * @param inclusive Whether the base time is inclusive or not.
|
jpayne@69
|
319 * @param result Receives The first time when this rule takes effect after
|
jpayne@69
|
320 * the specified base time.
|
jpayne@69
|
321 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
322 * "result" is unchanged.
|
jpayne@69
|
323 * @stable ICU 3.8
|
jpayne@69
|
324 */
|
jpayne@69
|
325 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
|
jpayne@69
|
326 UBool inclusive, UDate& result) const;
|
jpayne@69
|
327
|
jpayne@69
|
328 /**
|
jpayne@69
|
329 * Gets the most recent time when this rule takes effect before the specified time.
|
jpayne@69
|
330 * @param base The most recent time before this base time will be returned.
|
jpayne@69
|
331 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
332 * takes effect in milliseconds.
|
jpayne@69
|
333 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
334 * standard time.
|
jpayne@69
|
335 * @param inclusive Whether the base time is inclusive or not.
|
jpayne@69
|
336 * @param result Receives The most recent time when this rule takes effect before
|
jpayne@69
|
337 * the specified base time.
|
jpayne@69
|
338 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
339 * "result" is unchanged.
|
jpayne@69
|
340 * @stable ICU 3.8
|
jpayne@69
|
341 */
|
jpayne@69
|
342 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
|
jpayne@69
|
343 UBool inclusive, UDate& result) const;
|
jpayne@69
|
344
|
jpayne@69
|
345 public:
|
jpayne@69
|
346 /**
|
jpayne@69
|
347 * Return the class ID for this class. This is useful only for comparing to
|
jpayne@69
|
348 * a return value from getDynamicClassID(). For example:
|
jpayne@69
|
349 * <pre>
|
jpayne@69
|
350 * . Base* polymorphic_pointer = createPolymorphicObject();
|
jpayne@69
|
351 * . if (polymorphic_pointer->getDynamicClassID() ==
|
jpayne@69
|
352 * . erived::getStaticClassID()) ...
|
jpayne@69
|
353 * </pre>
|
jpayne@69
|
354 * @return The class ID for all objects of this class.
|
jpayne@69
|
355 * @stable ICU 3.8
|
jpayne@69
|
356 */
|
jpayne@69
|
357 static UClassID U_EXPORT2 getStaticClassID(void);
|
jpayne@69
|
358
|
jpayne@69
|
359 /**
|
jpayne@69
|
360 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
jpayne@69
|
361 * method is to implement a simple version of RTTI, since not all C++
|
jpayne@69
|
362 * compilers support genuine RTTI. Polymorphic operator==() and clone()
|
jpayne@69
|
363 * methods call this method.
|
jpayne@69
|
364 *
|
jpayne@69
|
365 * @return The class ID for this object. All objects of a
|
jpayne@69
|
366 * given class have the same class ID. Objects of
|
jpayne@69
|
367 * other classes have different class IDs.
|
jpayne@69
|
368 * @stable ICU 3.8
|
jpayne@69
|
369 */
|
jpayne@69
|
370 virtual UClassID getDynamicClassID(void) const;
|
jpayne@69
|
371 };
|
jpayne@69
|
372
|
jpayne@69
|
373 /**
|
jpayne@69
|
374 * <code>AnnualTimeZoneRule</code> is a class used for representing a time zone
|
jpayne@69
|
375 * rule which takes effect annually. The calenday system used for the rule is
|
jpayne@69
|
376 * is based on Gregorian calendar
|
jpayne@69
|
377 *
|
jpayne@69
|
378 * @stable ICU 3.8
|
jpayne@69
|
379 */
|
jpayne@69
|
380 class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule {
|
jpayne@69
|
381 public:
|
jpayne@69
|
382 /**
|
jpayne@69
|
383 * The constant representing the maximum year used for designating
|
jpayne@69
|
384 * a rule is permanent.
|
jpayne@69
|
385 */
|
jpayne@69
|
386 static const int32_t MAX_YEAR;
|
jpayne@69
|
387
|
jpayne@69
|
388 /**
|
jpayne@69
|
389 * Constructs a <code>AnnualTimeZoneRule</code> with the name, the GMT offset of its
|
jpayne@69
|
390 * standard time, the amount of daylight saving offset adjustment, the annual start
|
jpayne@69
|
391 * time rule and the start/until years. The input DateTimeRule is copied by this
|
jpayne@69
|
392 * constructor, so the caller remains responsible for deleting the object.
|
jpayne@69
|
393 * @param name The time zone name.
|
jpayne@69
|
394 * @param rawOffset The GMT offset of its standard time in milliseconds.
|
jpayne@69
|
395 * @param dstSavings The amount of daylight saving offset adjustment in
|
jpayne@69
|
396 * milliseconds. If this ia a rule for standard time,
|
jpayne@69
|
397 * the value of this argument is 0.
|
jpayne@69
|
398 * @param dateTimeRule The start date/time rule repeated annually.
|
jpayne@69
|
399 * @param startYear The first year when this rule takes effect.
|
jpayne@69
|
400 * @param endYear The last year when this rule takes effect. If this
|
jpayne@69
|
401 * rule is effective forever in future, specify MAX_YEAR.
|
jpayne@69
|
402 * @stable ICU 3.8
|
jpayne@69
|
403 */
|
jpayne@69
|
404 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
|
jpayne@69
|
405 const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);
|
jpayne@69
|
406
|
jpayne@69
|
407 /**
|
jpayne@69
|
408 * Constructs a <code>AnnualTimeZoneRule</code> with the name, the GMT offset of its
|
jpayne@69
|
409 * standard time, the amount of daylight saving offset adjustment, the annual start
|
jpayne@69
|
410 * time rule and the start/until years. The input DateTimeRule object is adopted
|
jpayne@69
|
411 * by this object, therefore, the caller must not delete the object.
|
jpayne@69
|
412 * @param name The time zone name.
|
jpayne@69
|
413 * @param rawOffset The GMT offset of its standard time in milliseconds.
|
jpayne@69
|
414 * @param dstSavings The amount of daylight saving offset adjustment in
|
jpayne@69
|
415 * milliseconds. If this ia a rule for standard time,
|
jpayne@69
|
416 * the value of this argument is 0.
|
jpayne@69
|
417 * @param dateTimeRule The start date/time rule repeated annually.
|
jpayne@69
|
418 * @param startYear The first year when this rule takes effect.
|
jpayne@69
|
419 * @param endYear The last year when this rule takes effect. If this
|
jpayne@69
|
420 * rule is effective forever in future, specify MAX_YEAR.
|
jpayne@69
|
421 * @stable ICU 3.8
|
jpayne@69
|
422 */
|
jpayne@69
|
423 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
|
jpayne@69
|
424 DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);
|
jpayne@69
|
425
|
jpayne@69
|
426 /**
|
jpayne@69
|
427 * Copy constructor.
|
jpayne@69
|
428 * @param source The AnnualTimeZoneRule object to be copied.
|
jpayne@69
|
429 * @stable ICU 3.8
|
jpayne@69
|
430 */
|
jpayne@69
|
431 AnnualTimeZoneRule(const AnnualTimeZoneRule& source);
|
jpayne@69
|
432
|
jpayne@69
|
433 /**
|
jpayne@69
|
434 * Destructor.
|
jpayne@69
|
435 * @stable ICU 3.8
|
jpayne@69
|
436 */
|
jpayne@69
|
437 virtual ~AnnualTimeZoneRule();
|
jpayne@69
|
438
|
jpayne@69
|
439 /**
|
jpayne@69
|
440 * Clone this AnnualTimeZoneRule object polymorphically. The caller owns the result and
|
jpayne@69
|
441 * should delete it when done.
|
jpayne@69
|
442 * @return A copy of the object.
|
jpayne@69
|
443 * @stable ICU 3.8
|
jpayne@69
|
444 */
|
jpayne@69
|
445 virtual AnnualTimeZoneRule* clone() const;
|
jpayne@69
|
446
|
jpayne@69
|
447 /**
|
jpayne@69
|
448 * Assignment operator.
|
jpayne@69
|
449 * @param right The object to be copied.
|
jpayne@69
|
450 * @stable ICU 3.8
|
jpayne@69
|
451 */
|
jpayne@69
|
452 AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right);
|
jpayne@69
|
453
|
jpayne@69
|
454 /**
|
jpayne@69
|
455 * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects
|
jpayne@69
|
456 * of different subclasses are considered unequal.
|
jpayne@69
|
457 * @param that The object to be compared with.
|
jpayne@69
|
458 * @return true if the given <code>TimeZoneRule</code> objects are semantically equal.
|
jpayne@69
|
459 * @stable ICU 3.8
|
jpayne@69
|
460 */
|
jpayne@69
|
461 virtual UBool operator==(const TimeZoneRule& that) const;
|
jpayne@69
|
462
|
jpayne@69
|
463 /**
|
jpayne@69
|
464 * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects
|
jpayne@69
|
465 * of different subclasses are considered unequal.
|
jpayne@69
|
466 * @param that The object to be compared with.
|
jpayne@69
|
467 * @return true if the given <code>TimeZoneRule</code> objects are semantically unequal.
|
jpayne@69
|
468 * @stable ICU 3.8
|
jpayne@69
|
469 */
|
jpayne@69
|
470 virtual UBool operator!=(const TimeZoneRule& that) const;
|
jpayne@69
|
471
|
jpayne@69
|
472 /**
|
jpayne@69
|
473 * Gets the start date/time rule used by this rule.
|
jpayne@69
|
474 * @return The <code>AnnualDateTimeRule</code> which represents the start date/time
|
jpayne@69
|
475 * rule used by this time zone rule.
|
jpayne@69
|
476 * @stable ICU 3.8
|
jpayne@69
|
477 */
|
jpayne@69
|
478 const DateTimeRule* getRule(void) const;
|
jpayne@69
|
479
|
jpayne@69
|
480 /**
|
jpayne@69
|
481 * Gets the first year when this rule takes effect.
|
jpayne@69
|
482 * @return The start year of this rule. The year is in Gregorian calendar
|
jpayne@69
|
483 * with 0 == 1 BCE, -1 == 2 BCE, etc.
|
jpayne@69
|
484 * @stable ICU 3.8
|
jpayne@69
|
485 */
|
jpayne@69
|
486 int32_t getStartYear(void) const;
|
jpayne@69
|
487
|
jpayne@69
|
488 /**
|
jpayne@69
|
489 * Gets the end year when this rule takes effect.
|
jpayne@69
|
490 * @return The end year of this rule (inclusive). The year is in Gregorian calendar
|
jpayne@69
|
491 * with 0 == 1 BCE, -1 == 2 BCE, etc.
|
jpayne@69
|
492 * @stable ICU 3.8
|
jpayne@69
|
493 */
|
jpayne@69
|
494 int32_t getEndYear(void) const;
|
jpayne@69
|
495
|
jpayne@69
|
496 /**
|
jpayne@69
|
497 * Gets the time when this rule takes effect in the given year.
|
jpayne@69
|
498 * @param year The Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc.
|
jpayne@69
|
499 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
500 * takes effect in milliseconds.
|
jpayne@69
|
501 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
502 * standard time.
|
jpayne@69
|
503 * @param result Receives the start time in the year.
|
jpayne@69
|
504 * @return true if this rule takes effect in the year and the result is set to
|
jpayne@69
|
505 * "result".
|
jpayne@69
|
506 * @stable ICU 3.8
|
jpayne@69
|
507 */
|
jpayne@69
|
508 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
|
jpayne@69
|
509
|
jpayne@69
|
510 /**
|
jpayne@69
|
511 * Returns if this rule represents the same rule and offsets as another.
|
jpayne@69
|
512 * When two <code>TimeZoneRule</code> objects differ only its names, this method
|
jpayne@69
|
513 * returns true.
|
jpayne@69
|
514 * @param that The <code>TimeZoneRule</code> object to be compared with.
|
jpayne@69
|
515 * @return true if the other <code>TimeZoneRule</code> is equivalent to this one.
|
jpayne@69
|
516 * @stable ICU 3.8
|
jpayne@69
|
517 */
|
jpayne@69
|
518 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
|
jpayne@69
|
519
|
jpayne@69
|
520 /**
|
jpayne@69
|
521 * Gets the very first time when this rule takes effect.
|
jpayne@69
|
522 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
523 * takes effect in milliseconds.
|
jpayne@69
|
524 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
525 * standard time.
|
jpayne@69
|
526 * @param result Receives the very first time when this rule takes effect.
|
jpayne@69
|
527 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
528 * "result" is unchanged.
|
jpayne@69
|
529 * @stable ICU 3.8
|
jpayne@69
|
530 */
|
jpayne@69
|
531 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
|
jpayne@69
|
532
|
jpayne@69
|
533 /**
|
jpayne@69
|
534 * Gets the final time when this rule takes effect.
|
jpayne@69
|
535 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
536 * takes effect in milliseconds.
|
jpayne@69
|
537 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
538 * standard time.
|
jpayne@69
|
539 * @param result Receives the final time when this rule takes effect.
|
jpayne@69
|
540 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
541 * "result" is unchanged.
|
jpayne@69
|
542 * @stable ICU 3.8
|
jpayne@69
|
543 */
|
jpayne@69
|
544 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
|
jpayne@69
|
545
|
jpayne@69
|
546 /**
|
jpayne@69
|
547 * Gets the first time when this rule takes effect after the specified time.
|
jpayne@69
|
548 * @param base The first start time after this base time will be returned.
|
jpayne@69
|
549 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
550 * takes effect in milliseconds.
|
jpayne@69
|
551 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
552 * standard time.
|
jpayne@69
|
553 * @param inclusive Whether the base time is inclusive or not.
|
jpayne@69
|
554 * @param result Receives The first time when this rule takes effect after
|
jpayne@69
|
555 * the specified base time.
|
jpayne@69
|
556 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
557 * "result" is unchanged.
|
jpayne@69
|
558 * @stable ICU 3.8
|
jpayne@69
|
559 */
|
jpayne@69
|
560 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
|
jpayne@69
|
561 UBool inclusive, UDate& result) const;
|
jpayne@69
|
562
|
jpayne@69
|
563 /**
|
jpayne@69
|
564 * Gets the most recent time when this rule takes effect before the specified time.
|
jpayne@69
|
565 * @param base The most recent time before this base time will be returned.
|
jpayne@69
|
566 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
567 * takes effect in milliseconds.
|
jpayne@69
|
568 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
569 * standard time.
|
jpayne@69
|
570 * @param inclusive Whether the base time is inclusive or not.
|
jpayne@69
|
571 * @param result Receives The most recent time when this rule takes effect before
|
jpayne@69
|
572 * the specified base time.
|
jpayne@69
|
573 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
574 * "result" is unchanged.
|
jpayne@69
|
575 * @stable ICU 3.8
|
jpayne@69
|
576 */
|
jpayne@69
|
577 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
|
jpayne@69
|
578 UBool inclusive, UDate& result) const;
|
jpayne@69
|
579
|
jpayne@69
|
580
|
jpayne@69
|
581 private:
|
jpayne@69
|
582 DateTimeRule* fDateTimeRule;
|
jpayne@69
|
583 int32_t fStartYear;
|
jpayne@69
|
584 int32_t fEndYear;
|
jpayne@69
|
585
|
jpayne@69
|
586 public:
|
jpayne@69
|
587 /**
|
jpayne@69
|
588 * Return the class ID for this class. This is useful only for comparing to
|
jpayne@69
|
589 * a return value from getDynamicClassID(). For example:
|
jpayne@69
|
590 * <pre>
|
jpayne@69
|
591 * . Base* polymorphic_pointer = createPolymorphicObject();
|
jpayne@69
|
592 * . if (polymorphic_pointer->getDynamicClassID() ==
|
jpayne@69
|
593 * . erived::getStaticClassID()) ...
|
jpayne@69
|
594 * </pre>
|
jpayne@69
|
595 * @return The class ID for all objects of this class.
|
jpayne@69
|
596 * @stable ICU 3.8
|
jpayne@69
|
597 */
|
jpayne@69
|
598 static UClassID U_EXPORT2 getStaticClassID(void);
|
jpayne@69
|
599
|
jpayne@69
|
600 /**
|
jpayne@69
|
601 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
jpayne@69
|
602 * method is to implement a simple version of RTTI, since not all C++
|
jpayne@69
|
603 * compilers support genuine RTTI. Polymorphic operator==() and clone()
|
jpayne@69
|
604 * methods call this method.
|
jpayne@69
|
605 *
|
jpayne@69
|
606 * @return The class ID for this object. All objects of a
|
jpayne@69
|
607 * given class have the same class ID. Objects of
|
jpayne@69
|
608 * other classes have different class IDs.
|
jpayne@69
|
609 * @stable ICU 3.8
|
jpayne@69
|
610 */
|
jpayne@69
|
611 virtual UClassID getDynamicClassID(void) const;
|
jpayne@69
|
612 };
|
jpayne@69
|
613
|
jpayne@69
|
614 /**
|
jpayne@69
|
615 * <code>TimeArrayTimeZoneRule</code> represents a time zone rule whose start times are
|
jpayne@69
|
616 * defined by an array of milliseconds since the standard base time.
|
jpayne@69
|
617 *
|
jpayne@69
|
618 * @stable ICU 3.8
|
jpayne@69
|
619 */
|
jpayne@69
|
620 class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule {
|
jpayne@69
|
621 public:
|
jpayne@69
|
622 /**
|
jpayne@69
|
623 * Constructs a <code>TimeArrayTimeZoneRule</code> with the name, the GMT offset of its
|
jpayne@69
|
624 * standard time, the amount of daylight saving offset adjustment and
|
jpayne@69
|
625 * the array of times when this rule takes effect.
|
jpayne@69
|
626 * @param name The time zone name.
|
jpayne@69
|
627 * @param rawOffset The UTC offset of its standard time in milliseconds.
|
jpayne@69
|
628 * @param dstSavings The amount of daylight saving offset adjustment in
|
jpayne@69
|
629 * milliseconds. If this ia a rule for standard time,
|
jpayne@69
|
630 * the value of this argument is 0.
|
jpayne@69
|
631 * @param startTimes The array start times in milliseconds since the base time
|
jpayne@69
|
632 * (January 1, 1970, 00:00:00).
|
jpayne@69
|
633 * @param numStartTimes The number of elements in the parameter "startTimes"
|
jpayne@69
|
634 * @param timeRuleType The time type of the start times, which is one of
|
jpayne@69
|
635 * <code>DataTimeRule::WALL_TIME</code>, <code>STANDARD_TIME</code>
|
jpayne@69
|
636 * and <code>UTC_TIME</code>.
|
jpayne@69
|
637 * @stable ICU 3.8
|
jpayne@69
|
638 */
|
jpayne@69
|
639 TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
|
jpayne@69
|
640 const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
|
jpayne@69
|
641
|
jpayne@69
|
642 /**
|
jpayne@69
|
643 * Copy constructor.
|
jpayne@69
|
644 * @param source The TimeArrayTimeZoneRule object to be copied.
|
jpayne@69
|
645 * @stable ICU 3.8
|
jpayne@69
|
646 */
|
jpayne@69
|
647 TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source);
|
jpayne@69
|
648
|
jpayne@69
|
649 /**
|
jpayne@69
|
650 * Destructor.
|
jpayne@69
|
651 * @stable ICU 3.8
|
jpayne@69
|
652 */
|
jpayne@69
|
653 virtual ~TimeArrayTimeZoneRule();
|
jpayne@69
|
654
|
jpayne@69
|
655 /**
|
jpayne@69
|
656 * Clone this TimeArrayTimeZoneRule object polymorphically. The caller owns the result and
|
jpayne@69
|
657 * should delete it when done.
|
jpayne@69
|
658 * @return A copy of the object.
|
jpayne@69
|
659 * @stable ICU 3.8
|
jpayne@69
|
660 */
|
jpayne@69
|
661 virtual TimeArrayTimeZoneRule* clone() const;
|
jpayne@69
|
662
|
jpayne@69
|
663 /**
|
jpayne@69
|
664 * Assignment operator.
|
jpayne@69
|
665 * @param right The object to be copied.
|
jpayne@69
|
666 * @stable ICU 3.8
|
jpayne@69
|
667 */
|
jpayne@69
|
668 TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right);
|
jpayne@69
|
669
|
jpayne@69
|
670 /**
|
jpayne@69
|
671 * Return true if the given <code>TimeZoneRule</code> objects are semantically equal. Objects
|
jpayne@69
|
672 * of different subclasses are considered unequal.
|
jpayne@69
|
673 * @param that The object to be compared with.
|
jpayne@69
|
674 * @return true if the given <code>TimeZoneRule</code> objects are semantically equal.
|
jpayne@69
|
675 * @stable ICU 3.8
|
jpayne@69
|
676 */
|
jpayne@69
|
677 virtual UBool operator==(const TimeZoneRule& that) const;
|
jpayne@69
|
678
|
jpayne@69
|
679 /**
|
jpayne@69
|
680 * Return true if the given <code>TimeZoneRule</code> objects are semantically unequal. Objects
|
jpayne@69
|
681 * of different subclasses are considered unequal.
|
jpayne@69
|
682 * @param that The object to be compared with.
|
jpayne@69
|
683 * @return true if the given <code>TimeZoneRule</code> objects are semantically unequal.
|
jpayne@69
|
684 * @stable ICU 3.8
|
jpayne@69
|
685 */
|
jpayne@69
|
686 virtual UBool operator!=(const TimeZoneRule& that) const;
|
jpayne@69
|
687
|
jpayne@69
|
688 /**
|
jpayne@69
|
689 * Gets the time type of the start times used by this rule. The return value
|
jpayne@69
|
690 * is either <code>DateTimeRule::WALL_TIME</code> or <code>STANDARD_TIME</code>
|
jpayne@69
|
691 * or <code>UTC_TIME</code>.
|
jpayne@69
|
692 *
|
jpayne@69
|
693 * @return The time type used of the start times used by this rule.
|
jpayne@69
|
694 * @stable ICU 3.8
|
jpayne@69
|
695 */
|
jpayne@69
|
696 DateTimeRule::TimeRuleType getTimeType(void) const;
|
jpayne@69
|
697
|
jpayne@69
|
698 /**
|
jpayne@69
|
699 * Gets a start time at the index stored in this rule.
|
jpayne@69
|
700 * @param index The index of start times
|
jpayne@69
|
701 * @param result Receives the start time at the index
|
jpayne@69
|
702 * @return true if the index is within the valid range and
|
jpayne@69
|
703 * and the result is set. When false, the output
|
jpayne@69
|
704 * parameger "result" is unchanged.
|
jpayne@69
|
705 * @stable ICU 3.8
|
jpayne@69
|
706 */
|
jpayne@69
|
707 UBool getStartTimeAt(int32_t index, UDate& result) const;
|
jpayne@69
|
708
|
jpayne@69
|
709 /**
|
jpayne@69
|
710 * Returns the number of start times stored in this rule
|
jpayne@69
|
711 * @return The number of start times.
|
jpayne@69
|
712 * @stable ICU 3.8
|
jpayne@69
|
713 */
|
jpayne@69
|
714 int32_t countStartTimes(void) const;
|
jpayne@69
|
715
|
jpayne@69
|
716 /**
|
jpayne@69
|
717 * Returns if this rule represents the same rule and offsets as another.
|
jpayne@69
|
718 * When two <code>TimeZoneRule</code> objects differ only its names, this method
|
jpayne@69
|
719 * returns true.
|
jpayne@69
|
720 * @param that The <code>TimeZoneRule</code> object to be compared with.
|
jpayne@69
|
721 * @return true if the other <code>TimeZoneRule</code> is equivalent to this one.
|
jpayne@69
|
722 * @stable ICU 3.8
|
jpayne@69
|
723 */
|
jpayne@69
|
724 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
|
jpayne@69
|
725
|
jpayne@69
|
726 /**
|
jpayne@69
|
727 * Gets the very first time when this rule takes effect.
|
jpayne@69
|
728 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
729 * takes effect in milliseconds.
|
jpayne@69
|
730 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
731 * standard time.
|
jpayne@69
|
732 * @param result Receives the very first time when this rule takes effect.
|
jpayne@69
|
733 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
734 * "result" is unchanged.
|
jpayne@69
|
735 * @stable ICU 3.8
|
jpayne@69
|
736 */
|
jpayne@69
|
737 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
|
jpayne@69
|
738
|
jpayne@69
|
739 /**
|
jpayne@69
|
740 * Gets the final time when this rule takes effect.
|
jpayne@69
|
741 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
742 * takes effect in milliseconds.
|
jpayne@69
|
743 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
744 * standard time.
|
jpayne@69
|
745 * @param result Receives the final time when this rule takes effect.
|
jpayne@69
|
746 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
747 * "result" is unchanged.
|
jpayne@69
|
748 * @stable ICU 3.8
|
jpayne@69
|
749 */
|
jpayne@69
|
750 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
|
jpayne@69
|
751
|
jpayne@69
|
752 /**
|
jpayne@69
|
753 * Gets the first time when this rule takes effect after the specified time.
|
jpayne@69
|
754 * @param base The first start time after this base time will be returned.
|
jpayne@69
|
755 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
756 * takes effect in milliseconds.
|
jpayne@69
|
757 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
758 * standard time.
|
jpayne@69
|
759 * @param inclusive Whether the base time is inclusive or not.
|
jpayne@69
|
760 * @param result Receives The first time when this rule takes effect after
|
jpayne@69
|
761 * the specified base time.
|
jpayne@69
|
762 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
763 * "result" is unchanged.
|
jpayne@69
|
764 * @stable ICU 3.8
|
jpayne@69
|
765 */
|
jpayne@69
|
766 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
|
jpayne@69
|
767 UBool inclusive, UDate& result) const;
|
jpayne@69
|
768
|
jpayne@69
|
769 /**
|
jpayne@69
|
770 * Gets the most recent time when this rule takes effect before the specified time.
|
jpayne@69
|
771 * @param base The most recent time before this base time will be returned.
|
jpayne@69
|
772 * @param prevRawOffset The standard time offset from UTC before this rule
|
jpayne@69
|
773 * takes effect in milliseconds.
|
jpayne@69
|
774 * @param prevDSTSavings The amount of daylight saving offset from the
|
jpayne@69
|
775 * standard time.
|
jpayne@69
|
776 * @param inclusive Whether the base time is inclusive or not.
|
jpayne@69
|
777 * @param result Receives The most recent time when this rule takes effect before
|
jpayne@69
|
778 * the specified base time.
|
jpayne@69
|
779 * @return true if the start time is available. When false is returned, output parameter
|
jpayne@69
|
780 * "result" is unchanged.
|
jpayne@69
|
781 * @stable ICU 3.8
|
jpayne@69
|
782 */
|
jpayne@69
|
783 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
|
jpayne@69
|
784 UBool inclusive, UDate& result) const;
|
jpayne@69
|
785
|
jpayne@69
|
786
|
jpayne@69
|
787 private:
|
jpayne@69
|
788 enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };
|
jpayne@69
|
789 UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);
|
jpayne@69
|
790 UDate getUTC(UDate time, int32_t raw, int32_t dst) const;
|
jpayne@69
|
791
|
jpayne@69
|
792 DateTimeRule::TimeRuleType fTimeRuleType;
|
jpayne@69
|
793 int32_t fNumStartTimes;
|
jpayne@69
|
794 UDate* fStartTimes;
|
jpayne@69
|
795 UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];
|
jpayne@69
|
796
|
jpayne@69
|
797 public:
|
jpayne@69
|
798 /**
|
jpayne@69
|
799 * Return the class ID for this class. This is useful only for comparing to
|
jpayne@69
|
800 * a return value from getDynamicClassID(). For example:
|
jpayne@69
|
801 * <pre>
|
jpayne@69
|
802 * . Base* polymorphic_pointer = createPolymorphicObject();
|
jpayne@69
|
803 * . if (polymorphic_pointer->getDynamicClassID() ==
|
jpayne@69
|
804 * . erived::getStaticClassID()) ...
|
jpayne@69
|
805 * </pre>
|
jpayne@69
|
806 * @return The class ID for all objects of this class.
|
jpayne@69
|
807 * @stable ICU 3.8
|
jpayne@69
|
808 */
|
jpayne@69
|
809 static UClassID U_EXPORT2 getStaticClassID(void);
|
jpayne@69
|
810
|
jpayne@69
|
811 /**
|
jpayne@69
|
812 * Returns a unique class ID POLYMORPHICALLY. Pure virtual override. This
|
jpayne@69
|
813 * method is to implement a simple version of RTTI, since not all C++
|
jpayne@69
|
814 * compilers support genuine RTTI. Polymorphic operator==() and clone()
|
jpayne@69
|
815 * methods call this method.
|
jpayne@69
|
816 *
|
jpayne@69
|
817 * @return The class ID for this object. All objects of a
|
jpayne@69
|
818 * given class have the same class ID. Objects of
|
jpayne@69
|
819 * other classes have different class IDs.
|
jpayne@69
|
820 * @stable ICU 3.8
|
jpayne@69
|
821 */
|
jpayne@69
|
822 virtual UClassID getDynamicClassID(void) const;
|
jpayne@69
|
823 };
|
jpayne@69
|
824
|
jpayne@69
|
825
|
jpayne@69
|
826 U_NAMESPACE_END
|
jpayne@69
|
827
|
jpayne@69
|
828 #endif /* #if !UCONFIG_NO_FORMATTING */
|
jpayne@69
|
829
|
jpayne@69
|
830 #endif /* U_SHOW_CPLUSPLUS_API */
|
jpayne@69
|
831
|
jpayne@69
|
832 #endif // TZRULE_H
|
jpayne@69
|
833
|
jpayne@69
|
834 //eof
|