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
00119 #ifdef ICU_TIMEZONE_USE_DEPRECATES
00120
00125 static const TimeZone* GMT;
00126 #endif
00127
00134 static const TimeZone* getGMT(void);
00135
00147 static TimeZone* createTimeZone(const UnicodeString& ID);
00148
00156 static StringEnumeration* createEnumeration();
00157
00175 static StringEnumeration* createEnumeration(int32_t rawOffset);
00176
00187 static StringEnumeration* createEnumeration(const char* country);
00188
00212 static const UnicodeString** createAvailableIDs(int32_t rawOffset, int32_t& numIDs);
00213
00235 static const UnicodeString** createAvailableIDs(const char* country,
00236 int32_t& numIDs);
00237
00251 static const UnicodeString** createAvailableIDs(int32_t& numIDs);
00252
00267 static int32_t countEquivalentIDs(const UnicodeString& id);
00268
00288 static const UnicodeString getEquivalentID(const UnicodeString& id,
00289 int32_t index);
00290
00303 static TimeZone* createDefault(void);
00304
00314 static void adoptDefault(TimeZone* zone);
00315
00323 static void setDefault(const TimeZone& zone);
00324
00334 virtual UBool operator==(const TimeZone& that) const;
00335
00345 UBool operator!=(const TimeZone& that) const {return !operator==(that);}
00346
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 = 0;
00369
00370 #ifdef ICU_TIMEZONE_USE_DEPRECATES
00374 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00375 uint8_t dayOfWeek, int32_t millis) const = 0;
00376 #endif
00377
00393 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00394 uint8_t dayOfWeek, int32_t milliseconds,
00395 int32_t monthLength, UErrorCode& status) const = 0;
00396
00404 virtual void setRawOffset(int32_t offsetMillis) = 0;
00405
00413 virtual int32_t getRawOffset(void) const = 0;
00414
00422 UnicodeString& getID(UnicodeString& ID) const;
00423
00437 void setID(const UnicodeString& ID);
00438
00443 enum EDisplayType {
00448 SHORT = 1,
00453 LONG
00454 };
00455
00467 UnicodeString& getDisplayName(UnicodeString& result) const;
00468
00482 UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
00483
00496 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
00497
00512 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
00513
00520 virtual UBool useDaylightTime(void) const = 0;
00521
00535 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
00536
00545 virtual UBool hasSameRules(const TimeZone& other) const;
00546
00554 virtual TimeZone* clone(void) const = 0;
00555
00567 static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00568
00584 virtual UClassID getDynamicClassID(void) const = 0;
00585
00586 protected:
00587
00592 TimeZone();
00593
00599 TimeZone(const UnicodeString &id);
00600
00606 TimeZone(const TimeZone& source);
00607
00613 TimeZone& operator=(const TimeZone& right);
00614
00615 private:
00616 static const char fgClassID;
00617
00618 static TimeZone* createCustomTimeZone(const UnicodeString&);
00619
00625 static void initDefault(void);
00626
00627
00635 static TimeZone* createSystemTimeZone(const UnicodeString& name);
00636
00637 UnicodeString fID;
00638 };
00639
00640
00641
00642
00643 inline UnicodeString&
00644 TimeZone::getID(UnicodeString& ID) const
00645 {
00646 ID = fID;
00647 return ID;
00648 }
00649
00650
00651
00652 inline void
00653 TimeZone::setID(const UnicodeString& ID)
00654 {
00655 fID = ID;
00656 }
00657 U_NAMESPACE_END
00658
00659 #endif
00660
00661 #endif //_TIMEZONE
00662