|
ICU 73.2
73.2
|
00001 // © 2016 and later: Unicode, Inc. and others. 00002 // License & terms of use: http://www.unicode.org/copyright.html 00003 /************************************************************************* 00004 * Copyright (c) 1997-2016, International Business Machines Corporation 00005 * and others. All Rights Reserved. 00006 ************************************************************************** 00007 * 00008 * File TIMEZONE.H 00009 * 00010 * Modification History: 00011 * 00012 * Date Name Description 00013 * 04/21/97 aliu Overhauled header. 00014 * 07/09/97 helena Changed createInstance to createDefault. 00015 * 08/06/97 aliu Removed dependency on internal header for Hashtable. 00016 * 08/10/98 stephen Changed getDisplayName() API conventions to match 00017 * 08/19/98 stephen Changed createTimeZone() to never return 0 00018 * 09/02/98 stephen Sync to JDK 1.2 8/31 00019 * - Added getOffset(... monthlen ...) 00020 * - Added hasSameRules() 00021 * 09/15/98 stephen Added getStaticClassID 00022 * 12/03/99 aliu Moved data out of static table into icudata.dll. 00023 * Hashtable replaced by new static data structures. 00024 * 12/14/99 aliu Made GMT public. 00025 * 08/15/01 grhoten Made GMT private and added the getGMT() function 00026 ************************************************************************** 00027 */ 00028 00029 #ifndef TIMEZONE_H 00030 #define TIMEZONE_H 00031 00032 #include "unicode/utypes.h" 00033 00034 #if U_SHOW_CPLUSPLUS_API 00035 00041 #if !UCONFIG_NO_FORMATTING 00042 00043 #include "unicode/uobject.h" 00044 #include "unicode/unistr.h" 00045 #include "unicode/ures.h" 00046 #include "unicode/ucal.h" 00047 00048 U_NAMESPACE_BEGIN 00049 00050 class StringEnumeration; 00051 00133 class U_I18N_API TimeZone : public UObject { 00134 public: 00138 virtual ~TimeZone(); 00139 00152 static const TimeZone& U_EXPORT2 getUnknown(); 00153 00166 static const TimeZone* U_EXPORT2 getGMT(void); 00167 00179 static TimeZone* U_EXPORT2 createTimeZone(const UnicodeString& ID); 00180 00196 static StringEnumeration* U_EXPORT2 createTimeZoneIDEnumeration( 00197 USystemTimeZoneType zoneType, 00198 const char* region, 00199 const int32_t* rawOffset, 00200 UErrorCode& ec); 00201 00202 #ifndef U_HIDE_DEPRECATED_API 00203 00210 static StringEnumeration* U_EXPORT2 createEnumeration(); 00211 #endif // U_HIDE_DEPRECATED_API 00212 00221 static StringEnumeration* U_EXPORT2 createEnumeration(UErrorCode& status); 00222 00223 #ifndef U_HIDE_DEPRECATED_API 00224 00241 static StringEnumeration* U_EXPORT2 createEnumeration(int32_t rawOffset); 00242 #endif // U_HIDE_DEPRECATED_API 00243 00262 static StringEnumeration* U_EXPORT2 createEnumerationForRawOffset(int32_t rawOffset, UErrorCode& status); 00263 00264 #ifndef U_HIDE_DEPRECATED_API 00265 00275 static StringEnumeration* U_EXPORT2 createEnumeration(const char* region); 00276 #endif // U_HIDE_DEPRECATED_API 00277 00289 static StringEnumeration* U_EXPORT2 createEnumerationForRegion(const char* region, UErrorCode& status); 00290 00305 static int32_t U_EXPORT2 countEquivalentIDs(const UnicodeString& id); 00306 00326 static const UnicodeString U_EXPORT2 getEquivalentID(const UnicodeString& id, 00327 int32_t index); 00328 00352 static TimeZone* U_EXPORT2 detectHostTimeZone(); 00353 00367 static TimeZone* U_EXPORT2 createDefault(void); 00368 00369 #ifndef U_HIDE_INTERNAL_API 00370 00379 static TimeZone* U_EXPORT2 forLocaleOrDefault(const Locale& locale); 00380 #endif /* U_HIDE_INTERNAL_API */ 00381 00391 static void U_EXPORT2 adoptDefault(TimeZone* zone); 00392 00393 #ifndef U_HIDE_SYSTEM_API 00394 00402 static void U_EXPORT2 setDefault(const TimeZone& zone); 00403 #endif /* U_HIDE_SYSTEM_API */ 00404 00411 static const char* U_EXPORT2 getTZDataVersion(UErrorCode& status); 00412 00426 static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id, 00427 UnicodeString& canonicalID, UErrorCode& status); 00428 00444 static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id, 00445 UnicodeString& canonicalID, UBool& isSystemID, UErrorCode& status); 00446 00469 static UnicodeString& U_EXPORT2 getWindowsID(const UnicodeString& id, 00470 UnicodeString& winid, UErrorCode& status); 00471 00498 static UnicodeString& U_EXPORT2 getIDForWindowsID(const UnicodeString& winid, const char* region, 00499 UnicodeString& id, UErrorCode& status); 00500 00510 virtual bool operator==(const TimeZone& that) const; 00511 00521 bool operator!=(const TimeZone& that) const {return !operator==(that);} 00522 00547 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 00548 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0; 00549 00570 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 00571 uint8_t dayOfWeek, int32_t milliseconds, 00572 int32_t monthLength, UErrorCode& status) const = 0; 00573 00597 virtual void getOffset(UDate date, UBool local, int32_t& rawOffset, 00598 int32_t& dstOffset, UErrorCode& ec) const; 00599 00607 virtual void setRawOffset(int32_t offsetMillis) = 0; 00608 00616 virtual int32_t getRawOffset(void) const = 0; 00617 00625 UnicodeString& getID(UnicodeString& ID) const; 00626 00640 void setID(const UnicodeString& ID); 00641 00646 enum EDisplayType { 00651 SHORT = 1, 00656 LONG, 00661 SHORT_GENERIC, 00666 LONG_GENERIC, 00672 SHORT_GMT, 00678 LONG_GMT, 00684 SHORT_COMMONLY_USED, 00690 GENERIC_LOCATION 00691 }; 00692 00704 UnicodeString& getDisplayName(UnicodeString& result) const; 00705 00719 UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const; 00720 00733 UnicodeString& getDisplayName(UBool inDaylight, EDisplayType style, UnicodeString& result) const; 00734 00749 UnicodeString& getDisplayName(UBool inDaylight, EDisplayType style, const Locale& locale, UnicodeString& result) const; 00750 00785 virtual UBool useDaylightTime(void) const = 0; 00786 00787 #ifndef U_FORCE_HIDE_DEPRECATED_API 00788 00801 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0; 00802 #endif // U_FORCE_HIDE_DEPRECATED_API 00803 00812 virtual UBool hasSameRules(const TimeZone& other) const; 00813 00821 virtual TimeZone* clone() const = 0; 00822 00829 static UClassID U_EXPORT2 getStaticClassID(void); 00830 00842 virtual UClassID getDynamicClassID(void) const override = 0; 00843 00859 virtual int32_t getDSTSavings() const; 00860 00878 static int32_t U_EXPORT2 getRegion(const UnicodeString& id, 00879 char *region, int32_t capacity, UErrorCode& status); 00880 00881 protected: 00882 00887 TimeZone(); 00888 00894 TimeZone(const UnicodeString &id); 00895 00901 TimeZone(const TimeZone& source); 00902 00908 TimeZone& operator=(const TimeZone& right); 00909 00910 #ifndef U_HIDE_INTERNAL_API 00911 00920 static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status); 00921 #endif /* U_HIDE_INTERNAL_API */ 00922 00923 private: 00924 friend class ZoneMeta; 00925 00926 00927 static TimeZone* createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string. 00928 00937 static const char16_t* findID(const UnicodeString& id); 00938 00947 static const char16_t* dereferOlsonLink(const UnicodeString& id); 00948 00955 static const char16_t* getRegion(const UnicodeString& id); 00956 00957 public: 00958 #ifndef U_HIDE_INTERNAL_API 00959 00967 static const char16_t* getRegion(const UnicodeString& id, UErrorCode& status); 00968 #endif /* U_HIDE_INTERNAL_API */ 00969 00970 private: 00981 static UBool parseCustomID(const UnicodeString& id, int32_t& sign, int32_t& hour, 00982 int32_t& minute, int32_t& second); 00983 00994 static UnicodeString& getCustomID(const UnicodeString& id, UnicodeString& normalized, 00995 UErrorCode& status); 00996 01006 static UnicodeString& formatCustomID(int32_t hour, int32_t min, int32_t sec, 01007 UBool negative, UnicodeString& id); 01008 01009 UnicodeString fID; // this time zone's ID 01010 01011 friend class TZEnumeration; 01012 }; 01013 01014 01015 // ------------------------------------- 01016 01017 inline UnicodeString& 01018 TimeZone::getID(UnicodeString& ID) const 01019 { 01020 ID = fID; 01021 return ID; 01022 } 01023 01024 // ------------------------------------- 01025 01026 inline void 01027 TimeZone::setID(const UnicodeString& ID) 01028 { 01029 fID = ID; 01030 } 01031 U_NAMESPACE_END 01032 01033 #endif /* #if !UCONFIG_NO_FORMATTING */ 01034 01035 #endif /* U_SHOW_CPLUSPLUS_API */ 01036 01037 #endif //_TIMEZONE 01038 //eof
1.7.6.1