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 U_SHOW_CPLUSPLUS_API
00020
00021 #if !UCONFIG_NO_FORMATTING
00022
00023 #include "unicode/uobject.h"
00024 #include "unicode/unistr.h"
00025 #include "unicode/dtrule.h"
00026
00027 U_NAMESPACE_BEGIN
00028
00036 class U_I18N_API TimeZoneRule : public UObject {
00037 public:
00042 virtual ~TimeZoneRule();
00043
00050 virtual TimeZoneRule* clone() const = 0;
00051
00059 virtual UBool operator==(const TimeZoneRule& that) const;
00060
00068 virtual UBool operator!=(const TimeZoneRule& that) const;
00069
00076 UnicodeString& getName(UnicodeString& name) const;
00077
00083 int32_t getRawOffset(void) const;
00084
00091 int32_t getDSTSavings(void) const;
00092
00101 virtual UBool isEquivalentTo(const TimeZoneRule& other) const;
00102
00114 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
00115
00127 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const = 0;
00128
00143 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00144 UBool inclusive, UDate& result) const = 0;
00145
00160 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00161 UBool inclusive, UDate& result) const = 0;
00162
00163 protected:
00164
00174 TimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
00175
00181 TimeZoneRule(const TimeZoneRule& source);
00182
00188 TimeZoneRule& operator=(const TimeZoneRule& right);
00189
00190 private:
00191 UnicodeString fName;
00192 int32_t fRawOffset;
00193 int32_t fDSTSavings;
00194 };
00195
00202 class U_I18N_API InitialTimeZoneRule : public TimeZoneRule {
00203 public:
00213 InitialTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings);
00214
00220 InitialTimeZoneRule(const InitialTimeZoneRule& source);
00221
00226 virtual ~InitialTimeZoneRule();
00227
00234 virtual InitialTimeZoneRule* clone() const;
00235
00241 InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right);
00242
00250 virtual UBool operator==(const TimeZoneRule& that) const;
00251
00259 virtual UBool operator!=(const TimeZoneRule& that) const;
00260
00273 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00274
00283 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
00284
00296 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00297
00309 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00310
00325 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00326 UBool inclusive, UDate& result) const;
00327
00342 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00343 UBool inclusive, UDate& result) const;
00344
00345 public:
00357 static UClassID U_EXPORT2 getStaticClassID(void);
00358
00370 virtual UClassID getDynamicClassID(void) const;
00371 };
00372
00380 class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule {
00381 public:
00386 static const int32_t MAX_YEAR;
00387
00404 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
00405 const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear);
00406
00423 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
00424 DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear);
00425
00431 AnnualTimeZoneRule(const AnnualTimeZoneRule& source);
00432
00437 virtual ~AnnualTimeZoneRule();
00438
00445 virtual AnnualTimeZoneRule* clone() const;
00446
00452 AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right);
00453
00461 virtual UBool operator==(const TimeZoneRule& that) const;
00462
00470 virtual UBool operator!=(const TimeZoneRule& that) const;
00471
00478 const DateTimeRule* getRule(void) const;
00479
00486 int32_t getStartYear(void) const;
00487
00494 int32_t getEndYear(void) const;
00495
00508 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00509
00518 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
00519
00531 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00532
00544 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00545
00560 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00561 UBool inclusive, UDate& result) const;
00562
00577 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00578 UBool inclusive, UDate& result) const;
00579
00580
00581 private:
00582 DateTimeRule* fDateTimeRule;
00583 int32_t fStartYear;
00584 int32_t fEndYear;
00585
00586 public:
00598 static UClassID U_EXPORT2 getStaticClassID(void);
00599
00611 virtual UClassID getDynamicClassID(void) const;
00612 };
00613
00620 class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule {
00621 public:
00639 TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings,
00640 const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType);
00641
00647 TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source);
00648
00653 virtual ~TimeArrayTimeZoneRule();
00654
00661 virtual TimeArrayTimeZoneRule* clone() const;
00662
00668 TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right);
00669
00677 virtual UBool operator==(const TimeZoneRule& that) const;
00678
00686 virtual UBool operator!=(const TimeZoneRule& that) const;
00687
00696 DateTimeRule::TimeRuleType getTimeType(void) const;
00697
00707 UBool getStartTimeAt(int32_t index, UDate& result) const;
00708
00714 int32_t countStartTimes(void) const;
00715
00724 virtual UBool isEquivalentTo(const TimeZoneRule& that) const;
00725
00737 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00738
00750 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const;
00751
00766 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00767 UBool inclusive, UDate& result) const;
00768
00783 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings,
00784 UBool inclusive, UDate& result) const;
00785
00786
00787 private:
00788 enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 };
00789 UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec);
00790 UDate getUTC(UDate time, int32_t raw, int32_t dst) const;
00791
00792 DateTimeRule::TimeRuleType fTimeRuleType;
00793 int32_t fNumStartTimes;
00794 UDate* fStartTimes;
00795 UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE];
00796
00797 public:
00809 static UClassID U_EXPORT2 getStaticClassID(void);
00810
00822 virtual UClassID getDynamicClassID(void) const;
00823 };
00824
00825
00826 U_NAMESPACE_END
00827
00828 #endif
00829
00830 #endif
00831
00832 #endif // TZRULE_H
00833
00834