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/utypes.h"
00027
00028
#if !UCONFIG_NO_FORMATTING
00029
00030
#include "unicode/timezone.h"
00031
00032
U_NAMESPACE_BEGIN
00033
00050 class U_I18N_API SimpleTimeZone:
public TimeZone {
00051
public:
00052
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
00149 SimpleTimeZone(int32_t rawOffsetGMT,
const UnicodeString& ID,
00150 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00151 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00152 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00153 int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
00154
UErrorCode& status);
00192 SimpleTimeZone(int32_t rawOffsetGMT,
const UnicodeString& ID,
00193 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00194 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00195 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00196 int8_t savingsEndDayOfWeek, int32_t savingsEndTime,
00197 int32_t savingsDST,
UErrorCode& status);
00198
00240 SimpleTimeZone(int32_t rawOffsetGMT,
const UnicodeString& ID,
00241 int8_t savingsStartMonth, int8_t savingsStartDayOfWeekInMonth,
00242 int8_t savingsStartDayOfWeek, int32_t savingsStartTime,
00243 TimeMode savingsStartTimeMode,
00244 int8_t savingsEndMonth, int8_t savingsEndDayOfWeekInMonth,
00245 int8_t savingsEndDayOfWeek, int32_t savingsEndTime, TimeMode savingsEndTimeMode,
00246 int32_t savingsDST,
UErrorCode& status);
00247
00256
void setStartYear(int32_t year);
00257
00298
void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00299 int32_t time,
UErrorCode& status);
00342
void setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00343 int32_t time, TimeMode mode,
UErrorCode& status);
00344
00356
void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00357
UErrorCode& status);
00371
void setStartRule(int32_t month, int32_t dayOfMonth, int32_t time,
00372 TimeMode mode,
UErrorCode& status);
00373
00390
void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00391 int32_t time,
UBool after,
UErrorCode& status);
00410
void setStartRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00411 int32_t time, TimeMode mode,
UBool after,
UErrorCode& status);
00412
00435
void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00436 int32_t time,
UErrorCode& status);
00437
00462
void setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek,
00463 int32_t time, TimeMode mode,
UErrorCode& status);
00464
00476
void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time,
UErrorCode& status);
00477
00491
void setEndRule(int32_t month, int32_t dayOfMonth, int32_t time,
00492 TimeMode mode,
UErrorCode& status);
00493
00510
void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00511 int32_t time,
UBool after,
UErrorCode& status);
00512
00531
void setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00532 int32_t time, TimeMode mode,
UBool after,
UErrorCode& status);
00533
00554
virtual int32_t
getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00555 uint8_t dayOfWeek, int32_t millis,
UErrorCode& status)
const;
00556
00572
virtual int32_t
getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00573 uint8_t dayOfWeek, int32_t milliseconds,
00574 int32_t monthLength,
UErrorCode& status)
const;
00591
virtual int32_t
getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00592 uint8_t dayOfWeek, int32_t milliseconds,
00593 int32_t monthLength, int32_t prevMonthLength,
00594
UErrorCode& status)
const;
00595
00601
virtual void getOffset(
UDate date,
UBool local, int32_t& rawOffset,
00602 int32_t& dstOffset,
UErrorCode& ec)
const;
00603
00611
virtual int32_t
getRawOffset(
void) const;
00612
00620 virtual
void setRawOffset(int32_t offsetMillis);
00621
00630
void setDSTSavings(int32_t millisSavedDuringDST,
UErrorCode& status);
00631
00639 int32_t getDSTSavings(
void) const;
00640
00647 virtual
UBool useDaylightTime(
void) const;
00648
00663 virtual
UBool inDaylightTime(
UDate date,
UErrorCode& status) const;
00664
00671
UBool hasSameRules(const
TimeZone& other) const;
00672
00680 virtual
TimeZone* clone(
void) const;
00681
00682 public:
00683
00694 virtual
UClassID getDynamicClassID(
void) const;
00695
00707 static
UClassID getStaticClassID(
void);
00708
00709 private:
00713 enum EMode
00714 {
00715 DOM_MODE = 1,
00716 DOW_IN_MONTH_MODE,
00717 DOW_GE_DOM_MODE,
00718 DOW_LE_DOM_MODE
00719 };
00720
00721 SimpleTimeZone();
00722
00742
void construct(int32_t rawOffsetGMT,
00743 int8_t startMonth, int8_t startDay, int8_t startDayOfWeek,
00744 int32_t startTime, TimeMode startTimeMode,
00745 int8_t endMonth, int8_t endDay, int8_t endDayOfWeek,
00746 int32_t endTime, TimeMode endTimeMode,
00747 int32_t dstSavings,
UErrorCode& status);
00748
00758
static int32_t compareToRule(int8_t month, int8_t monthLen, int8_t prevMonthLen,
00759 int8_t dayOfMonth,
00760 int8_t dayOfWeek, int32_t millis, int32_t millisDelta,
00761 EMode ruleMode, int8_t ruleMonth, int8_t ruleDayOfWeek,
00762 int8_t ruleDay, int32_t ruleMillis);
00763
00779
void decodeRules(
UErrorCode& status);
00780
void decodeStartRule(
UErrorCode& status);
00781
void decodeEndRule(
UErrorCode& status);
00782
00783 int8_t startMonth, startDay, startDayOfWeek;
00784 int32_t startTime;
00785 TimeMode startTimeMode, endTimeMode;
00786 int8_t endMonth, endDay, endDayOfWeek;
00787 int32_t endTime;
00788 int32_t startYear;
00789 int32_t rawOffset;
00790
UBool useDaylight;
00791
static const int8_t STATICMONTHLENGTH[12];
00792 EMode startMode, endMode;
00793
00798 int32_t dstSavings;
00799 };
00800
00801 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfWeekInMonth,
00802 int32_t dayOfWeek,
00803 int32_t time,
UErrorCode& status) {
00804
setStartRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00805 }
00806
00807 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00808 int32_t time,
00809
UErrorCode& status) {
00810
setStartRule(month, dayOfMonth, time, WALL_TIME, status);
00811 }
00812
00813 inline void SimpleTimeZone::setStartRule(int32_t month, int32_t dayOfMonth,
00814 int32_t dayOfWeek,
00815 int32_t time,
UBool after,
UErrorCode& status) {
00816
setStartRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00817 }
00818
00819 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfWeekInMonth,
00820 int32_t dayOfWeek,
00821 int32_t time,
UErrorCode& status) {
00822
setEndRule(month, dayOfWeekInMonth, dayOfWeek, time, WALL_TIME, status);
00823 }
00824
00825 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth,
00826 int32_t time,
UErrorCode& status) {
00827
setEndRule(month, dayOfMonth, time, WALL_TIME, status);
00828 }
00829
00830 inline void SimpleTimeZone::setEndRule(int32_t month, int32_t dayOfMonth, int32_t dayOfWeek,
00831 int32_t time,
UBool after,
UErrorCode& status) {
00832
setEndRule(month, dayOfMonth, dayOfWeek, time, WALL_TIME, after, status);
00833 }
00834
00835
inline void
00836 SimpleTimeZone::getOffset(
UDate date,
UBool local, int32_t& rawOffsetRef,
00837 int32_t& dstOffsetRef,
UErrorCode& ec)
const {
00838
TimeZone::getOffset(date, local, rawOffsetRef, dstOffsetRef, ec);
00839 }
00840
00841
U_NAMESPACE_END
00842
00843
#endif
00844
00845
#endif // _SIMPLETZ