00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00031 U_NAMESPACE_BEGIN
00032
00033 class TimeZone;
00034
00051 class U_I18N_API SimpleTimeZone: public TimeZone {
00052 public:
00053
00064 enum TimeMode {
00065 WALL_TIME = 0,
00066 STANDARD_TIME,
00067 UTC_TIME
00068 };
00069
00074 SimpleTimeZone(const SimpleTimeZone& source);
00075
00080 SimpleTimeZone& operator=(const SimpleTimeZone& right);
00081
00086 virtual ~SimpleTimeZone();
00087
00097 virtual UBool operator==(const TimeZone& that) const;
00098
00110 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID);
00111
00153 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00154 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00155 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00156 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00157 int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
00158 UErrorCode& status);
00159
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 int32_t savingsDST, UErrorCode& status);
00166
00167 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00168 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00169 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00170 TimeMode savingsStartTimeMode,
00171 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00172 int8_t savingsEndDayOfWeek, int32_t savingsEndTime, TimeMode savingsEndTimeMode,
00173 int32_t savingsDST, UErrorCode& status);
00174
00183 void setStartYear(int32_t year);
00184
00227 void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00228 int32_t time, UErrorCode& status);
00229
00230 void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00231 int32_t time, TimeMode mode, UErrorCode& status);
00232
00246 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00247 UErrorCode& status);
00248
00249 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00250 TimeMode mode, UErrorCode& status);
00251
00270 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00271 int32_t time, UBool after, UErrorCode& status);
00272
00273 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00274 int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00275
00300 void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00301 int32_t time, UErrorCode& status);
00302
00303 void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00304 int32_t time, TimeMode mode, UErrorCode& status);
00305
00319 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, UErrorCode& status);
00320
00321 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time,
00322 TimeMode mode, UErrorCode& status);
00323
00342 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00343 int32_t time, UBool after, UErrorCode& status);
00344
00345 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00346 int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00347
00367 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00368 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;
00369
00370 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00371 uint8_t dayOfWeek, int32_t millis) const;
00372
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, UErrorCode& status) const;
00391
00392 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00393 uint8_t dayOfWeek, int32_t milliseconds,
00394 int32_t monthLength, int32_t prevMonthLength,
00395 UErrorCode& status) const;
00396
00404 virtual int32_t getRawOffset(void) const;
00405
00413 virtual void setRawOffset(int32_t offsetMillis);
00414
00422 void setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status);
00423
00424 #ifdef ICU_SIMPLETIMEZONE_USE_DEPRECATES
00425
00428 void setDSTSavings(int32_t millisSavedDuringDST);
00429 #endif
00430
00437 int32_t getDSTSavings(void) const;
00438
00445 virtual UBool useDaylightTime(void) const;
00446
00456 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
00457
00464 UBool hasSameRules(const TimeZone& other) const;
00465
00473 virtual TimeZone* clone(void) const;
00474
00475 public:
00476
00487 virtual UClassID getDynamicClassID(void) const { return (UClassID)&fgClassID; }
00488
00500 static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00501
00502 private:
00506 enum EMode
00507 {
00508 DOM_MODE = 1,
00509 DOW_IN_MONTH_MODE,
00510 DOW_GE_DOM_MODE,
00511 DOW_LE_DOM_MODE
00512 };
00513
00514 friend class TimeZone;
00515
00519 SimpleTimeZone(const StandardZone& stdZone, const UnicodeString& id);
00520 SimpleTimeZone(const DSTZone& dstZone, const UnicodeString& id);
00521
00525 void construct(int32_t rawOffsetGMT,
00526 int8_t startMonth, int8_t startDay, int8_t startDayOfWeek,
00527 int32_t startTime, TimeMode startTimeMode,
00528 int8_t endMonth, int8_t endDay, int8_t endDayOfWeek,
00529 int32_t endTime, TimeMode endTimeMode,
00530 int32_t dstSavings, UErrorCode& status);
00531
00541 static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen,
00542 int8_t dayOfMonth,
00543 int8_t dayOfWeek, int32_t millis, int32_t millisDelta,
00544 EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek,
00545 int8_t ruleDay, int32_t ruleMillis);
00546
00562 void decodeRules(UErrorCode& status);
00563 void decodeStartRule(UErrorCode& status);
00564 void decodeEndRule(UErrorCode& status);
00565
00566 static const char fgClassID;
00567
00568 int8_t startMonth, startDay, startDayOfWeek;
00569 int32_t startTime;
00570 TimeMode startTimeMode, endTimeMode;
00571 int8_t endMonth, endDay, endDayOfWeek;
00572 int32_t endTime;
00573 int32_t startYear;
00574 int32_t rawOffset;
00575 UBool useDaylight;
00576 static const int8_t staticMonthLength[12];
00577 EMode startMode, endMode;
00578
00583 int32_t dstSavings;
00584 };
00585
00586 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth,
00587 int32_t dayOfWeek,
00588 int32_t time, UErrorCode& status) {
00589 setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00590 }
00591
00592 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00593 int32_t time,
00594 UErrorCode& status) {
00595 setStartRule(month, dayOfMonth, time, WALL_TIME, status);
00596 }
00597
00598 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00599 int32_t dayOfWeek,
00600 int32_t time, UBool after, UErrorCode& status) {
00601 setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00602 }
00603
00604 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth,
00605 int32_t dayOfWeek,
00606 int32_t time, UErrorCode& status) {
00607 setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00608 }
00609
00610 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth,
00611 int32_t time, UErrorCode& status) {
00612 setEndRule(month, dayOfMonth, time, WALL_TIME, status);
00613 }
00614
00615 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00616 int32_t time, UBool after, UErrorCode& status) {
00617 setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00618 }
00619
00620 U_NAMESPACE_END
00621
00622 #endif // _SIMPLETZ