Main Page   Class Hierarchy   Compound List   File List   Header Files   Sources   Compound Members   File Members  

simpletz.h

00001 /*
00002 * Copyright © {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 rawOffset, const UnicodeString& ID);
00108 
00150     SimpleTimeZone(int32_t rawOffset, const UnicodeString& ID,
00151         int8_t startMonth, int8_t startDayOfWeekInMonth,
00152         int8_t startDayOfWeek, int32_t startTime,
00153         int8_t endMonth, int8_t endDayOfWeekInMonth,
00154         int8_t endDayOfWeek, int32_t endTime,
00155         UErrorCode& status);
00156 
00157     SimpleTimeZone(int32_t rawOffset, const UnicodeString& ID,
00158         int8_t startMonth, int8_t startDayOfWeekInMonth,
00159         int8_t startDayOfWeek, int32_t startTime,
00160         int8_t endMonth, int8_t endDayOfWeekInMonth,
00161         int8_t endDayOfWeek, int32_t endTime,
00162         int32_t dstSavings, UErrorCode& status);
00163 
00164     SimpleTimeZone(int32_t rawOffset, const UnicodeString& ID,
00165         int8_t startMonth, int8_t startDayOfWeekInMonth,
00166         int8_t startDayOfWeek, int32_t startTime, TimeMode startTimeMode,
00167         int8_t endMonth, int8_t endDayOfWeekInMonth,
00168         int8_t endDayOfWeek, int32_t endTime, TimeMode endTimeMode,
00169         int32_t dstSavings, UErrorCode& status);
00170 
00179     void setStartYear(int32_t year);
00180 
00223     void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00224                       int32_t time, UErrorCode& status);
00225 
00226     void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00227                       int32_t time, TimeMode mode, UErrorCode& status);
00228 
00242     void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time, 
00243                       UErrorCode& status);
00244 
00245     void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time, 
00246                       TimeMode mode, UErrorCode& status);
00247 
00266     void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 
00267                       int32_t time, UBool after, UErrorCode& status);
00268 
00269     void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 
00270                       int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00271 
00296     void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00297                     int32_t time, UErrorCode& status);
00298 
00299     void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00300                     int32_t time, TimeMode mode, UErrorCode& status);
00301 
00315     void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, UErrorCode& status);
00316 
00317     void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time,
00318                     TimeMode mode, UErrorCode& status);
00319 
00338     void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 
00339                     int32_t time, UBool after, UErrorCode& status);
00340 
00341     void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 
00342                     int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00343 
00363     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00364                               uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;
00365 
00366     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00367                               uint8_t dayOfWeek, int32_t millis) const;
00368 
00384     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00385                            uint8_t dayOfWeek, int32_t milliseconds, 
00386                            int32_t monthLength, UErrorCode& status) const;
00387 
00388     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00389                               uint8_t dayOfWeek, int32_t milliseconds, 
00390                               int32_t monthLength, int32_t prevMonthLength,
00391                               UErrorCode& status) const;
00392 
00400     virtual int32_t getRawOffset(void) const;
00401 
00409     virtual void setRawOffset(int32_t offsetMillis);
00410 
00418     void setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status);
00419 
00423     void setDSTSavings(int32_t millisSavedDuringDST);
00424 
00431     int32_t getDSTSavings(void) const;
00432 
00439     virtual UBool useDaylightTime(void) const;
00440 
00450     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
00451 
00458     UBool hasSameRules(const TimeZone& other) const;
00459 
00467     virtual TimeZone* clone(void) const;
00468 
00469 public:
00470 
00481     virtual UClassID getDynamicClassID(void) const { return (UClassID)&fgClassID; }
00482 
00494     static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00495 
00496 private:
00500     enum EMode
00501     {
00502         DOM_MODE = 1,
00503         DOW_IN_MONTH_MODE,
00504         DOW_GE_DOM_MODE,
00505         DOW_LE_DOM_MODE
00506     };
00507 
00508     friend class TimeZone; // for access to these 2 constructors:
00509 
00513     SimpleTimeZone(const StandardZone& stdZone, const UnicodeString& id);
00514     SimpleTimeZone(const DSTZone& dstZone, const UnicodeString& id);
00515 
00519     void construct(int32_t rawOffset, const UnicodeString& ID,
00520                    int8_t startMonth, int8_t startDay, int8_t startDayOfWeek,
00521                    int32_t startTime, TimeMode startTimeMode,
00522                    int8_t endMonth, int8_t endDay, int8_t endDayOfWeek,
00523                    int32_t endTime, TimeMode endTimeMode,
00524                    int32_t dstSavings, UErrorCode& status);
00525 
00535     static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen,
00536                                  int8_t dayOfMonth,
00537                                  int8_t dayOfWeek, int32_t millis, int32_t millisDelta,
00538                                  EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek,
00539                                  int8_t ruleDay, int32_t ruleMillis);
00540 
00556     void decodeRules(UErrorCode& status);
00557     void decodeStartRule(UErrorCode& status);
00558     void decodeEndRule(UErrorCode& status);
00559 
00560     static char     fgClassID;
00561 
00562     int8_t startMonth, startDay, startDayOfWeek;   // the month, day, DOW, and time DST starts
00563     int32_t startTime;
00564     TimeMode startTimeMode, endTimeMode; // Mode for startTime, endTime; see TimeMode
00565     int8_t endMonth, endDay, endDayOfWeek; // the month, day, DOW, and time DST ends
00566     int32_t endTime;
00567     int32_t startYear;  // the year these DST rules took effect
00568     int32_t rawOffset;  // the TimeZone's raw GMT offset
00569     UBool useDaylight; // flag indicating whether this TimeZone uses DST
00570     static const int8_t staticMonthLength[12]; // lengths of the months
00571     EMode startMode, endMode;   // flags indicating what kind of rules the DST rules are
00572 
00577     int32_t dstSavings;
00578 };
00579 
00580 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth,
00581                                          int32_t dayOfWeek,
00582                                          int32_t time, UErrorCode& status) {
00583     setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00584 }
00585 
00586 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00587                                          int32_t time, 
00588                                          UErrorCode& status) {
00589     setStartRule(month, dayOfMonth, time, WALL_TIME, status);
00590 }
00591 
00592 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00593                                          int32_t dayOfWeek, 
00594                                          int32_t time, UBool after, UErrorCode& status) {
00595     setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00596 }
00597 
00598 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth,
00599                                        int32_t dayOfWeek,
00600                                        int32_t time, UErrorCode& status) {
00601     setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00602 }
00603 
00604 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth,
00605                                        int32_t time, UErrorCode& status) {
00606     setEndRule(month, dayOfMonth, time, WALL_TIME, status);
00607 }
00608 
00609 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek, 
00610                                        int32_t time, UBool after, UErrorCode& status) {
00611     setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00612 }
00613 
00614 #endif // _SIMPLETZ

Generated at Mon Jun 5 12:53:05 2000 for ICU1.5 by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999