timezone.h

Go to the documentation of this file.
00001 /*************************************************************************
00002 * Copyright (c) 1997-2007, 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 
00043 U_NAMESPACE_BEGIN
00044 
00045 class StringEnumeration;
00046 
00122 class U_I18N_API TimeZone : public UObject {
00123 public:
00127     virtual ~TimeZone();
00128 
00135     static const TimeZone* U_EXPORT2 getGMT(void);
00136 
00148     static TimeZone* U_EXPORT2 createTimeZone(const UnicodeString& ID);
00149 
00157     static StringEnumeration* U_EXPORT2 createEnumeration();
00158 
00176     static StringEnumeration* U_EXPORT2 createEnumeration(int32_t rawOffset);
00177 
00188     static StringEnumeration* U_EXPORT2 createEnumeration(const char* country);
00189 
00190 #ifdef U_USE_TIMEZONE_OBSOLETE_2_8
00191 
00214     static const UnicodeString** createAvailableIDs(int32_t rawOffset, int32_t& numIDs);
00215 
00237     static const UnicodeString** createAvailableIDs(const char* country,
00238                                                           int32_t& numIDs);
00239 
00253     static const UnicodeString** createAvailableIDs(int32_t& numIDs);
00254 #endif
00255 
00270     static int32_t U_EXPORT2 countEquivalentIDs(const UnicodeString& id);
00271 
00291     static const UnicodeString U_EXPORT2 getEquivalentID(const UnicodeString& id,
00292                                                int32_t index);
00293 
00306     static TimeZone* U_EXPORT2 createDefault(void);
00307 
00317     static void U_EXPORT2 adoptDefault(TimeZone* zone);
00318 
00326     static void U_EXPORT2 setDefault(const TimeZone& zone);
00327 
00334     static const char* U_EXPORT2 getTZDataVersion(UErrorCode& status);
00335 
00345     virtual UBool operator==(const TimeZone& that) const;
00346 
00356     UBool operator!=(const TimeZone& that) const {return !operator==(that);}
00357 
00382     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00383                               uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
00384 
00405     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00406                            uint8_t dayOfWeek, int32_t milliseconds,
00407                            int32_t monthLength, UErrorCode& status) const = 0;
00408 
00432     virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
00433                            int32_t& dstOffset, UErrorCode& ec) const;
00434 
00442     virtual void setRawOffset(int32_t offsetMillis) = 0;
00443 
00451     virtual int32_t getRawOffset(void) const = 0;
00452 
00460     UnicodeString& getID(UnicodeString& ID) const;
00461 
00475     void setID(const UnicodeString& ID);
00476 
00481     enum EDisplayType {
00486         SHORT = 1,
00491         LONG
00492     };
00493 
00505     UnicodeString& getDisplayName(UnicodeString& result) const;
00506 
00520     UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
00521 
00534     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
00535 
00550     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
00551 
00558     virtual UBool useDaylightTime(void) const = 0;
00559 
00573     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
00574 
00583     virtual UBool hasSameRules(const TimeZone& other) const;
00584 
00592     virtual TimeZone* clone(void) const = 0;
00593 
00600     static UClassID U_EXPORT2 getStaticClassID(void);
00601 
00613     virtual UClassID getDynamicClassID(void) const = 0;
00614     
00630     virtual int32_t getDSTSavings() const;
00631 
00632 protected:
00633 
00638     TimeZone();
00639 
00645     TimeZone(const UnicodeString &id);
00646 
00652     TimeZone(const TimeZone& source);
00653 
00659     TimeZone& operator=(const TimeZone& right);
00660 
00670     static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status);
00671 
00672 private:
00673     static TimeZone*        createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.
00674 
00680     static void             initDefault(void);
00681 
00682     // See source file for documentation
00690     static TimeZone*        createSystemTimeZone(const UnicodeString& name);
00691 
00692     UnicodeString           fID;    // this time zone's ID
00693 };
00694 
00695 
00696 // -------------------------------------
00697 
00698 inline UnicodeString&
00699 TimeZone::getID(UnicodeString& ID) const
00700 {
00701     ID = fID;
00702     return ID;
00703 }
00704 
00705 // -------------------------------------
00706 
00707 inline void
00708 TimeZone::setID(const UnicodeString& ID)
00709 {
00710     fID = ID;
00711 }
00712 U_NAMESPACE_END
00713 
00714 #endif /* #if !UCONFIG_NO_FORMATTING */
00715 
00716 #endif //_TIMEZONE
00717 //eof

Generated on Fri Sep 14 12:59:20 2007 for ICU 3.8 by  doxygen 1.5.1