00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef TIMEZONE_H
00027 #define TIMEZONE_H
00028
00029 #include "unicode/utypes.h"
00030
00031 #if !UCONFIG_NO_FORMATTING
00032
00033 #include "unicode/uobject.h"
00034 #include "unicode/unistr.h"
00035 #include "unicode/ures.h"
00036
00037 U_NAMESPACE_BEGIN
00038
00039 class StringEnumeration;
00040
00113 class U_I18N_API TimeZone : public UObject {
00114 public:
00118 virtual ~TimeZone();
00119
00126 static const TimeZone* getGMT(void);
00127
00139 static TimeZone* createTimeZone(const UnicodeString& ID);
00140
00148 static StringEnumeration* createEnumeration();
00149
00167 static StringEnumeration* createEnumeration(int32_t rawOffset);
00168
00179 static StringEnumeration* createEnumeration(const char* country);
00180
00181 #ifdef U_USE_TIMEZONE_OBSOLETE_2_8
00182
00205 static const UnicodeString** createAvailableIDs(int32_t rawOffset, int32_t& numIDs);
00206
00228 static const UnicodeString** createAvailableIDs(const char* country,
00229 int32_t& numIDs);
00230
00244 static const UnicodeString** createAvailableIDs(int32_t& numIDs);
00245 #endif
00246
00261 static int32_t countEquivalentIDs(const UnicodeString& id);
00262
00282 static const UnicodeString getEquivalentID(const UnicodeString& id,
00283 int32_t index);
00284
00297 static TimeZone* createDefault(void);
00298
00308 static void adoptDefault(TimeZone* zone);
00309
00317 static void setDefault(const TimeZone& zone);
00318
00328 virtual UBool operator==(const TimeZone& that) const;
00329
00339 UBool operator!=(const TimeZone& that) const {return !operator==(that);}
00340
00365 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00366 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
00367
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 = 0;
00391
00415 virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
00416 int32_t& dstOffset, UErrorCode& ec) const;
00417
00425 virtual void setRawOffset(int32_t offsetMillis) = 0;
00426
00434 virtual int32_t getRawOffset(void) const = 0;
00435
00443 UnicodeString& getID(UnicodeString& ID) const;
00444
00458 void setID(const UnicodeString& ID);
00459
00464 enum EDisplayType {
00469 SHORT = 1,
00474 LONG
00475 };
00476
00488 UnicodeString& getDisplayName(UnicodeString& result) const;
00489
00503 UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
00504
00517 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
00518
00533 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
00534
00541 virtual UBool useDaylightTime(void) const = 0;
00542
00556 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
00557
00566 virtual UBool hasSameRules(const TimeZone& other) const;
00567
00575 virtual TimeZone* clone(void) const = 0;
00576
00592 virtual UClassID getDynamicClassID(void) const = 0;
00593
00594 protected:
00595
00600 TimeZone();
00601
00607 TimeZone(const UnicodeString &id);
00608
00614 TimeZone(const TimeZone& source);
00615
00621 TimeZone& operator=(const TimeZone& right);
00622
00632 static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status);
00633
00634 private:
00635 static TimeZone* createCustomTimeZone(const UnicodeString&);
00636
00642 static void initDefault(void);
00643
00644
00652 static TimeZone* createSystemTimeZone(const UnicodeString& name);
00653
00654 UnicodeString fID;
00655 };
00656
00657
00658
00659
00660 inline UnicodeString&
00661 TimeZone::getID(UnicodeString& ID) const
00662 {
00663 ID = fID;
00664 return ID;
00665 }
00666
00667
00668
00669 inline void
00670 TimeZone::setID(const UnicodeString& ID)
00671 {
00672 fID = ID;
00673 }
00674 U_NAMESPACE_END
00675
00676 #endif
00677
00678 #endif //_TIMEZONE
00679