|
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) 1997-2013, International Business Machines * 00006 * Corporation and others. All Rights Reserved. * 00007 ******************************************************************************** 00008 * 00009 * File SIMPLETZ.H 00010 * 00011 * Modification History: 00012 * 00013 * Date Name Description 00014 * 04/21/97 aliu Overhauled header. 00015 * 08/10/98 stephen JDK 1.2 sync 00016 * Added setStartRule() / setEndRule() overloads 00017 * Added hasSameRules() 00018 * 09/02/98 stephen Added getOffset(monthLen) 00019 * Changed getOffset() to take UErrorCode 00020 * 07/09/99 stephen Removed millisPerHour (unused, for HP compiler) 00021 * 12/02/99 aliu Added TimeMode and constructor and setStart/EndRule 00022 * methods that take TimeMode. Added to docs. 00023 ******************************************************************************** 00024 */ 00025 00026 #ifndef SIMPLETZ_H 00027 #define SIMPLETZ_H 00028 00029 #include "unicode/utypes.h" 00030 00031 #if U_SHOW_CPLUSPLUS_API 00032 00038 #if !UCONFIG_NO_FORMATTING 00039 00040 #include "unicode/basictz.h" 00041 00042 U_NAMESPACE_BEGIN 00043 00044 // forward declaration 00045 class InitialTimeZoneRule; 00046 class TimeZoneTransition; 00047 class AnnualTimeZoneRule; 00048 00065 class U_I18N_API SimpleTimeZone: public BasicTimeZone { 00066 public: 00067 00079 enum TimeMode { 00080 WALL_TIME = 0, 00081 STANDARD_TIME, 00082 UTC_TIME 00083 }; 00084 00090 SimpleTimeZone(const SimpleTimeZone& source); 00091 00097 SimpleTimeZone& operator=(const SimpleTimeZone& right); 00098 00103 virtual ~SimpleTimeZone(); 00104 00114 virtual bool operator==(const TimeZone& that) const override; 00115 00127 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID); 00128 00164 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID, 00165 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth, 00166 int8_t savingsStartDayOfWeek, int32_t savingsStartTime, 00167 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth, 00168 int8_t savingsEndDayOfWeek, int32_t savingsEndTime, 00169 UErrorCode& status); 00207 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID, 00208 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth, 00209 int8_t savingsStartDayOfWeek, int32_t savingsStartTime, 00210 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth, 00211 int8_t savingsEndDayOfWeek, int32_t savingsEndTime, 00212 int32_t savingsDST, UErrorCode& status); 00213 00255 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID, 00256 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth, 00257 int8_t savingsStartDayOfWeek, int32_t savingsStartTime, 00258 TimeMode savingsStartTimeMode, 00259 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth, 00260 int8_t savingsEndDayOfWeek, int32_t savingsEndTime, TimeMode savingsEndTimeMode, 00261 int32_t savingsDST, UErrorCode& status); 00262 00271 void setStartYear(int32_t year); 00272 00315 void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, 00316 int32_t time, UErrorCode& status); 00361 void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, 00362 int32_t time, TimeMode mode, UErrorCode& status); 00363 00375 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time, 00376 UErrorCode& status); 00390 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time, 00391 TimeMode mode, UErrorCode& status); 00392 00409 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 00410 int32_t time, UBool after, UErrorCode& status); 00429 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 00430 int32_t time, TimeMode mode, UBool after, UErrorCode& status); 00431 00454 void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, 00455 int32_t time, UErrorCode& status); 00456 00481 void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, 00482 int32_t time, TimeMode mode, UErrorCode& status); 00483 00495 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, UErrorCode& status); 00496 00510 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, 00511 TimeMode mode, UErrorCode& status); 00512 00529 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 00530 int32_t time, UBool after, UErrorCode& status); 00531 00550 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 00551 int32_t time, TimeMode mode, UBool after, UErrorCode& status); 00552 00573 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 00574 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const override; 00575 00591 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 00592 uint8_t dayOfWeek, int32_t milliseconds, 00593 int32_t monthLength, UErrorCode& status) const override; 00610 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 00611 uint8_t dayOfWeek, int32_t milliseconds, 00612 int32_t monthLength, int32_t prevMonthLength, 00613 UErrorCode& status) const; 00614 00620 virtual void getOffset(UDate date, UBool local, int32_t& rawOffset, 00621 int32_t& dstOffset, UErrorCode& ec) const override; 00622 00627 virtual void getOffsetFromLocal( 00628 UDate date, UTimeZoneLocalOption nonExistingTimeOpt, 00629 UTimeZoneLocalOption duplicatedTimeOpt, 00630 int32_t& rawOffset, int32_t& dstOffset, UErrorCode& status) const override; 00631 00639 virtual int32_t getRawOffset(void) const override; 00640 00648 virtual void setRawOffset(int32_t offsetMillis) override; 00649 00659 void setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status); 00660 00669 virtual int32_t getDSTSavings(void) const override; 00670 00677 virtual UBool useDaylightTime(void) const override; 00678 00679 #ifndef U_FORCE_HIDE_DEPRECATED_API 00680 00694 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const override; 00695 #endif // U_FORCE_HIDE_DEPRECATED_API 00696 00703 UBool hasSameRules(const TimeZone& other) const override; 00704 00712 virtual SimpleTimeZone* clone() const override; 00713 00722 virtual UBool getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const override; 00723 00732 virtual UBool getPreviousTransition(UDate base, UBool inclusive, TimeZoneTransition& result) const override; 00733 00742 virtual int32_t countTransitionRules(UErrorCode& status) const override; 00743 00760 virtual void getTimeZoneRules(const InitialTimeZoneRule*& initial, 00761 const TimeZoneRule* trsrules[], int32_t& trscount, UErrorCode& status) const override; 00762 00763 00764 public: 00765 00776 virtual UClassID getDynamicClassID(void) const override; 00777 00789 static UClassID U_EXPORT2 getStaticClassID(void); 00790 00791 private: 00795 enum EMode 00796 { 00797 DOM_MODE = 1, 00798 DOW_IN_MONTH_MODE, 00799 DOW_GE_DOM_MODE, 00800 DOW_LE_DOM_MODE 00801 }; 00802 00803 SimpleTimeZone() = delete; // default constructor not implemented 00804 00824 void construct(int32_t rawOffsetGMT, 00825 int8_t startMonth, int8_t startDay, int8_t startDayOfWeek, 00826 int32_t startTime, TimeMode startTimeMode, 00827 int8_t endMonth, int8_t endDay, int8_t endDayOfWeek, 00828 int32_t endTime, TimeMode endTimeMode, 00829 int32_t dstSavings, UErrorCode& status); 00830 00840 static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen, 00841 int8_t dayOfMonth, 00842 int8_t dayOfWeek, int32_t millis, int32_t millisDelta, 00843 EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek, 00844 int8_t ruleDay, int32_t ruleMillis); 00845 00861 void decodeRules(UErrorCode& status); 00862 void decodeStartRule(UErrorCode& status); 00863 void decodeEndRule(UErrorCode& status); 00864 00865 int8_t startMonth, startDay, startDayOfWeek; // the month, day, DOW, and time DST starts 00866 int32_t startTime; 00867 TimeMode startTimeMode, endTimeMode; // Mode for startTime, endTime; see TimeMode 00868 int8_t endMonth, endDay, endDayOfWeek; // the month, day, DOW, and time DST ends 00869 int32_t endTime; 00870 int32_t startYear; // the year these DST rules took effect 00871 int32_t rawOffset; // the TimeZone's raw GMT offset 00872 UBool useDaylight; // flag indicating whether this TimeZone uses DST 00873 static const int8_t STATICMONTHLENGTH[12]; // lengths of the months 00874 EMode startMode, endMode; // flags indicating what kind of rules the DST rules are 00875 00880 int32_t dstSavings; 00881 00882 /* Private for BasicTimeZone implementation */ 00883 void checkTransitionRules(UErrorCode& status) const; 00884 void initTransitionRules(UErrorCode& status); 00885 void clearTransitionRules(void); 00886 void deleteTransitionRules(void); 00887 UBool transitionRulesInitialized; 00888 InitialTimeZoneRule* initialRule; 00889 TimeZoneTransition* firstTransition; 00890 AnnualTimeZoneRule* stdRule; 00891 AnnualTimeZoneRule* dstRule; 00892 }; 00893 00894 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth, 00895 int32_t dayOfWeek, 00896 int32_t time, UErrorCode& status) { 00897 setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status); 00898 } 00899 00900 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth, 00901 int32_t time, 00902 UErrorCode& status) { 00903 setStartRule(month, dayOfMonth, time, WALL_TIME, status); 00904 } 00905 00906 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth, 00907 int32_t dayOfWeek, 00908 int32_t time, UBool after, UErrorCode& status) { 00909 setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status); 00910 } 00911 00912 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth, 00913 int32_t dayOfWeek, 00914 int32_t time, UErrorCode& status) { 00915 setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status); 00916 } 00917 00918 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, 00919 int32_t time, UErrorCode& status) { 00920 setEndRule(month, dayOfMonth, time, WALL_TIME, status); 00921 } 00922 00923 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 00924 int32_t time, UBool after, UErrorCode& status) { 00925 setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status); 00926 } 00927 00928 inline void 00929 SimpleTimeZone::getOffset(UDate date, UBool local, int32_t& rawOffsetRef, 00930 int32_t& dstOffsetRef, UErrorCode& ec) const { 00931 TimeZone::getOffset(date, local, rawOffsetRef, dstOffsetRef, ec); 00932 } 00933 00934 U_NAMESPACE_END 00935 00936 #endif /* #if !UCONFIG_NO_FORMATTING */ 00937 00938 #endif /* U_SHOW_CPLUSPLUS_API */ 00939 00940 #endif // _SIMPLETZ
1.7.6.1