Debian Codegraph @

intl/icu/source/i18n/unicode/tzrule.h

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