Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

simpletz.h

00001 /*
00002 * Copyright (C) {1997-2003}, 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 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 
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 
00303     void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00304                       int32_t time, UErrorCode& status);
00347     void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00348                       int32_t time, TimeMode mode, UErrorCode& status);
00349 
00361     void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00362                       UErrorCode& status);
00376     void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00377                       TimeMode mode, UErrorCode& status);
00378 
00395     void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00396                       int32_t time, UBool after, UErrorCode& status);
00415     void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00416                       int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00417 
00440     void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00441                     int32_t time, UErrorCode& status);
00442 
00467     void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00468                     int32_t time, TimeMode mode, UErrorCode& status);
00469 
00481     void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, UErrorCode& status);
00482 
00496     void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time,
00497                     TimeMode mode, UErrorCode& status);
00498 
00515     void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00516                     int32_t time, UBool after, UErrorCode& status);
00517 
00536     void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00537                     int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00538 
00559     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00560                               uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;
00561 
00577     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00578                            uint8_t dayOfWeek, int32_t milliseconds,
00579                            int32_t monthLength, UErrorCode& status) const;
00596     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00597                               uint8_t dayOfWeek, int32_t milliseconds,
00598                               int32_t monthLength, int32_t prevMonthLength,
00599                               UErrorCode& status) const;
00600 
00608     virtual int32_t getRawOffset(void) const;
00609 
00617     virtual void setRawOffset(int32_t offsetMillis);
00618 
00627     void setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status);
00628 
00636     int32_t getDSTSavings(void) const;
00637 
00644     virtual UBool useDaylightTime(void) const;
00645 
00660     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
00661 
00668     UBool hasSameRules(const TimeZone& other) const;
00669 
00677     virtual TimeZone* clone(void) const;
00678 
00679 public:
00680 
00691     virtual UClassID getDynamicClassID(void) const;
00692 
00704     static UClassID getStaticClassID(void);
00705 
00706 private:
00710     enum EMode
00711     {
00712         DOM_MODE = 1,
00713         DOW_IN_MONTH_MODE,
00714         DOW_GE_DOM_MODE,
00715         DOW_LE_DOM_MODE
00716     };
00717 
00718     friend class TimeZone; // for access to these 2 constructors:
00719 
00720     SimpleTimeZone(); // default constructor not implemented
00721 
00725     SimpleTimeZone(const StandardZone& stdZone, const UnicodeString& id);
00726     SimpleTimeZone(const DSTZone& dstZone, const UnicodeString& id);
00727 
00747     void construct(int32_t rawOffsetGMT,
00748                    int8_t startMonth, int8_t startDay, int8_t startDayOfWeek,
00749                    int32_t startTime, TimeMode startTimeMode,
00750                    int8_t endMonth, int8_t endDay, int8_t endDayOfWeek,
00751                    int32_t endTime, TimeMode endTimeMode,
00752                    int32_t dstSavings, UErrorCode& status);
00753 
00763     static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen,
00764                                  int8_t dayOfMonth,
00765                                  int8_t dayOfWeek, int32_t millis, int32_t millisDelta,
00766                                  EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek,
00767                                  int8_t ruleDay, int32_t ruleMillis);
00768 
00784     void decodeRules(UErrorCode& status);
00785     void decodeStartRule(UErrorCode& status);
00786     void decodeEndRule(UErrorCode& status);
00787 
00788     static const char     fgClassID;
00789 
00790     int8_t startMonth, startDay, startDayOfWeek;   // the month, day, DOW, and time DST starts
00791     int32_t startTime;
00792     TimeMode startTimeMode, endTimeMode; // Mode for startTime, endTime; see TimeMode
00793     int8_t endMonth, endDay, endDayOfWeek; // the month, day, DOW, and time DST ends
00794     int32_t endTime;
00795     int32_t startYear;  // the year these DST rules took effect
00796     int32_t rawOffset;  // the TimeZone's raw GMT offset
00797     UBool useDaylight; // flag indicating whether this TimeZone uses DST
00798     static const int8_t staticMonthLength[12]; // lengths of the months
00799     EMode startMode, endMode;   // flags indicating what kind of rules the DST rules are
00800 
00805     int32_t dstSavings;
00806 };
00807 
00808 inline UClassID
00809 SimpleTimeZone::getStaticClassID(void)
00810 { return (UClassID)&fgClassID; }
00811 
00812 inline UClassID
00813 SimpleTimeZone::getDynamicClassID(void) const
00814 { return SimpleTimeZone::getStaticClassID(); }
00815 
00816 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth,
00817                                          int32_t dayOfWeek,
00818                                          int32_t time, UErrorCode& status) {
00819     setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00820 }
00821 
00822 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00823                                          int32_t time,
00824                                          UErrorCode& status) {
00825     setStartRule(month, dayOfMonth, time, WALL_TIME, status);
00826 }
00827 
00828 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00829                                          int32_t dayOfWeek,
00830                                          int32_t time, UBool after, UErrorCode& status) {
00831     setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00832 }
00833 
00834 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth,
00835                                        int32_t dayOfWeek,
00836                                        int32_t time, UErrorCode& status) {
00837     setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00838 }
00839 
00840 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth,
00841                                        int32_t time, UErrorCode& status) {
00842     setEndRule(month, dayOfMonth, time, WALL_TIME, status);
00843 }
00844 
00845 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00846                                        int32_t time, UBool after, UErrorCode& status) {
00847     setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00848 }
00849 
00850 U_NAMESPACE_END
00851 
00852 #endif /* #if !UCONFIG_NO_FORMATTING */
00853 
00854 #endif // _SIMPLETZ

Generated on Wed Sep 3 17:47:09 2003 for ICU 2.6 by doxygen 1.3.2