simpletz.h

Go to the documentation of this file.
00001 /* 00002 * Copyright (C) {1997-2004}, International Business Machines Corporation and others. All Rights Reserved. 00003 * * 00004 ******************************************************************************** 00005 * 00006 * File SIMPLETZ.H 00007 * 00008 * Modification History: 00009 * 00010 * Date Name Description 00011 * 04/21/97 aliu Overhauled header. 00012 * 08/10/98 stephen JDK 1.2 sync 00013 * Added setStartRule() / setEndRule() overloads 00014 * Added hasSameRules() 00015 * 09/02/98 stephen Added getOffset(monthLen) 00016 * Changed getOffset() to take UErrorCode 00017 * 07/09/99 stephen Removed millisPerHour (unused, for HP compiler) 00018 * 12/02/99 aliu Added TimeMode and constructor and setStart/EndRule 00019 * methods that take TimeMode. Added to docs. 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 U_NAMESPACE_BEGIN 00033 00050 class U_I18N_API SimpleTimeZone: public TimeZone { 00051 public: 00052 00064 enum TimeMode { 00065 WALL_TIME = 0, 00066 STANDARD_TIME, 00067 UTC_TIME 00068 }; 00069 00075 SimpleTimeZone(const SimpleTimeZone& source); 00076 00082 SimpleTimeZone& operator=(const SimpleTimeZone& right); 00083 00088 virtual ~SimpleTimeZone(); 00089 00099 virtual UBool operator==(const TimeZone& that) const; 00100 00112 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID); 00113 00149 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID, 00150 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth, 00151 int8_t savingsStartDayOfWeek, int32_t savingsStartTime, 00152 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth, 00153 int8_t savingsEndDayOfWeek, int32_t savingsEndTime, 00154 UErrorCode& status); 00192 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID, 00193 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth, 00194 int8_t savingsStartDayOfWeek, int32_t savingsStartTime, 00195 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth, 00196 int8_t savingsEndDayOfWeek, int32_t savingsEndTime, 00197 int32_t savingsDST, UErrorCode& status); 00198 00240 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID, 00241 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth, 00242 int8_t savingsStartDayOfWeek, int32_t savingsStartTime, 00243 TimeMode savingsStartTimeMode, 00244 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth, 00245 int8_t savingsEndDayOfWeek, int32_t savingsEndTime, TimeMode savingsEndTimeMode, 00246 int32_t savingsDST, UErrorCode& status); 00247 00256 void setStartYear(int32_t year); 00257 00300 void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, 00301 int32_t time, UErrorCode& status); 00346 void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, 00347 int32_t time, TimeMode mode, UErrorCode& status); 00348 00360 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time, 00361 UErrorCode& status); 00375 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time, 00376 TimeMode mode, UErrorCode& status); 00377 00394 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 00395 int32_t time, UBool after, UErrorCode& status); 00414 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 00415 int32_t time, TimeMode mode, UBool after, UErrorCode& status); 00416 00439 void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, 00440 int32_t time, UErrorCode& status); 00441 00466 void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, 00467 int32_t time, TimeMode mode, UErrorCode& status); 00468 00480 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, UErrorCode& status); 00481 00495 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, 00496 TimeMode mode, UErrorCode& status); 00497 00514 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 00515 int32_t time, UBool after, UErrorCode& status); 00516 00535 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 00536 int32_t time, TimeMode mode, UBool after, UErrorCode& status); 00537 00558 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 00559 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const; 00560 00576 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 00577 uint8_t dayOfWeek, int32_t milliseconds, 00578 int32_t monthLength, UErrorCode& status) const; 00595 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 00596 uint8_t dayOfWeek, int32_t milliseconds, 00597 int32_t monthLength, int32_t prevMonthLength, 00598 UErrorCode& status) const; 00599 00605 virtual void getOffset(UDate date, UBool local, int32_t& rawOffset, 00606 int32_t& dstOffset, UErrorCode& ec) const; 00607 00615 virtual int32_t getRawOffset(void) const; 00616 00624 virtual void setRawOffset(int32_t offsetMillis); 00625 00634 void setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status); 00635 00643 int32_t getDSTSavings(void) const; 00644 00651 virtual UBool useDaylightTime(void) const; 00652 00667 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const; 00668 00675 UBool hasSameRules(const TimeZone& other) const; 00676 00684 virtual TimeZone* clone(void) const; 00685 00686 public: 00687 00698 virtual UClassID getDynamicClassID(void) const; 00699 00711 static UClassID getStaticClassID(void); 00712 00713 private: 00717 enum EMode 00718 { 00719 DOM_MODE = 1, 00720 DOW_IN_MONTH_MODE, 00721 DOW_GE_DOM_MODE, 00722 DOW_LE_DOM_MODE 00723 }; 00724 00725 SimpleTimeZone(); // default constructor not implemented 00726 00746 void construct(int32_t rawOffsetGMT, 00747 int8_t startMonth, int8_t startDay, int8_t startDayOfWeek, 00748 int32_t startTime, TimeMode startTimeMode, 00749 int8_t endMonth, int8_t endDay, int8_t endDayOfWeek, 00750 int32_t endTime, TimeMode endTimeMode, 00751 int32_t dstSavings, UErrorCode& status); 00752 00762 static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen, 00763 int8_t dayOfMonth, 00764 int8_t dayOfWeek, int32_t millis, int32_t millisDelta, 00765 EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek, 00766 int8_t ruleDay, int32_t ruleMillis); 00767 00783 void decodeRules(UErrorCode& status); 00784 void decodeStartRule(UErrorCode& status); 00785 void decodeEndRule(UErrorCode& status); 00786 00787 int8_t startMonth, startDay, startDayOfWeek; // the month, day, DOW, and time DST starts 00788 int32_t startTime; 00789 TimeMode startTimeMode, endTimeMode; // Mode for startTime, endTime; see TimeMode 00790 int8_t endMonth, endDay, endDayOfWeek; // the month, day, DOW, and time DST ends 00791 int32_t endTime; 00792 int32_t startYear; // the year these DST rules took effect 00793 int32_t rawOffset; // the TimeZone's raw GMT offset 00794 UBool useDaylight; // flag indicating whether this TimeZone uses DST 00795 static const int8_t STATICMONTHLENGTH[12]; // lengths of the months 00796 EMode startMode, endMode; // flags indicating what kind of rules the DST rules are 00797 00802 int32_t dstSavings; 00803 }; 00804 00805 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth, 00806 int32_t dayOfWeek, 00807 int32_t time, UErrorCode& status) { 00808 setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status); 00809 } 00810 00811 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth, 00812 int32_t time, 00813 UErrorCode& status) { 00814 setStartRule(month, dayOfMonth, time, WALL_TIME, status); 00815 } 00816 00817 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth, 00818 int32_t dayOfWeek, 00819 int32_t time, UBool after, UErrorCode& status) { 00820 setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status); 00821 } 00822 00823 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth, 00824 int32_t dayOfWeek, 00825 int32_t time, UErrorCode& status) { 00826 setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status); 00827 } 00828 00829 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, 00830 int32_t time, UErrorCode& status) { 00831 setEndRule(month, dayOfMonth, time, WALL_TIME, status); 00832 } 00833 00834 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 00835 int32_t time, UBool after, UErrorCode& status) { 00836 setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status); 00837 } 00838 00839 inline void 00840 SimpleTimeZone::getOffset(UDate date, UBool local, int32_t& rawOffsetRef, 00841 int32_t& dstOffsetRef, UErrorCode& ec) const { 00842 TimeZone::getOffset(date, local, rawOffsetRef, dstOffsetRef, ec); 00843 } 00844 00845 U_NAMESPACE_END 00846 00847 #endif /* #if !UCONFIG_NO_FORMATTING */ 00848 00849 #endif // _SIMPLETZ

Generated on Fri Jun 18 12:35:58 2004 for ICU by doxygen 1.3.7