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
00036 U_NAMESPACE_BEGIN
00037
00038 class StringEnumeration;
00039
00112 class U_I18N_API TimeZone : public UObject {
00113 public:
00117 virtual ~TimeZone();
00118
00125 static const TimeZone* getGMT(void);
00126
00138 static TimeZone* createTimeZone(const UnicodeString& ID);
00139
00147 static StringEnumeration* createEnumeration();
00148
00166 static StringEnumeration* createEnumeration(int32_t rawOffset);
00167
00178 static StringEnumeration* createEnumeration(const char* country);
00179
00203 static const UnicodeString** createAvailableIDs(int32_t rawOffset, int32_t& numIDs);
00204
00226 static const UnicodeString** createAvailableIDs(const char* country,
00227 int32_t& numIDs);
00228
00242 static const UnicodeString** createAvailableIDs(int32_t& numIDs);
00243
00258 static int32_t countEquivalentIDs(const UnicodeString& id);
00259
00279 static const UnicodeString getEquivalentID(const UnicodeString& id,
00280 int32_t index);
00281
00294 static TimeZone* createDefault(void);
00295
00305 static void adoptDefault(TimeZone* zone);
00306
00314 static void setDefault(const TimeZone& zone);
00315
00325 virtual UBool operator==(const TimeZone& that) const;
00326
00336 UBool operator!=(const TimeZone& that) const {return !operator==(that);}
00337
00358 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00359 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
00360
00376 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00377 uint8_t dayOfWeek, int32_t milliseconds,
00378 int32_t monthLength, UErrorCode& status) const = 0;
00379
00387 virtual void setRawOffset(int32_t offsetMillis) = 0;
00388
00396 virtual int32_t getRawOffset(void) const = 0;
00397
00405 UnicodeString& getID(UnicodeString& ID) const;
00406
00420 void setID(const UnicodeString& ID);
00421
00426 enum EDisplayType {
00431 SHORT = 1,
00436 LONG
00437 };
00438
00450 UnicodeString& getDisplayName(UnicodeString& result) const;
00451
00465 UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
00466
00479 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
00480
00495 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
00496
00503 virtual UBool useDaylightTime(void) const = 0;
00504
00518 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
00519
00528 virtual UBool hasSameRules(const TimeZone& other) const;
00529
00537 virtual TimeZone* clone(void) const = 0;
00538
00550 static inline UClassID getStaticClassID(void);
00551
00567 virtual UClassID getDynamicClassID(void) const = 0;
00568
00569 protected:
00570
00575 TimeZone();
00576
00582 TimeZone(const UnicodeString &id);
00583
00589 TimeZone(const TimeZone& source);
00590
00596 TimeZone& operator=(const TimeZone& right);
00597
00598 private:
00599 static const char fgClassID;
00600
00601 static TimeZone* createCustomTimeZone(const UnicodeString&);
00602
00608 static void initDefault(void);
00609
00610
00618 static TimeZone* createSystemTimeZone(const UnicodeString& name);
00619
00620 UnicodeString fID;
00621 };
00622
00623
00624 inline UClassID
00625 TimeZone::getStaticClassID(void)
00626 { return (UClassID)&fgClassID; }
00627
00628
00629
00630 inline UnicodeString&
00631 TimeZone::getID(UnicodeString& ID) const
00632 {
00633 ID = fID;
00634 return ID;
00635 }
00636
00637
00638
00639 inline void
00640 TimeZone::setID(const UnicodeString& ID)
00641 {
00642 fID = ID;
00643 }
00644 U_NAMESPACE_END
00645
00646 #endif
00647
00648 #endif //_TIMEZONE
00649