ICU 49.1.1
49.1.1
|
00001 /************************************************************************* 00002 * Copyright (c) 1997-2012, 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 00129 class U_I18N_API TimeZone : public UObject { 00130 public: 00134 virtual ~TimeZone(); 00135 00136 #ifndef U_HIDE_DRAFT_API 00137 00149 static const TimeZone& U_EXPORT2 getUnknown(); 00150 #endif /* U_HIDE_DRAFT_API */ 00151 00164 static const TimeZone* U_EXPORT2 getGMT(void); 00165 00177 static TimeZone* U_EXPORT2 createTimeZone(const UnicodeString& ID); 00178 00194 static StringEnumeration* U_EXPORT2 createTimeZoneIDEnumeration( 00195 USystemTimeZoneType zoneType, 00196 const char* region, 00197 const int32_t* rawOffset, 00198 UErrorCode& ec); 00199 00207 static StringEnumeration* U_EXPORT2 createEnumeration(); 00208 00226 static StringEnumeration* U_EXPORT2 createEnumeration(int32_t rawOffset); 00227 00238 static StringEnumeration* U_EXPORT2 createEnumeration(const char* country); 00239 00254 static int32_t U_EXPORT2 countEquivalentIDs(const UnicodeString& id); 00255 00275 static const UnicodeString U_EXPORT2 getEquivalentID(const UnicodeString& id, 00276 int32_t index); 00277 00290 static TimeZone* U_EXPORT2 createDefault(void); 00291 00301 static void U_EXPORT2 adoptDefault(TimeZone* zone); 00302 00303 #ifndef U_HIDE_SYSTEM_API 00304 00312 static void U_EXPORT2 setDefault(const TimeZone& zone); 00313 #endif /* U_HIDE_SYSTEM_API */ 00314 00321 static const char* U_EXPORT2 getTZDataVersion(UErrorCode& status); 00322 00336 static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id, 00337 UnicodeString& canonicalID, UErrorCode& status); 00338 00354 static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id, 00355 UnicodeString& canonicalID, UBool& isSystemID, UErrorCode& status); 00356 00366 virtual UBool operator==(const TimeZone& that) const; 00367 00377 UBool operator!=(const TimeZone& that) const {return !operator==(that);} 00378 00403 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 00404 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0; 00405 00426 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, 00427 uint8_t dayOfWeek, int32_t milliseconds, 00428 int32_t monthLength, UErrorCode& status) const = 0; 00429 00453 virtual void getOffset(UDate date, UBool local, int32_t& rawOffset, 00454 int32_t& dstOffset, UErrorCode& ec) const; 00455 00463 virtual void setRawOffset(int32_t offsetMillis) = 0; 00464 00472 virtual int32_t getRawOffset(void) const = 0; 00473 00481 UnicodeString& getID(UnicodeString& ID) const; 00482 00496 void setID(const UnicodeString& ID); 00497 00502 enum EDisplayType { 00507 SHORT = 1, 00512 LONG, 00517 SHORT_GENERIC, 00522 LONG_GENERIC, 00528 SHORT_GMT, 00534 LONG_GMT, 00540 SHORT_COMMONLY_USED, 00546 GENERIC_LOCATION 00547 }; 00548 00560 UnicodeString& getDisplayName(UnicodeString& result) const; 00561 00575 UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const; 00576 00589 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const; 00590 00605 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const; 00606 00641 virtual UBool useDaylightTime(void) const = 0; 00642 00656 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0; 00657 00666 virtual UBool hasSameRules(const TimeZone& other) const; 00667 00675 virtual TimeZone* clone(void) const = 0; 00676 00683 static UClassID U_EXPORT2 getStaticClassID(void); 00684 00696 virtual UClassID getDynamicClassID(void) const = 0; 00697 00713 virtual int32_t getDSTSavings() const; 00714 00732 static int32_t U_EXPORT2 getRegion(const UnicodeString& id, 00733 char *region, int32_t capacity, UErrorCode& status); 00734 00735 protected: 00736 00741 TimeZone(); 00742 00748 TimeZone(const UnicodeString &id); 00749 00755 TimeZone(const TimeZone& source); 00756 00762 TimeZone& operator=(const TimeZone& right); 00763 00764 #ifndef U_HIDE_INTERNAL_API 00765 00774 static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status); 00775 #endif /* U_HIDE_INTERNAL_API */ 00776 00777 private: 00778 friend class ZoneMeta; 00779 00780 00781 static TimeZone* createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string. 00782 00791 static const UChar* findID(const UnicodeString& id); 00792 00801 static const UChar* dereferOlsonLink(const UnicodeString& id); 00802 00809 static const UChar* getRegion(const UnicodeString& id); 00810 00818 static const UChar* getRegion(const UnicodeString& id, UErrorCode& status); 00819 00830 static UBool parseCustomID(const UnicodeString& id, int32_t& sign, int32_t& hour, 00831 int32_t& minute, int32_t& second); 00832 00843 static UnicodeString& getCustomID(const UnicodeString& id, UnicodeString& normalized, 00844 UErrorCode& status); 00845 00855 static UnicodeString& formatCustomID(int32_t hour, int32_t min, int32_t sec, 00856 UBool negative, UnicodeString& id); 00857 00863 static void initDefault(void); 00864 00865 // See source file for documentation 00873 static TimeZone* createSystemTimeZone(const UnicodeString& name); 00874 static TimeZone* createSystemTimeZone(const UnicodeString& name, UErrorCode& ec); 00875 00876 UnicodeString fID; // this time zone's ID 00877 00878 friend class TZEnumeration; 00879 }; 00880 00881 00882 // ------------------------------------- 00883 00884 inline UnicodeString& 00885 TimeZone::getID(UnicodeString& ID) const 00886 { 00887 ID = fID; 00888 return ID; 00889 } 00890 00891 // ------------------------------------- 00892 00893 inline void 00894 TimeZone::setID(const UnicodeString& ID) 00895 { 00896 fID = ID; 00897 } 00898 U_NAMESPACE_END 00899 00900 #endif /* #if !UCONFIG_NO_FORMATTING */ 00901 00902 #endif //_TIMEZONE 00903 //eof