|
ICU 73.2
73.2
|
00001 // © 2016 and later: Unicode, Inc. and others. 00002 // License & terms of use: http://www.unicode.org/copyright.html 00003 /* 00004 ******************************************************************************* 00005 * Copyright (C) 2007-2008, International Business Machines Corporation and * 00006 * others. All Rights Reserved. * 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 bool operator==(const TimeZoneRule& that) const; 00060 00068 virtual bool 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; // time name 00192 int32_t fRawOffset; // UTC offset of the standard time in milliseconds 00193 int32_t fDSTSavings; // DST saving amount in milliseconds 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 override; 00235 00241 InitialTimeZoneRule& operator=(const InitialTimeZoneRule& right); 00242 00250 virtual bool operator==(const TimeZoneRule& that) const override; 00251 00259 virtual bool operator!=(const TimeZoneRule& that) const override; 00260 00269 virtual UBool isEquivalentTo(const TimeZoneRule& that) const override; 00270 00282 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 00283 00295 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 00296 00311 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 00312 UBool inclusive, UDate& result) const override; 00313 00328 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 00329 UBool inclusive, UDate& result) const override; 00330 00331 public: 00343 static UClassID U_EXPORT2 getStaticClassID(void); 00344 00356 virtual UClassID getDynamicClassID(void) const override; 00357 }; 00358 00366 class U_I18N_API AnnualTimeZoneRule : public TimeZoneRule { 00367 public: 00372 static const int32_t MAX_YEAR; 00373 00390 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings, 00391 const DateTimeRule& dateTimeRule, int32_t startYear, int32_t endYear); 00392 00409 AnnualTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings, 00410 DateTimeRule* dateTimeRule, int32_t startYear, int32_t endYear); 00411 00417 AnnualTimeZoneRule(const AnnualTimeZoneRule& source); 00418 00423 virtual ~AnnualTimeZoneRule(); 00424 00431 virtual AnnualTimeZoneRule* clone() const override; 00432 00438 AnnualTimeZoneRule& operator=(const AnnualTimeZoneRule& right); 00439 00447 virtual bool operator==(const TimeZoneRule& that) const override; 00448 00456 virtual bool operator!=(const TimeZoneRule& that) const override; 00457 00464 const DateTimeRule* getRule(void) const; 00465 00472 int32_t getStartYear(void) const; 00473 00480 int32_t getEndYear(void) const; 00481 00494 UBool getStartInYear(int32_t year, int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const; 00495 00504 virtual UBool isEquivalentTo(const TimeZoneRule& that) const override; 00505 00517 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 00518 00530 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 00531 00546 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 00547 UBool inclusive, UDate& result) const override; 00548 00563 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 00564 UBool inclusive, UDate& result) const override; 00565 00566 00567 private: 00568 DateTimeRule* fDateTimeRule; 00569 int32_t fStartYear; 00570 int32_t fEndYear; 00571 00572 public: 00584 static UClassID U_EXPORT2 getStaticClassID(void); 00585 00597 virtual UClassID getDynamicClassID(void) const override; 00598 }; 00599 00606 class U_I18N_API TimeArrayTimeZoneRule : public TimeZoneRule { 00607 public: 00625 TimeArrayTimeZoneRule(const UnicodeString& name, int32_t rawOffset, int32_t dstSavings, 00626 const UDate* startTimes, int32_t numStartTimes, DateTimeRule::TimeRuleType timeRuleType); 00627 00633 TimeArrayTimeZoneRule(const TimeArrayTimeZoneRule& source); 00634 00639 virtual ~TimeArrayTimeZoneRule(); 00640 00647 virtual TimeArrayTimeZoneRule* clone() const override; 00648 00654 TimeArrayTimeZoneRule& operator=(const TimeArrayTimeZoneRule& right); 00655 00663 virtual bool operator==(const TimeZoneRule& that) const override; 00664 00672 virtual bool operator!=(const TimeZoneRule& that) const override; 00673 00682 DateTimeRule::TimeRuleType getTimeType(void) const; 00683 00693 UBool getStartTimeAt(int32_t index, UDate& result) const; 00694 00700 int32_t countStartTimes(void) const; 00701 00710 virtual UBool isEquivalentTo(const TimeZoneRule& that) const override; 00711 00723 virtual UBool getFirstStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 00724 00736 virtual UBool getFinalStart(int32_t prevRawOffset, int32_t prevDSTSavings, UDate& result) const override; 00737 00752 virtual UBool getNextStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 00753 UBool inclusive, UDate& result) const override; 00754 00769 virtual UBool getPreviousStart(UDate base, int32_t prevRawOffset, int32_t prevDSTSavings, 00770 UBool inclusive, UDate& result) const override; 00771 00772 00773 private: 00774 enum { TIMEARRAY_STACK_BUFFER_SIZE = 32 }; 00775 UBool initStartTimes(const UDate source[], int32_t size, UErrorCode& ec); 00776 UDate getUTC(UDate time, int32_t raw, int32_t dst) const; 00777 00778 DateTimeRule::TimeRuleType fTimeRuleType; 00779 int32_t fNumStartTimes; 00780 UDate* fStartTimes; 00781 UDate fLocalStartTimes[TIMEARRAY_STACK_BUFFER_SIZE]; 00782 00783 public: 00795 static UClassID U_EXPORT2 getStaticClassID(void); 00796 00808 virtual UClassID getDynamicClassID(void) const override; 00809 }; 00810 00811 00812 U_NAMESPACE_END 00813 00814 #endif /* #if !UCONFIG_NO_FORMATTING */ 00815 00816 #endif /* U_SHOW_CPLUSPLUS_API */ 00817 00818 #endif // TZRULE_H 00819 00820 //eof
1.7.6.1