timezone.h

Go to the documentation of this file.
00001 /*************************************************************************
00002 * Copyright (c) 1997-2008, 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 
00349     static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,
00350         UnicodeString& canonicalID, UErrorCode& status);
00351 
00367     static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,
00368         UnicodeString& canonicalID, UBool& isSystemID, UErrorCode& status);
00369 
00379     virtual UBool operator==(const TimeZone& that) const;
00380 
00390     UBool operator!=(const TimeZone& that) const {return !operator==(that);}
00391 
00416     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00417                               uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
00418 
00439     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00440                            uint8_t dayOfWeek, int32_t milliseconds,
00441                            int32_t monthLength, UErrorCode& status) const = 0;
00442 
00466     virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
00467                            int32_t& dstOffset, UErrorCode& ec) const;
00468 
00476     virtual void setRawOffset(int32_t offsetMillis) = 0;
00477 
00485     virtual int32_t getRawOffset(void) const = 0;
00486 
00494     UnicodeString& getID(UnicodeString& ID) const;
00495 
00509     void setID(const UnicodeString& ID);
00510 
00515     enum EDisplayType {
00520         SHORT = 1,
00525         LONG
00526     };
00527 
00539     UnicodeString& getDisplayName(UnicodeString& result) const;
00540 
00554     UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
00555 
00568     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
00569 
00584     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
00585 
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 
00666 protected:
00667 
00672     TimeZone();
00673 
00679     TimeZone(const UnicodeString &id);
00680 
00686     TimeZone(const TimeZone& source);
00687 
00693     TimeZone& operator=(const TimeZone& right);
00694 
00704     static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status);
00705 
00706 private:
00707     friend class ZoneMeta;
00708 
00709 
00710     static TimeZone*        createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.
00711 
00721     static UnicodeString& dereferOlsonLink(const UnicodeString& linkTo, UnicodeString& linkFrom);
00722 
00733     static UBool parseCustomID(const UnicodeString& id, int32_t& sign, int32_t& hour,
00734         int32_t& min, int32_t& sec);
00735 
00746     static UnicodeString& getCustomID(const UnicodeString& id, UnicodeString& normalized,
00747         UErrorCode& status);
00748 
00758     static UnicodeString& formatCustomID(int32_t hour, int32_t min, int32_t sec,
00759         UBool negative, UnicodeString& id);
00760 
00766     static void             initDefault(void);
00767 
00768     // See source file for documentation
00776     static TimeZone*        createSystemTimeZone(const UnicodeString& name);
00777 
00778     UnicodeString           fID;    // this time zone's ID
00779 };
00780 
00781 
00782 // -------------------------------------
00783 
00784 inline UnicodeString&
00785 TimeZone::getID(UnicodeString& ID) const
00786 {
00787     ID = fID;
00788     return ID;
00789 }
00790 
00791 // -------------------------------------
00792 
00793 inline void
00794 TimeZone::setID(const UnicodeString& ID)
00795 {
00796     fID = ID;
00797 }
00798 U_NAMESPACE_END
00799 
00800 #endif /* #if !UCONFIG_NO_FORMATTING */
00801 
00802 #endif //_TIMEZONE
00803 //eof

Generated on Sun Aug 22 15:37:58 2010 for ICU 4.0.1 by  doxygen 1.3.9.1