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
00075 SimpleTimeZone(const SimpleTimeZone& source);
00076
00082 SimpleTimeZone& operator=(const SimpleTimeZone& right);
00083
00088 virtual ~SimpleTimeZone();
00089
00099 virtual UBool operator==(const TimeZone& that) const;
00100
00112 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID);
00113
00155 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00156 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00157 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00158 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00159 int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
00160 UErrorCode& status);
00161
00162 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00163 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00164 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00165 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00166 int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
00167 int32_t savingsDST, UErrorCode& status);
00168
00169 SimpleTimeZone(int32_t rawOffsetGMT, const UnicodeString& ID,
00170 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00171 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00172 TimeMode savingsStartTimeMode,
00173 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00174 int8_t savingsEndDayOfWeek, int32_t savingsEndTime, TimeMode savingsEndTimeMode,
00175 int32_t savingsDST, UErrorCode& status);
00176
00185 void setStartYear(int32_t year);
00186
00229 void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00230 int32_t time, UErrorCode& status);
00231
00232 void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00233 int32_t time, TimeMode mode, UErrorCode& status);
00234
00248 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00249 UErrorCode& status);
00250
00251 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00252 TimeMode mode, UErrorCode& status);
00253
00272 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00273 int32_t time, UBool after, UErrorCode& status);
00274
00275 void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00276 int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00277
00302 void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00303 int32_t time, UErrorCode& status);
00304
00305 void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00306 int32_t time, TimeMode mode, UErrorCode& status);
00307
00321 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time, UErrorCode& status);
00322
00323 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time,
00324 TimeMode mode, UErrorCode& status);
00325
00344 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00345 int32_t time, UBool after, UErrorCode& status);
00346
00347 void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00348 int32_t time, TimeMode mode, UBool after, UErrorCode& status);
00349
00370 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00371 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const;
00372
00373 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00374 uint8_t dayOfWeek, int32_t millis) const;
00375
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, UErrorCode& status) const;
00395
00396 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00397 uint8_t dayOfWeek, int32_t milliseconds,
00398 int32_t monthLength, int32_t prevMonthLength,
00399 UErrorCode& status) const;
00400
00408 virtual int32_t getRawOffset(void) const;
00409
00417 virtual void setRawOffset(int32_t offsetMillis);
00418
00427 void setDSTSavings(int32_t millisSavedDuringDST, UErrorCode& status);
00428
00435 int32_t getDSTSavings(void) const;
00436
00443 virtual UBool useDaylightTime(void) const;
00444
00455 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const;
00456
00463 UBool hasSameRules(const TimeZone& other) const;
00464
00472 virtual TimeZone* clone(void) const;
00473
00474 public:
00475
00486 virtual UClassID getDynamicClassID(void) const { return (UClassID)&fgClassID; }
00487
00499 static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00500
00501 private:
00505 enum EMode
00506 {
00507 DOM_MODE = 1,
00508 DOW_IN_MONTH_MODE,
00509 DOW_GE_DOM_MODE,
00510 DOW_LE_DOM_MODE
00511 };
00512
00513 friend class TimeZone;
00514
00518 SimpleTimeZone(const StandardZone& stdZone, const UnicodeString& id);
00519 SimpleTimeZone(const DSTZone& dstZone, const UnicodeString& id);
00520
00540 void construct(int32_t rawOffsetGMT,
00541 int8_t startMonth, int8_t startDay, int8_t startDayOfWeek,
00542 int32_t startTime, TimeMode startTimeMode,
00543 int8_t endMonth, int8_t endDay, int8_t endDayOfWeek,
00544 int32_t endTime, TimeMode endTimeMode,
00545 int32_t dstSavings, UErrorCode& status);
00546
00556 static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen,
00557 int8_t dayOfMonth,
00558 int8_t dayOfWeek, int32_t millis, int32_t millisDelta,
00559 EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek,
00560 int8_t ruleDay, int32_t ruleMillis);
00561
00577 void decodeRules(UErrorCode& status);
00578 void decodeStartRule(UErrorCode& status);
00579 void decodeEndRule(UErrorCode& status);
00580
00581 static const char fgClassID;
00582
00583 int8_t startMonth, startDay, startDayOfWeek;
00584 int32_t startTime;
00585 TimeMode startTimeMode, endTimeMode;
00586 int8_t endMonth, endDay, endDayOfWeek;
00587 int32_t endTime;
00588 int32_t startYear;
00589 int32_t rawOffset;
00590 UBool useDaylight;
00591 static const int8_t staticMonthLength[12];
00592 EMode startMode, endMode;
00593
00598 int32_t dstSavings;
00599 };
00600
00601 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth,
00602 int32_t dayOfWeek,
00603 int32_t time, UErrorCode& status) {
00604 setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00605 }
00606
00607 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00608 int32_t time,
00609 UErrorCode& status) {
00610 setStartRule(month, dayOfMonth, time, WALL_TIME, status);
00611 }
00612
00613 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00614 int32_t dayOfWeek,
00615 int32_t time, UBool after, UErrorCode& status) {
00616 setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00617 }
00618
00619 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth,
00620 int32_t dayOfWeek,
00621 int32_t time, UErrorCode& status) {
00622 setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00623 }
00624
00625 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth,
00626 int32_t time, UErrorCode& status) {
00627 setEndRule(month, dayOfMonth, time, WALL_TIME, status);
00628 }
00629
00630 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00631 int32_t time, UBool after, UErrorCode& status) {
00632 setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00633 }
00634
00635 U_NAMESPACE_END
00636
00637 #endif // _SIMPLETZ