ICU 54.1 54.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tzrule.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 * Copyright (C) 2007-2008, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
6 */
7 #ifndef TZRULE_H
8 #define TZRULE_H
9
15 #include "unicode/utypes.h"
16
17 #if !UCONFIG_NO_FORMATTING
18
19 #include "unicode/uobject.h"
20 #include "unicode/unistr.h"
21 #include "unicode/dtrule.h"
22
23 U_NAMESPACE_BEGIN
24
32 class U_I18N_API TimeZoneRule : public UObject {
33 public:
38 virtual ~TimeZoneRule();
39
46 virtual TimeZoneRule* clone(void) const = 0;
47
55 virtual UBool operator==(const TimeZoneRule& that) const;
56
64 virtual UBool operator!=(const TimeZoneRule& that) const;
65
72 UnicodeString& getName(UnicodeString& name) const;
73
79 int32_t getRawOffset(void) const;
80
87 int32_t getDSTSavings(void) const;
88
97 virtual UBool isEquivalentTo(const TimeZoneRule& other) const;
98
110 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
111
123 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
124
139 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
140 UBool inclusive, UDate& result) const = 0;
141
156 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
157 UBool inclusive, UDate& result) const = 0;
158
159 protected:
160
170 TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
171
177 TimeZoneRule(const TimeZoneRule& source);
178
184 TimeZoneRule& operator=(const TimeZoneRule& right);
185
186 private:
187 UnicodeString fName; // time name
188 int32_t fRawOffset; // UTC offset of the standard time in milliseconds
189 int32_t fDSTSavings; // DST saving amount in milliseconds
190 };
191
198 class U_I18N_API InitialTimeZoneRule : public TimeZoneRule {
199 public:
209 InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
210
216 InitialTimeZoneRule(const InitialTimeZoneRule& source);
217
222 virtual ~InitialTimeZoneRule();
223
230 virtual InitialTimeZoneRule* clone(void) const;
231
237 InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right);
238
246 virtual UBool operator==(const TimeZoneRule& that) const;
247
255 virtual UBool operator!=(const TimeZoneRule& that) const;
256
269 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
270
279 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
280
292 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
293
305 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
306
321 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
322 UBool inclusive, UDate& result) const;
323
338 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
339 UBool inclusive, UDate& result) const;
340
341 public:
353 static UClassID U_EXPORT2 getStaticClassID(void);
354
366 virtual UClassID getDynamicClassID(void) const;
367 };
368
376 class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule {
377 public:
382 static const int32_t MAX_YEAR;
383
400 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
401 const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);
402
419 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
420 DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);
421
427 AnnualTimeZoneRule(const AnnualTimeZoneRule& source);
428
433 virtual ~AnnualTimeZoneRule();
434
441 virtual AnnualTimeZoneRule* clone(void) const;
442
448 AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right);
449
457 virtual UBool operator==(const TimeZoneRule& that) const;
458
466 virtual UBool operator!=(const TimeZoneRule& that) const;
467
474 const DateTimeRule* getRule(void) const;
475
482 int32_t getStartYear(void) const;
483
490 int32_t getEndYear(void) const;
491
504 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
505
514 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
515
527 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
528
540 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
541
556 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
557 UBool inclusive, UDate& result) const;
558
573 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
574 UBool inclusive, UDate& result) const;
575
576
577 private:
578 DateTimeRule* fDateTimeRule;
579 int32_t fStartYear;
580 int32_t fEndYear;
581
582 public:
594 static UClassID U_EXPORT2 getStaticClassID(void);
595
607 virtual UClassID getDynamicClassID(void) const;
608 };
609
616 class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule {
617 public:
635 TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
636 const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
637
643 TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source);
644
649 virtual ~TimeArrayTimeZoneRule();
650
657 virtual TimeArrayTimeZoneRule* clone(void) const;
658
664 TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right);
665
673 virtual UBool operator==(const TimeZoneRule& that) const;
674
682 virtual UBool operator!=(const TimeZoneRule& that) const;
683
692 DateTimeRule::TimeRuleType getTimeType(void) const;
693
703 UBool getStartTimeAt(int32_t index, UDate& result) const;
704
710 int32_t countStartTimes(void) const;
711
720 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
721
733 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
734
746 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
747
762 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
763 UBool inclusive, UDate& result) const;
764
779 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
780 UBool inclusive, UDate& result) const;
781
782
783 private:
784 enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };
785 UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);
786 UDate getUTC(UDate time, int32_t raw, int32_t dst) const;
787
788 DateTimeRule::TimeRuleType fTimeRuleType;
789 int32_t fNumStartTimes;
790 UDate* fStartTimes;
791 UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];
792
793 public:
805 static UClassID U_EXPORT2 getStaticClassID(void);
806
818 virtual UClassID getDynamicClassID(void) const;
819 };
820
821
822 U_NAMESPACE_END
823
824 #endif /* #if !UCONFIG_NO_FORMATTING */
825
826 #endif // TZRULE_H
827
828 //eof