simpletz.h

Go to the documentation of this file.
00001 /*
00002 * Copyright (C) {1997-2005}, 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 
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(); // default constructor not implemented
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;   // the month, day, DOW, and time DST starts
00793     int32_t startTime;
00794     TimeMode startTimeMode, endTimeMode; // Mode for startTime, endTime; see TimeMode
00795     int8_t endMonth, endDay, endDayOfWeek; // the month, day, DOW, and time DST ends
00796     int32_t endTime;
00797     int32_t startYear;  // the year these DST rules took effect
00798     int32_t rawOffset;  // the TimeZone's raw GMT offset
00799     UBool useDaylight; // flag indicating whether this TimeZone uses DST
00800     static const int8_t STATICMONTHLENGTH[12]; // lengths of the months
00801     EMode startMode, endMode;   // flags indicating what kind of rules the DST rules are
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 /* #if !UCONFIG_NO_FORMATTING */
00853 
00854 #endif // _SIMPLETZ

Generated on Mon Aug 13 07:17:24 2007 for ICU 3.6 by  doxygen 1.5.2