ICU 4.8.1.1
4.8.1.1
|
00001 /* 00002 ******************************************************************************* 00003 * Copyright (C) 2007-2008, International Business Machines Corporation and * 00004 * others. All Rights Reserved. * 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; // time name 00188 int32_t fRawOffset; // UTC offset of the standard time in milliseconds 00189 int32_t fDSTSavings; // DST saving amount in milliseconds 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 00692 DateTimeRule::TimeRuleType getTimeType(void) const; 00693 00703 UBool getStartTimeAt(int32_t index, UDate& result) const; 00704 00710 int32_t countStartTimes(void) const; 00711 00720 virtual UBool isEquivalentTo(const TimeZoneRule& that) const; 00721 00733 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const; 00734 00746 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const; 00747 00762 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 00763 UBool inclusive, UDate& result) const; 00764 00779 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 00780 UBool inclusive, UDate& result) const; 00781 00782 00783 private: 00784 enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 }; 00785 UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec); 00786 UDate getUTC(UDate time, int32_t raw, int32_t dst) const; 00787 00788 DateTimeRule::TimeRuleType fTimeRuleType; 00789 int32_t fNumStartTimes; 00790 UDate* fStartTimes; 00791 UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE]; 00792 00793 public: 00805 static UClassID U_EXPORT2 getStaticClassID(void); 00806 00818 virtual UClassID getDynamicClassID(void) const; 00819 }; 00820 00821 00822 U_NAMESPACE_END 00823 00824 #endif /* #if !UCONFIG_NO_FORMATTING */ 00825 00826 #endif // TZRULE_H 00827 00828 //eof