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 #include "unicode/uobject.h"
00031 #include "unicode/unistr.h"
00032
00033 U_NAMESPACE_BEGIN
00034
00107 class U_I18N_API TimeZone : public UObject {
00108 public:
00112 virtual ~TimeZone();
00113
00114 #ifdef ICU_TIMEZONE_USE_DEPRECATES
00115
00121 static const TimeZone* GMT;
00122 #endif
00123
00130 static const TimeZone* getGMT(void);
00131
00143 static TimeZone* createTimeZone(const UnicodeString& ID);
00144
00166 static const UnicodeString** createAvailableIDs(int32_t rawOffset, int32_t& numIDs);
00167
00186 static const UnicodeString** createAvailableIDs(const char* country,
00187 int32_t& numIDs);
00188
00200 static const UnicodeString** createAvailableIDs(int32_t& numIDs);
00201
00216 static int32_t countEquivalentIDs(const UnicodeString& id);
00217
00237 static const UnicodeString getEquivalentID(const UnicodeString& id,
00238 int32_t index);
00239
00252 static TimeZone* createDefault(void);
00253
00263 static void adoptDefault(TimeZone* zone);
00264
00272 static void setDefault(const TimeZone& zone);
00273
00283 virtual UBool operator==(const TimeZone& that) const;
00284
00294 UBool operator!=(const TimeZone& that) const {return !operator==(that);}
00295
00316 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00317 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
00321 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00322 uint8_t dayOfWeek, int32_t millis) const = 0;
00323
00339 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00340 uint8_t dayOfWeek, int32_t milliseconds,
00341 int32_t monthLength, UErrorCode& status) const = 0;
00342
00350 virtual void setRawOffset(int32_t offsetMillis) = 0;
00351
00359 virtual int32_t getRawOffset(void) const = 0;
00360
00368 UnicodeString& getID(UnicodeString& ID) const;
00369
00383 void setID(const UnicodeString& ID);
00384
00389 enum EDisplayType {
00390 SHORT = 1,
00391 LONG
00392 };
00393
00405 UnicodeString& getDisplayName(UnicodeString& result) const;
00406
00420 UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
00421
00434 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
00435
00450 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
00451
00458 virtual UBool useDaylightTime(void) const = 0;
00459
00469 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
00470
00479 virtual UBool hasSameRules(const TimeZone& other) const;
00480
00488 virtual TimeZone* clone(void) const = 0;
00489
00501 static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00502
00518 virtual UClassID getDynamicClassID(void) const = 0;
00519
00520 protected:
00521
00526 TimeZone();
00527
00533 TimeZone(const UnicodeString &id);
00534
00540 TimeZone(const TimeZone& source);
00541
00547 TimeZone& operator=(const TimeZone& right);
00548
00549 private:
00550 static const char fgClassID;
00551
00552 static TimeZone* createCustomTimeZone(const UnicodeString&);
00553
00559 static void initDefault(void);
00560
00561
00569 static TimeZone* createSystemTimeZone(const UnicodeString& name);
00570
00571 UnicodeString fID;
00572 };
00573
00574
00575
00576
00577 inline UnicodeString&
00578 TimeZone::getID(UnicodeString& ID) const
00579 {
00580 ID = fID;
00581 return ID;
00582 }
00583
00584
00585
00586 inline void
00587 TimeZone::setID(const UnicodeString& ID)
00588 {
00589 fID = ID;
00590 }
00591 U_NAMESPACE_END
00592
00593 #endif //_TIMEZONE
00594