timezone.h

Go to the documentation of this file.
00001 /*
00002 * Copyright (C) {1997-2005}, International Business Machines Corporation and others. All Rights Reserved.
00003 ********************************************************************************
00004 *
00005 * File TIMEZONE.H
00006 *
00007 * Modification History:
00008 *
00009 *   Date        Name        Description
00010 *   04/21/97    aliu        Overhauled header.
00011 *   07/09/97    helena      Changed createInstance to createDefault.
00012 *   08/06/97    aliu        Removed dependency on internal header for Hashtable.
00013 *   08/10/98    stephen        Changed getDisplayName() API conventions to match
00014 *   08/19/98    stephen        Changed createTimeZone() to never return 0
00015 *   09/02/98    stephen        Sync to JDK 1.2 8/31
00016 *                            - Added getOffset(... monthlen ...)
00017 *                            - Added hasSameRules()
00018 *   09/15/98    stephen        Added getStaticClassID
00019 *   12/03/99    aliu        Moved data out of static table into icudata.dll.
00020 *                           Hashtable replaced by new static data structures.
00021 *   12/14/99    aliu        Made GMT public.
00022 *   08/15/01    grhoten     Made GMT private and added the getGMT() function
00023 ********************************************************************************
00024 */
00025 
00026 #ifndef TIMEZONE_H
00027 #define TIMEZONE_H
00028 
00029 #include "unicode/utypes.h"
00030 
00036 #if !UCONFIG_NO_FORMATTING
00037 
00038 #include "unicode/uobject.h"
00039 #include "unicode/unistr.h"
00040 #include "unicode/ures.h"
00041 
00042 U_NAMESPACE_BEGIN
00043 
00044 class StringEnumeration;
00045 
00121 class U_I18N_API TimeZone : public UObject {
00122 public:
00126     virtual ~TimeZone();
00127 
00134     static const TimeZone* U_EXPORT2 getGMT(void);
00135 
00147     static TimeZone* U_EXPORT2 createTimeZone(const UnicodeString& ID);
00148 
00156     static StringEnumeration* U_EXPORT2 createEnumeration();
00157 
00175     static StringEnumeration* U_EXPORT2 createEnumeration(int32_t rawOffset);
00176 
00187     static StringEnumeration* U_EXPORT2 createEnumeration(const char* country);
00188 
00189 #ifdef U_USE_TIMEZONE_OBSOLETE_2_8
00190 
00213     static const UnicodeString** createAvailableIDs(int32_t rawOffset, int32_t& numIDs);
00214 
00236     static const UnicodeString** createAvailableIDs(const char* country,
00237                                                           int32_t& numIDs);
00238 
00252     static const UnicodeString** createAvailableIDs(int32_t& numIDs);
00253 #endif
00254 
00269     static int32_t U_EXPORT2 countEquivalentIDs(const UnicodeString& id);
00270 
00290     static const UnicodeString U_EXPORT2 getEquivalentID(const UnicodeString& id,
00291                                                int32_t index);
00292 
00305     static TimeZone* U_EXPORT2 createDefault(void);
00306 
00316     static void U_EXPORT2 adoptDefault(TimeZone* zone);
00317 
00325     static void U_EXPORT2 setDefault(const TimeZone& zone);
00326 
00336     virtual UBool operator==(const TimeZone& that) const;
00337 
00347     UBool operator!=(const TimeZone& that) const {return !operator==(that);}
00348 
00373     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00374                               uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
00375 
00396     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00397                            uint8_t dayOfWeek, int32_t milliseconds,
00398                            int32_t monthLength, UErrorCode& status) const = 0;
00399 
00423     virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
00424                            int32_t& dstOffset, UErrorCode& ec) const;
00425 
00433     virtual void setRawOffset(int32_t offsetMillis) = 0;
00434 
00442     virtual int32_t getRawOffset(void) const = 0;
00443 
00451     UnicodeString& getID(UnicodeString& ID) const;
00452 
00466     void setID(const UnicodeString& ID);
00467 
00472     enum EDisplayType {
00477         SHORT = 1,
00482         LONG
00483     };
00484 
00496     UnicodeString& getDisplayName(UnicodeString& result) const;
00497 
00511     UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
00512 
00525     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
00526 
00541     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
00542 
00549     virtual UBool useDaylightTime(void) const = 0;
00550 
00564     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
00565 
00574     virtual UBool hasSameRules(const TimeZone& other) const;
00575 
00583     virtual TimeZone* clone(void) const = 0;
00584 
00591     static UClassID U_EXPORT2 getStaticClassID(void);
00592 
00604     virtual UClassID getDynamicClassID(void) const = 0;
00605     
00621     virtual int32_t getDSTSavings() const;
00622 protected:
00623 
00628     TimeZone();
00629 
00635     TimeZone(const UnicodeString &id);
00636 
00642     TimeZone(const TimeZone& source);
00643 
00649     TimeZone& operator=(const TimeZone& right);
00650 
00660     static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status);
00661 
00662 private:
00663     static TimeZone*        createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.
00664 
00670     static void             initDefault(void);
00671 
00672     // See source file for documentation
00680     static TimeZone*        createSystemTimeZone(const UnicodeString& name);
00681 
00682     UnicodeString           fID;    // this time zone's ID
00683 };
00684 
00685 
00686 // -------------------------------------
00687 
00688 inline UnicodeString&
00689 TimeZone::getID(UnicodeString& ID) const
00690 {
00691     ID = fID;
00692     return ID;
00693 }
00694 
00695 // -------------------------------------
00696 
00697 inline void
00698 TimeZone::setID(const UnicodeString& ID)
00699 {
00700     fID = ID;
00701 }
00702 U_NAMESPACE_END
00703 
00704 #endif /* #if !UCONFIG_NO_FORMATTING */
00705 
00706 #endif //_TIMEZONE
00707 //eof

Generated on Mon Aug 13 07:17:24 2007 for ICU 3.6 by  doxygen 1.5.2