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
00028 #if !UCONFIG_NO_FORMATTING
00029
00030 #include "unicode/timezone.h"
00031
00032 struct StandardZone;
00033 struct DSTZone;
00034
00035 U_NAMESPACE_BEGIN
00036
00037 class TimeZone;
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
00160 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00161 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00162 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00163 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00164 int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
00165 UErrorCode& status);
00203 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00204 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00205 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00206 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00207 int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
00208 int32_t savingsDST, UErrorCode& status);
00248 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00249 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00250 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00251 TimeMode savingsStartTimeMode,
00252 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00253 int8_t savingsEndDayOfWeek, int32_t savingsEndTime, TimeMode savingsEndTimeMode,
00254 int32_t savingsDST, UErrorCode& status);
00255
00264 void setStartYear(int32_t year);
00265
00306 void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00307 int32_t time, UErrorCode& status);
00350 void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00351 int32_t time, TimeMode mode, UErrorCode& status);
00352
00364 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00365 UErrorCode& status);
00379 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00380 TimeMode mode, UErrorCode& status);
00381
00400 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00401 int32_t time, UBool after, UErrorCode& status);
00420 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00421 int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00422
00445 void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00446 int32_t time, UErrorCode& status);
00447
00472 void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00473 int32_t time, TimeMode mode, UErrorCode& status);
00474
00486 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, UErrorCode& status);
00487
00501 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time,
00502 TimeMode mode, UErrorCode& status);
00503
00520 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00521 int32_t time, UBool after, UErrorCode& status);
00522
00541 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00542 int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00543
00564 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00565 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;
00566 #ifdef ICU_TIMEZONE_USE_DEPRECATES
00570 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00571 uint8_t dayOfWeek, int32_t millis) const;
00572 #endif
00573
00589 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00590 uint8_t dayOfWeek, int32_t milliseconds,
00591 int32_t monthLength, UErrorCode& status) const;
00608 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00609 uint8_t dayOfWeek, int32_t milliseconds,
00610 int32_t monthLength, int32_t prevMonthLength,
00611 UErrorCode& status) 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
00647 int32_t getDSTSavings(void) const;
00648
00655 virtual UBool useDaylightTime(void) const;
00656
00671 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
00672
00679 UBool hasSameRules(const TimeZone& other) const;
00680
00688 virtual TimeZone* clone(void) const;
00689
00690 public:
00691
00702 virtual UClassID getDynamicClassID(void) const { return (UClassID)&fgClassID; }
00703
00715 static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00716
00717 private:
00721 enum EMode
00722 {
00723 DOM_MODE = 1,
00724 DOW_IN_MONTH_MODE,
00725 DOW_GE_DOM_MODE,
00726 DOW_LE_DOM_MODE
00727 };
00728
00729 friend class TimeZone;
00730
00734 SimpleTimeZone(const StandardZone& stdZone, const UnicodeString& id);
00735 SimpleTimeZone(const DSTZone& dstZone, const UnicodeString& id);
00736
00756 void construct(int32_t rawOffsetGMT,
00757 int8_t startMonth, int8_t startDay, int8_t startDayOfWeek,
00758 int32_t startTime, TimeMode startTimeMode,
00759 int8_t endMonth, int8_t endDay, int8_t endDayOfWeek,
00760 int32_t endTime, TimeMode endTimeMode,
00761 int32_t dstSavings, UErrorCode& status);
00762
00772 static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen,
00773 int8_t dayOfMonth,
00774 int8_t dayOfWeek, int32_t millis, int32_t millisDelta,
00775 EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek,
00776 int8_t ruleDay, int32_t ruleMillis);
00777
00793 void decodeRules(UErrorCode& status);
00794 void decodeStartRule(UErrorCode& status);
00795 void decodeEndRule(UErrorCode& status);
00796
00797 static const char fgClassID;
00798
00799 int8_t startMonth, startDay, startDayOfWeek;
00800 int32_t startTime;
00801 TimeMode startTimeMode, endTimeMode;
00802 int8_t endMonth, endDay, endDayOfWeek;
00803 int32_t endTime;
00804 int32_t startYear;
00805 int32_t rawOffset;
00806 UBool useDaylight;
00807 static const int8_t staticMonthLength[12];
00808 EMode startMode, endMode;
00809
00814 int32_t dstSavings;
00815 };
00816
00817 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth,
00818 int32_t dayOfWeek,
00819 int32_t time, UErrorCode& status) {
00820 setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00821 }
00822
00823 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00824 int32_t time,
00825 UErrorCode& status) {
00826 setStartRule(month, dayOfMonth, time, WALL_TIME, status);
00827 }
00828
00829 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00830 int32_t dayOfWeek,
00831 int32_t time, UBool after, UErrorCode& status) {
00832 setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00833 }
00834
00835 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth,
00836 int32_t dayOfWeek,
00837 int32_t time, UErrorCode& status) {
00838 setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00839 }
00840
00841 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth,
00842 int32_t time, UErrorCode& status) {
00843 setEndRule(month, dayOfMonth, time, WALL_TIME, status);
00844 }
00845
00846 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00847 int32_t time, UBool after, UErrorCode& status) {
00848 setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00849 }
00850
00851 U_NAMESPACE_END
00852
00853 #endif
00854
00855 #endif // _SIMPLETZ