ICU 4.8.1.1
4.8.1.1
|
00001 /************************************************************************* 00002 * Copyright (c) 1997-2011, International Business Machines Corporation 00003 * and others. All Rights Reserved. 00004 ************************************************************************** 00005 * 00006 * File TIMEZONE.H 00007 * 00008 * Modification History: 00009 * 00010 * Date Name Description 00011 * 04/21/97 aliu Overhauled header. 00012 * 07/09/97 helena Changed createInstance to createDefault. 00013 * 08/06/97 aliu Removed dependency on internal header for Hashtable. 00014 * 08/10/98 stephen Changed getDisplayName() API conventions to match 00015 * 08/19/98 stephen Changed createTimeZone() to never return 0 00016 * 09/02/98 stephen Sync to JDK 1.2 8/31 00017 * - Added getOffset(... monthlen ...) 00018 * - Added hasSameRules() 00019 * 09/15/98 stephen Added getStaticClassID 00020 * 12/03/99 aliu Moved data out of static table into icudata.dll. 00021 * Hashtable replaced by new static data structures. 00022 * 12/14/99 aliu Made GMT public. 00023 * 08/15/01 grhoten Made GMT private and added the getGMT() function 00024 ************************************************************************** 00025 */ 00026 00027 #ifndef TIMEZONE_H 00028 #define TIMEZONE_H 00029 00030 #include "unicode/utypes.h" 00031 00037 #if !UCONFIG_NO_FORMATTING 00038 00039 #include "unicode/uobject.h" 00040 #include "unicode/unistr.h" 00041 #include "unicode/ures.h" 00042 #include "unicode/ucal.h" 00043 00044 U_NAMESPACE_BEGIN 00045 00046 class StringEnumeration; 00047 00123 class U_I18N_API TimeZone : public UObject { 00124 public: 00128 virtual ~TimeZone(); 00129 00136 static const TimeZone* U_EXPORT2 getGMT(void); 00137 00148 static TimeZone* U_EXPORT2 createTimeZone(const UnicodeString& ID); 00149 00150 00166 static StringEnumeration* U_EXPORT2 createTimeZoneIDEnumeration( 00167 USystemTimeZoneType zoneType, 00168 const char* region, 00169 const int32_t* rawOffset, 00170 UErrorCode& ec); 00171 00179 static StringEnumeration* U_EXPORT2 createEnumeration(); 00180 00198 static StringEnumeration* U_EXPORT2 createEnumeration(int32_t rawOffset); 00199 00210 static StringEnumeration* U_EXPORT2 createEnumeration(const char* country); 00211 00226 static int32_t U_EXPORT2 countEquivalentIDs(const UnicodeString& id); 00227 00247 static const UnicodeString U_EXPORT2 getEquivalentID(const UnicodeString& id, 00248 int32_t index); 00249 00262 static TimeZone* U_EXPORT2 createDefault(void); 00263 00273 static void U_EXPORT2 adoptDefault(TimeZone* zone); 00274 00282 static void U_EXPORT2 setDefault(const TimeZone& zone); 00283 00290 static const char* U_EXPORT2 getTZDataVersion(UErrorCode& status); 00291 00305 static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id, 00306 UnicodeString& canonicalID, UErrorCode& status); 00307 00323 static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id, 00324 UnicodeString& canonicalID, UBool& isSystemID, UErrorCode& status); 00325 00335 virtual UBool operator==(const TimeZone& that) const; 00336 00346 UBool operator!=(const TimeZone& that) const {return !operator==(that);} 00347 00372 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 00373 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0; 00374 00395 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 00396 uint8_t dayOfWeek, int32_t milliseconds, 00397 int32_t monthLength, UErrorCode& status) const = 0; 00398 00422 virtual void getOffset(UDate date, UBool local, int32_t& rawOffset, 00423 int32_t& dstOffset, UErrorCode& ec) const; 00424 00432 virtual void setRawOffset(int32_t offsetMillis) = 0; 00433 00441 virtual int32_t getRawOffset(void) const = 0; 00442 00450 UnicodeString& getID(UnicodeString& ID) const; 00451 00465 void setID(const UnicodeString& ID); 00466 00471 enum EDisplayType { 00476 SHORT = 1, 00481 LONG, 00486 SHORT_GENERIC, 00491 LONG_GENERIC, 00497 SHORT_GMT, 00503 LONG_GMT, 00509 SHORT_COMMONLY_USED, 00515 GENERIC_LOCATION 00516 }; 00517 00529 UnicodeString& getDisplayName(UnicodeString& result) const; 00530 00544 UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const; 00545 00558 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const; 00559 00574 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const; 00575 00592 virtual UBool useDaylightTime(void) const = 0; 00593 00607 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0; 00608 00617 virtual UBool hasSameRules(const TimeZone& other) const; 00618 00626 virtual TimeZone* clone(void) const = 0; 00627 00634 static UClassID U_EXPORT2 getStaticClassID(void); 00635 00647 virtual UClassID getDynamicClassID(void) const = 0; 00648 00664 virtual int32_t getDSTSavings() const; 00665 00683 static int32_t U_EXPORT2 getRegion(const UnicodeString& id, 00684 char *region, int32_t capacity, UErrorCode& status); 00685 00686 protected: 00687 00692 TimeZone(); 00693 00699 TimeZone(const UnicodeString &id); 00700 00706 TimeZone(const TimeZone& source); 00707 00713 TimeZone& operator=(const TimeZone& right); 00714 00724 static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status); 00725 00726 00727 private: 00728 friend class ZoneMeta; 00729 00730 00731 static TimeZone* createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string. 00732 00741 static const UChar* findID(const UnicodeString& id); 00742 00751 static const UChar* dereferOlsonLink(const UnicodeString& id); 00752 00759 static const UChar* getRegion(const UnicodeString& id); 00760 00768 static const UChar* getRegion(const UnicodeString& id, UErrorCode& status); 00769 00780 static UBool parseCustomID(const UnicodeString& id, int32_t& sign, int32_t& hour, 00781 int32_t& minute, int32_t& second); 00782 00793 static UnicodeString& getCustomID(const UnicodeString& id, UnicodeString& normalized, 00794 UErrorCode& status); 00795 00805 static UnicodeString& formatCustomID(int32_t hour, int32_t min, int32_t sec, 00806 UBool negative, UnicodeString& id); 00807 00813 static void initDefault(void); 00814 00815 // See source file for documentation 00823 static TimeZone* createSystemTimeZone(const UnicodeString& name); 00824 static TimeZone* createSystemTimeZone(const UnicodeString& name, UErrorCode& ec); 00825 00826 UnicodeString fID; // this time zone's ID 00827 00828 friend class TZEnumeration; 00829 }; 00830 00831 00832 // ------------------------------------- 00833 00834 inline UnicodeString& 00835 TimeZone::getID(UnicodeString& ID) const 00836 { 00837 ID = fID; 00838 return ID; 00839 } 00840 00841 // ------------------------------------- 00842 00843 inline void 00844 TimeZone::setID(const UnicodeString& ID) 00845 { 00846 fID = ID; 00847 } 00848 U_NAMESPACE_END 00849 00850 #endif /* #if !UCONFIG_NO_FORMATTING */ 00851 00852 #endif //_TIMEZONE 00853 //eof