Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

simpletz.h

Go to the documentation of this file.
00001 /*
00002 * Copyright (C) {1997-1999}, 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 
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; // for access to these 2 constructors:
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;   // the month, day, DOW, and time DST starts
00800     int32_t startTime;
00801     TimeMode startTimeMode, endTimeMode; // Mode for startTime, endTime; see TimeMode
00802     int8_t endMonth, endDay, endDayOfWeek; // the month, day, DOW, and time DST ends
00803     int32_t endTime;
00804     int32_t startYear;  // the year these DST rules took effect
00805     int32_t rawOffset;  // the TimeZone's raw GMT offset
00806     UBool useDaylight; // flag indicating whether this TimeZone uses DST
00807     static const int8_t staticMonthLength[12]; // lengths of the months
00808     EMode startMode, endMode;   // flags indicating what kind of rules the DST rules are
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 /* #if !UCONFIG_NO_FORMATTING */
00854 
00855 #endif // _SIMPLETZ

Generated on Wed Dec 18 16:49:46 2002 for ICU 2.4 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001