00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SIMPLETZ_H
00024 #define SIMPLETZ_H
00025
00026 #include "unicode/utypes.h"
00027
00033 #if !UCONFIG_NO_FORMATTING
00034
00035 #include "unicode/timezone.h"
00036
00037 U_NAMESPACE_BEGIN
00038
00055 class U_I18N_API SimpleTimeZone: public TimeZone {
00056 public:
00057
00069 enum TimeMode {
00070 WALL_TIME = 0,
00071 STANDARD_TIME,
00072 UTC_TIME
00073 };
00074
00080 SimpleTimeZone(const SimpleTimeZone& source);
00081
00087 SimpleTimeZone& operator=(const SimpleTimeZone& right);
00088
00093 virtual ~SimpleTimeZone();
00094
00104 virtual UBool operator==(const TimeZone& that) const;
00105
00117 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID);
00118
00154 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00155 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00156 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00157 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00158 int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
00159 UErrorCode& status);
00197 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00198 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00199 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00200 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00201 int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
00202 int32_t savingsDST, UErrorCode& status);
00203
00245 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00246 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00247 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00248 TimeMode savingsStartTimeMode,
00249 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00250 int8_t savingsEndDayOfWeek, int32_t savingsEndTime, TimeMode savingsEndTimeMode,
00251 int32_t savingsDST, UErrorCode& status);
00252
00261 void setStartYear(int32_t year);
00262
00305 void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00306 int32_t time, UErrorCode& status);
00351 void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00352 int32_t time, TimeMode mode, UErrorCode& status);
00353
00365 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00366 UErrorCode& status);
00380 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00381 TimeMode mode, UErrorCode& status);
00382
00399 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00400 int32_t time, UBool after, UErrorCode& status);
00419 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00420 int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00421
00444 void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00445 int32_t time, UErrorCode& status);
00446
00471 void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00472 int32_t time, TimeMode mode, UErrorCode& status);
00473
00485 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, UErrorCode& status);
00486
00500 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time,
00501 TimeMode mode, UErrorCode& status);
00502
00519 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00520 int32_t time, UBool after, UErrorCode& status);
00521
00540 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00541 int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00542
00563 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00564 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;
00565
00581 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00582 uint8_t dayOfWeek, int32_t milliseconds,
00583 int32_t monthLength, UErrorCode& status) const;
00600 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00601 uint8_t dayOfWeek, int32_t milliseconds,
00602 int32_t monthLength, int32_t prevMonthLength,
00603 UErrorCode& status) const;
00604
00610 virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
00611 int32_t& dstOffset, UErrorCode& ec) const;
00612
00620 virtual int32_t getRawOffset(void) const;
00621
00629 virtual void setRawOffset(int32_t offsetMillis);
00630
00639 void setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status);
00640
00648 virtual int32_t getDSTSavings(void) const;
00649
00656 virtual UBool useDaylightTime(void) const;
00657
00672 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
00673
00680 UBool hasSameRules(const TimeZone& other) const;
00681
00689 virtual TimeZone* clone(void) const;
00690
00691 public:
00692
00703 virtual UClassID getDynamicClassID(void) const;
00704
00716 static UClassID U_EXPORT2 getStaticClassID(void);
00717
00718 private:
00722 enum EMode
00723 {
00724 DOM_MODE = 1,
00725 DOW_IN_MONTH_MODE,
00726 DOW_GE_DOM_MODE,
00727 DOW_LE_DOM_MODE
00728 };
00729
00730 SimpleTimeZone();
00731
00751 void construct(int32_t rawOffsetGMT,
00752 int8_t startMonth, int8_t startDay, int8_t startDayOfWeek,
00753 int32_t startTime, TimeMode startTimeMode,
00754 int8_t endMonth, int8_t endDay, int8_t endDayOfWeek,
00755 int32_t endTime, TimeMode endTimeMode,
00756 int32_t dstSavings, UErrorCode& status);
00757
00767 static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen,
00768 int8_t dayOfMonth,
00769 int8_t dayOfWeek, int32_t millis, int32_t millisDelta,
00770 EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek,
00771 int8_t ruleDay, int32_t ruleMillis);
00772
00788 void decodeRules(UErrorCode& status);
00789 void decodeStartRule(UErrorCode& status);
00790 void decodeEndRule(UErrorCode& status);
00791
00792 int8_t startMonth, startDay, startDayOfWeek;
00793 int32_t startTime;
00794 TimeMode startTimeMode, endTimeMode;
00795 int8_t endMonth, endDay, endDayOfWeek;
00796 int32_t endTime;
00797 int32_t startYear;
00798 int32_t rawOffset;
00799 UBool useDaylight;
00800 static const int8_t STATICMONTHLENGTH[12];
00801 EMode startMode, endMode;
00802
00807 int32_t dstSavings;
00808 };
00809
00810 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth,
00811 int32_t dayOfWeek,
00812 int32_t time, UErrorCode& status) {
00813 setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00814 }
00815
00816 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00817 int32_t time,
00818 UErrorCode& status) {
00819 setStartRule(month, dayOfMonth, time, WALL_TIME, status);
00820 }
00821
00822 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00823 int32_t dayOfWeek,
00824 int32_t time, UBool after, UErrorCode& status) {
00825 setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00826 }
00827
00828 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth,
00829 int32_t dayOfWeek,
00830 int32_t time, UErrorCode& status) {
00831 setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00832 }
00833
00834 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth,
00835 int32_t time, UErrorCode& status) {
00836 setEndRule(month, dayOfMonth, time, WALL_TIME, status);
00837 }
00838
00839 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00840 int32_t time, UBool after, UErrorCode& status) {
00841 setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00842 }
00843
00844 inline void
00845 SimpleTimeZone::getOffset(UDate date, UBool local, int32_t& rawOffsetRef,
00846 int32_t& dstOffsetRef, UErrorCode& ec) const {
00847 TimeZone::getOffset(date, local, rawOffsetRef, dstOffsetRef, ec);
00848 }
00849
00850 U_NAMESPACE_END
00851
00852 #endif
00853
00854 #endif // _SIMPLETZ