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

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/timezone.h"
00027 
00028 struct StandardZone;
00029 struct DSTZone;
00030 class TimeZone;
00031 
00048 class U_I18N_API SimpleTimeZone: public TimeZone {
00049 public:
00050 
00061     enum TimeMode {
00062         WALL_TIME = 0,
00063         STANDARD_TIME,
00064         UTC_TIME
00065     };
00066 
00071     SimpleTimeZone(const SimpleTimeZone& source);
00072 
00077     SimpleTimeZone& operator=(const SimpleTimeZone& right);
00078 
00083     virtual ~SimpleTimeZone();
00084 
00094     virtual UBool operator==(const TimeZone& that) const;
00095 
00107     SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID);
00108 
00150     SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00151         int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00152         int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00153         int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00154         int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
00155         UErrorCode& status);
00156 
00157     SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00158         int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00159         int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00160         int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00161         int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
00162         int32_t savingsDST, UErrorCode& status);
00163 
00164     SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00165         int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00166         int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00167         TimeMode savingsStartTimeMode,
00168         int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00169         int8_t savingsEndDayOfWeek, int32_t savingsEndTime, TimeMode savingsEndTimeMode,
00170         int32_t savingsDST, UErrorCode& status);
00171 
00180     void setStartYear(int32_t year);
00181 
00224     void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00225                       int32_t time, UErrorCode& status);
00226 
00227     void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00228                       int32_t time, TimeMode mode, UErrorCode& status);
00229 
00243     void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00244                       UErrorCode& status);
00245 
00246     void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00247                       TimeMode mode, UErrorCode& status);
00248 
00267     void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00268                       int32_t time, UBool after, UErrorCode& status);
00269 
00270     void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00271                       int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00272 
00297     void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00298                     int32_t time, UErrorCode& status);
00299 
00300     void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00301                     int32_t time, TimeMode mode, UErrorCode& status);
00302 
00316     void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, UErrorCode& status);
00317 
00318     void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time,
00319                     TimeMode mode, UErrorCode& status);
00320 
00339     void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00340                     int32_t time, UBool after, UErrorCode& status);
00341 
00342     void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00343                     int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00344 
00364     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00365                               uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;
00366 
00367     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00368                               uint8_t dayOfWeek, int32_t millis) const;
00369 
00385     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00386                            uint8_t dayOfWeek, int32_t milliseconds,
00387                            int32_t monthLength, UErrorCode& status) const;
00388 
00389     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00390                               uint8_t dayOfWeek, int32_t milliseconds,
00391                               int32_t monthLength, int32_t prevMonthLength,
00392                               UErrorCode& status) const;
00393 
00401     virtual int32_t getRawOffset(void) const;
00402 
00410     virtual void setRawOffset(int32_t offsetMillis);
00411 
00419     void setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status);
00420 
00424     void setDSTSavings(int32_t millisSavedDuringDST);
00425 
00432     int32_t getDSTSavings(void) const;
00433 
00440     virtual UBool useDaylightTime(void) const;
00441 
00451     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
00452 
00459     UBool hasSameRules(const TimeZone& other) const;
00460 
00468     virtual TimeZone* clone(void) const;
00469 
00470 public:
00471 
00482     virtual UClassID getDynamicClassID(void) const { return (UClassID)&fgClassID; }
00483 
00495     static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00496 
00497 private:
00501     enum EMode
00502     {
00503         DOM_MODE = 1,
00504         DOW_IN_MONTH_MODE,
00505         DOW_GE_DOM_MODE,
00506         DOW_LE_DOM_MODE
00507     };
00508 
00509     friend class TimeZone; // for access to these 2 constructors:
00510 
00514     SimpleTimeZone(const StandardZone& stdZone, const UnicodeString& id);
00515     SimpleTimeZone(const DSTZone& dstZone, const UnicodeString& id);
00516 
00520     void construct(int32_t rawOffsetGMT, const UnicodeString& ID,
00521                    int8_t startMonth, int8_t startDay, int8_t startDayOfWeek,
00522                    int32_t startTime, TimeMode startTimeMode,
00523                    int8_t endMonth, int8_t endDay, int8_t endDayOfWeek,
00524                    int32_t endTime, TimeMode endTimeMode,
00525                    int32_t dstSavings, UErrorCode& status);
00526 
00536     static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen,
00537                                  int8_t dayOfMonth,
00538                                  int8_t dayOfWeek, int32_t millis, int32_t millisDelta,
00539                                  EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek,
00540                                  int8_t ruleDay, int32_t ruleMillis);
00541 
00557     void decodeRules(UErrorCode& status);
00558     void decodeStartRule(UErrorCode& status);
00559     void decodeEndRule(UErrorCode& status);
00560 
00561     static char     fgClassID;
00562 
00563     int8_t startMonth, startDay, startDayOfWeek;   // the month, day, DOW, and time DST starts
00564     int32_t startTime;
00565     TimeMode startTimeMode, endTimeMode; // Mode for startTime, endTime; see TimeMode
00566     int8_t endMonth, endDay, endDayOfWeek; // the month, day, DOW, and time DST ends
00567     int32_t endTime;
00568     int32_t startYear;  // the year these DST rules took effect
00569     int32_t rawOffset;  // the TimeZone's raw GMT offset
00570     UBool useDaylight; // flag indicating whether this TimeZone uses DST
00571     static const int8_t staticMonthLength[12]; // lengths of the months
00572     EMode startMode, endMode;   // flags indicating what kind of rules the DST rules are
00573 
00578     int32_t dstSavings;
00579 };
00580 
00581 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth,
00582                                          int32_t dayOfWeek,
00583                                          int32_t time, UErrorCode& status) {
00584     setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00585 }
00586 
00587 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00588                                          int32_t time,
00589                                          UErrorCode& status) {
00590     setStartRule(month, dayOfMonth, time, WALL_TIME, status);
00591 }
00592 
00593 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00594                                          int32_t dayOfWeek,
00595                                          int32_t time, UBool after, UErrorCode& status) {
00596     setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00597 }
00598 
00599 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth,
00600                                        int32_t dayOfWeek,
00601                                        int32_t time, UErrorCode& status) {
00602     setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00603 }
00604 
00605 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth,
00606                                        int32_t time, UErrorCode& status) {
00607     setEndRule(month, dayOfMonth, time, WALL_TIME, status);
00608 }
00609 
00610 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00611                                        int32_t time, UBool after, UErrorCode& status) {
00612     setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00613 }
00614 
00615 #endif // _SIMPLETZ

Generated at Thu Mar 22 16:12:38 2001 for ICU 1.8 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000