00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef TZRULE_H
00010 #define TZRULE_H
00011
00017 #include "unicode/utypes.h"
00018
00019 #if !UCONFIG_NO_FORMATTING
00020
00021 #include "unicode/uobject.h"
00022 #include "unicode/unistr.h"
00023 #include "unicode/dtrule.h"
00024
00025 U_NAMESPACE_BEGIN
00026
00034 class U_I18N_API TimeZoneRule : public UObject {
00035 public:
00040 virtual ~TimeZoneRule();
00041
00048 virtual TimeZoneRule* clone(void) const = 0;
00049
00057 virtual UBool operator==(const TimeZoneRule& that) const;
00058
00066 virtual UBool operator!=(const TimeZoneRule& that) const;
00067
00074 UnicodeString& getName(UnicodeString& name) const;
00075
00081 int32_t getRawOffset(void) const;
00082
00089 int32_t getDSTSavings(void) const;
00090
00099 virtual UBool isEquivalentTo(const TimeZoneRule& other) const;
00100
00112 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
00113
00125 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
00126
00141 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00142 UBool inclusive, UDate& result) const = 0;
00143
00158 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00159 UBool inclusive, UDate& result) const = 0;
00160
00161 protected:
00162
00172 TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
00173
00179 TimeZoneRule(const TimeZoneRule& source);
00180
00186 TimeZoneRule& operator=(const TimeZoneRule& right);
00187
00188 private:
00189 UnicodeString fName;
00190 int32_t fRawOffset;
00191 int32_t fDSTSavings;
00192 };
00193
00200 class U_I18N_API InitialTimeZoneRule : public TimeZoneRule {
00201 public:
00211 InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
00212
00218 InitialTimeZoneRule(const InitialTimeZoneRule& source);
00219
00224 virtual ~InitialTimeZoneRule();
00225
00232 virtual InitialTimeZoneRule* clone(void) const;
00233
00239 InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right);
00240
00248 virtual UBool operator==(const TimeZoneRule& that) const;
00249
00257 virtual UBool operator!=(const TimeZoneRule& that) const;
00258
00271 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00272
00281 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
00282
00294 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00295
00307 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00308
00323 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00324 UBool inclusive, UDate& result) const;
00325
00340 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00341 UBool inclusive, UDate& result) const;
00342
00343 public:
00355 static UClassID U_EXPORT2 getStaticClassID(void);
00356
00368 virtual UClassID getDynamicClassID(void) const;
00369 };
00370
00378 class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule {
00379 public:
00384 static const int32_t MAX_YEAR;
00385
00402 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
00403 const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);
00404
00421 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
00422 DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);
00423
00429 AnnualTimeZoneRule(const AnnualTimeZoneRule& source);
00430
00435 virtual ~AnnualTimeZoneRule();
00436
00443 virtual AnnualTimeZoneRule* clone(void) const;
00444
00450 AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right);
00451
00459 virtual UBool operator==(const TimeZoneRule& that) const;
00460
00468 virtual UBool operator!=(const TimeZoneRule& that) const;
00469
00476 const DateTimeRule* getRule(void) const;
00477
00484 int32_t getStartYear(void) const;
00485
00492 int32_t getEndYear(void) const;
00493
00506 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00507
00516 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
00517
00529 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00530
00542 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00543
00558 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00559 UBool inclusive, UDate& result) const;
00560
00575 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00576 UBool inclusive, UDate& result) const;
00577
00578
00579 private:
00580 DateTimeRule* fDateTimeRule;
00581 int32_t fStartYear;
00582 int32_t fEndYear;
00583
00584 public:
00596 static UClassID U_EXPORT2 getStaticClassID(void);
00597
00609 virtual UClassID getDynamicClassID(void) const;
00610 };
00611
00618 class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule {
00619 public:
00637 TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
00638 const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
00639
00645 TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source);
00646
00651 virtual ~TimeArrayTimeZoneRule();
00652
00659 virtual TimeArrayTimeZoneRule* clone(void) const;
00660
00666 TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right);
00667
00675 virtual UBool operator==(const TimeZoneRule& that) const;
00676
00684 virtual UBool operator!=(const TimeZoneRule& that) const;
00685
00694 DateTimeRule::TimeRuleType getTimeType(void) const;
00695
00705 UBool getStartTimeAt(int32_t index, UDate& result) const;
00706
00712 int32_t countStartTimes(void) const;
00713
00722 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
00723
00735 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00736
00748 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00749
00764 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00765 UBool inclusive, UDate& result) const;
00766
00781 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00782 UBool inclusive, UDate& result) const;
00783
00784
00785 private:
00786 enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };
00787 UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);
00788 UDate getUTC(UDate time, int32_t raw, int32_t dst) const;
00789
00790 DateTimeRule::TimeRuleType fTimeRuleType;
00791 int32_t fNumStartTimes;
00792 UDate* fStartTimes;
00793 UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];
00794
00795 public:
00807 static UClassID U_EXPORT2 getStaticClassID(void);
00808
00820 virtual UClassID getDynamicClassID(void) const;
00821 };
00822
00823
00824 U_NAMESPACE_END
00825
00826 #endif
00827
00828 #endif // TZRULE_H
00829
00830