00001
00002
00003
00004
00005
00006
00007 #ifndef TZRULE_H
00008 #define TZRULE_H
00009
00015 #include "unicode/utypes.h"
00016
00017 #if !UCONFIG_NO_FORMATTING
00018
00019 #include "unicode/uobject.h"
00020 #include "unicode/unistr.h"
00021 #include "unicode/dtrule.h"
00022
00023 U_NAMESPACE_BEGIN
00024
00032 class U_I18N_API TimeZoneRule : public UObject {
00033 public:
00038 virtual ~TimeZoneRule();
00039
00046 virtual TimeZoneRule* clone(void) const = 0;
00047
00055 virtual UBool operator==(const TimeZoneRule& that) const;
00056
00064 virtual UBool operator!=(const TimeZoneRule& that) const;
00065
00072 UnicodeString& getName(UnicodeString& name) const;
00073
00079 int32_t getRawOffset(void) const;
00080
00087 int32_t getDSTSavings(void) const;
00088
00097 virtual UBool isEquivalentTo(const TimeZoneRule& other) const;
00098
00110 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
00111
00123 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
00124
00139 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00140 UBool inclusive, UDate& result) const = 0;
00141
00156 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00157 UBool inclusive, UDate& result) const = 0;
00158
00159 protected:
00160
00170 TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
00171
00177 TimeZoneRule(const TimeZoneRule& source);
00178
00184 TimeZoneRule& operator=(const TimeZoneRule& right);
00185
00186 private:
00187 UnicodeString fName;
00188 int32_t fRawOffset;
00189 int32_t fDSTSavings;
00190 };
00191
00198 class U_I18N_API InitialTimeZoneRule : public TimeZoneRule {
00199 public:
00209 InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
00210
00216 InitialTimeZoneRule(const InitialTimeZoneRule& source);
00217
00222 virtual ~InitialTimeZoneRule();
00223
00230 virtual InitialTimeZoneRule* clone(void) const;
00231
00237 InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right);
00238
00246 virtual UBool operator==(const TimeZoneRule& that) const;
00247
00255 virtual UBool operator!=(const TimeZoneRule& that) const;
00256
00269 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00270
00279 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
00280
00292 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00293
00305 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00306
00321 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00322 UBool inclusive, UDate& result) const;
00323
00338 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00339 UBool inclusive, UDate& result) const;
00340
00341 public:
00353 static UClassID U_EXPORT2 getStaticClassID(void);
00354
00366 virtual UClassID getDynamicClassID(void) const;
00367 };
00368
00376 class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule {
00377 public:
00382 static const int32_t MAX_YEAR;
00383
00400 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
00401 const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);
00402
00419 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
00420 DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);
00421
00427 AnnualTimeZoneRule(const AnnualTimeZoneRule& source);
00428
00433 virtual ~AnnualTimeZoneRule();
00434
00441 virtual AnnualTimeZoneRule* clone(void) const;
00442
00448 AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right);
00449
00457 virtual UBool operator==(const TimeZoneRule& that) const;
00458
00466 virtual UBool operator!=(const TimeZoneRule& that) const;
00467
00474 const DateTimeRule* getRule(void) const;
00475
00482 int32_t getStartYear(void) const;
00483
00490 int32_t getEndYear(void) const;
00491
00504 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00505
00514 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
00515
00527 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00528
00540 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00541
00556 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00557 UBool inclusive, UDate& result) const;
00558
00573 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00574 UBool inclusive, UDate& result) const;
00575
00576
00577 private:
00578 DateTimeRule* fDateTimeRule;
00579 int32_t fStartYear;
00580 int32_t fEndYear;
00581
00582 public:
00594 static UClassID U_EXPORT2 getStaticClassID(void);
00595
00607 virtual UClassID getDynamicClassID(void) const;
00608 };
00609
00616 class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule {
00617 public:
00635 TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
00636 const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
00637
00643 TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source);
00644
00649 virtual ~TimeArrayTimeZoneRule();
00650
00657 virtual TimeArrayTimeZoneRule* clone(void) const;
00658
00664 TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right);
00665
00673 virtual UBool operator==(const TimeZoneRule& that) const;
00674
00682 virtual UBool operator!=(const TimeZoneRule& that) const;
00683
00691 DateTimeRule::TimeRuleType getTimeType(void) const;
00692
00701 UBool getStartTimeAt(int32_t index, UDate& result) const;
00702
00707 int32_t countStartTimes(void) const;
00708
00717 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
00718
00730 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00731
00743 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00744
00759 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00760 UBool inclusive, UDate& result) const;
00761
00776 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00777 UBool inclusive, UDate& result) const;
00778
00779
00780 private:
00781 enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };
00782 UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);
00783 UDate getUTC(UDate time, int32_t raw, int32_t dst) const;
00784
00785 DateTimeRule::TimeRuleType fTimeRuleType;
00786 int32_t fNumStartTimes;
00787 UDate* fStartTimes;
00788 UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];
00789
00790 public:
00802 static UClassID U_EXPORT2 getStaticClassID(void);
00803
00815 virtual UClassID getDynamicClassID(void) const;
00816 };
00817
00818
00819 U_NAMESPACE_END
00820
00821 #endif
00822
00823 #endif // TZRULE_H
00824
00825