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
00427 void setDSTSavings(int32_t millisSavedDuringDST);
00428
00435 int32_t getDSTSavings(void) const;
00436
00443 virtual UBool useDaylightTime(void) const;
00444
00454 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
00455
00462 UBool hasSameRules(const TimeZone& other) const;
00463
00471 virtual TimeZone* clone(void) const;
00472
00473 public:
00474
00485 virtual UClassID getDynamicClassID(void) const { return (UClassID)&fgClassID; }
00486
00498 static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00499
00500 private:
00504 enum EMode
00505 {
00506 DOM_MODE = 1,
00507 DOW_IN_MONTH_MODE,
00508 DOW_GE_DOM_MODE,
00509 DOW_LE_DOM_MODE
00510 };
00511
00512 friend class TimeZone;
00513
00517 SimpleTimeZone(const StandardZone& stdZone, const UnicodeString& id);
00518 SimpleTimeZone(const DSTZone& dstZone, const UnicodeString& id);
00519
00523 void construct(int32_t rawOffsetGMT,
00524 int8_t startMonth, int8_t startDay, int8_t startDayOfWeek,
00525 int32_t startTime, TimeMode startTimeMode,
00526 int8_t endMonth, int8_t endDay, int8_t endDayOfWeek,
00527 int32_t endTime, TimeMode endTimeMode,
00528 int32_t dstSavings, UErrorCode& status);
00529
00539 static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen,
00540 int8_t dayOfMonth,
00541 int8_t dayOfWeek, int32_t millis, int32_t millisDelta,
00542 EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek,
00543 int8_t ruleDay, int32_t ruleMillis);
00544
00560 void decodeRules(UErrorCode& status);
00561 void decodeStartRule(UErrorCode& status);
00562 void decodeEndRule(UErrorCode& status);
00563
00564 static const char fgClassID;
00565
00566 int8_t startMonth, startDay, startDayOfWeek;
00567 int32_t startTime;
00568 TimeMode startTimeMode, endTimeMode;
00569 int8_t endMonth, endDay, endDayOfWeek;
00570 int32_t endTime;
00571 int32_t startYear;
00572 int32_t rawOffset;
00573 UBool useDaylight;
00574 static const int8_t staticMonthLength[12];
00575 EMode startMode, endMode;
00576
00581 int32_t dstSavings;
00582 };
00583
00584 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth,
00585 int32_t dayOfWeek,
00586 int32_t time, UErrorCode& status) {
00587 setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00588 }
00589
00590 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00591 int32_t time,
00592 UErrorCode& status) {
00593 setStartRule(month, dayOfMonth, time, WALL_TIME, status);
00594 }
00595
00596 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00597 int32_t dayOfWeek,
00598 int32_t time, UBool after, UErrorCode& status) {
00599 setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00600 }
00601
00602 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth,
00603 int32_t dayOfWeek,
00604 int32_t time, UErrorCode& status) {
00605 setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00606 }
00607
00608 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth,
00609 int32_t time, UErrorCode& status) {
00610 setEndRule(month, dayOfMonth, time, WALL_TIME, status);
00611 }
00612
00613 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00614 int32_t time, UBool after, UErrorCode& status) {
00615 setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00616 }
00617
00618 U_NAMESPACE_END
00619
00620 #endif // _SIMPLETZ