Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

timezone.h

00001 /*
00002 * Copyright (C) {1997-2003}, 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 
00031 #if !UCONFIG_NO_FORMATTING
00032 
00033 #include "unicode/uobject.h"
00034 #include "unicode/unistr.h"
00035 
00036 U_NAMESPACE_BEGIN
00037 
00038 class StringEnumeration;
00039 
00112 class U_I18N_API TimeZone : public UObject {
00113 public:
00117     virtual ~TimeZone();
00118 
00125     static const TimeZone* getGMT(void);
00126 
00138     static TimeZone* createTimeZone(const UnicodeString& ID);
00139 
00147     static StringEnumeration* createEnumeration();
00148 
00166     static StringEnumeration* createEnumeration(int32_t rawOffset);
00167 
00178     static StringEnumeration* createEnumeration(const char* country);
00179 
00203     static const UnicodeString** createAvailableIDs(int32_t rawOffset, int32_t& numIDs);
00204 
00226     static const UnicodeString** createAvailableIDs(const char* country,
00227                                                           int32_t& numIDs);
00228 
00242     static const UnicodeString** createAvailableIDs(int32_t& numIDs);
00243 
00258     static int32_t countEquivalentIDs(const UnicodeString& id);
00259 
00279     static const UnicodeString getEquivalentID(const UnicodeString& id,
00280                                                int32_t index);
00281 
00294     static TimeZone* createDefault(void);
00295 
00305     static void adoptDefault(TimeZone* zone);
00306 
00314     static void setDefault(const TimeZone& zone);
00315 
00325     virtual UBool operator==(const TimeZone& that) const;
00326 
00336     UBool operator!=(const TimeZone& that) const {return !operator==(that);}
00337 
00358     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00359                               uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
00360 
00376     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00377                            uint8_t dayOfWeek, int32_t milliseconds,
00378                            int32_t monthLength, UErrorCode& status) const = 0;
00379 
00387     virtual void setRawOffset(int32_t offsetMillis) = 0;
00388 
00396     virtual int32_t getRawOffset(void) const = 0;
00397 
00405     UnicodeString& getID(UnicodeString& ID) const;
00406 
00420     void setID(const UnicodeString& ID);
00421 
00426     enum EDisplayType {
00431         SHORT = 1,
00436         LONG
00437     };
00438 
00450     UnicodeString& getDisplayName(UnicodeString& result) const;
00451 
00465     UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
00466 
00479     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
00480 
00495     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
00496 
00503     virtual UBool useDaylightTime(void) const = 0;
00504 
00518     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
00519 
00528     virtual UBool hasSameRules(const TimeZone& other) const;
00529 
00537     virtual TimeZone* clone(void) const = 0;
00538 
00550     static inline UClassID getStaticClassID(void);
00551 
00567     virtual UClassID getDynamicClassID(void) const = 0;
00568 
00569 protected:
00570 
00575     TimeZone();
00576 
00582     TimeZone(const UnicodeString &id);
00583 
00589     TimeZone(const TimeZone& source);
00590 
00596     TimeZone& operator=(const TimeZone& right);
00597 
00598 private:
00599     static const char fgClassID;
00600 
00601     static TimeZone*        createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.
00602 
00608     static void             initDefault(void);
00609 
00610     // See source file for documentation
00618     static TimeZone*        createSystemTimeZone(const UnicodeString& name);
00619 
00620     UnicodeString           fID;    // this time zone's ID
00621 };
00622 
00623 
00624 inline UClassID
00625 TimeZone::getStaticClassID(void)
00626 { return (UClassID)&fgClassID; }
00627 
00628 // -------------------------------------
00629 
00630 inline UnicodeString&
00631 TimeZone::getID(UnicodeString& ID) const
00632 {
00633     ID = fID;
00634     return ID;
00635 }
00636 
00637 // -------------------------------------
00638 
00639 inline void
00640 TimeZone::setID(const UnicodeString& ID)
00641 {
00642     fID = ID;
00643 }
00644 U_NAMESPACE_END
00645 
00646 #endif /* #if !UCONFIG_NO_FORMATTING */
00647 
00648 #endif //_TIMEZONE
00649 //eof

Generated on Wed Sep 3 17:47:09 2003 for ICU 2.6 by doxygen 1.3.2