Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | 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 #include "unicode/ures.h"
00036 
00037 U_NAMESPACE_BEGIN
00038 
00039 class StringEnumeration;
00040 
00113 class U_I18N_API TimeZone : public UObject {
00114 public:
00118     virtual ~TimeZone();
00119 
00126     static const TimeZone* getGMT(void);
00127 
00139     static TimeZone* createTimeZone(const UnicodeString& ID);
00140 
00148     static StringEnumeration* createEnumeration();
00149 
00167     static StringEnumeration* createEnumeration(int32_t rawOffset);
00168 
00179     static StringEnumeration* createEnumeration(const char* country);
00180 
00181 #ifdef U_USE_TIMEZONE_OBSOLETE_2_8
00182 
00205     static const UnicodeString** createAvailableIDs(int32_t rawOffset, int32_t& numIDs);
00206 
00228     static const UnicodeString** createAvailableIDs(const char* country,
00229                                                           int32_t& numIDs);
00230 
00244     static const UnicodeString** createAvailableIDs(int32_t& numIDs);
00245 #endif
00246 
00261     static int32_t countEquivalentIDs(const UnicodeString& id);
00262 
00282     static const UnicodeString getEquivalentID(const UnicodeString& id,
00283                                                int32_t index);
00284 
00297     static TimeZone* createDefault(void);
00298 
00308     static void adoptDefault(TimeZone* zone);
00309 
00317     static void setDefault(const TimeZone& zone);
00318 
00328     virtual UBool operator==(const TimeZone& that) const;
00329 
00339     UBool operator!=(const TimeZone& that) const {return !operator==(that);}
00340 
00365     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00366                               uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
00367 
00388     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00389                            uint8_t dayOfWeek, int32_t milliseconds,
00390                            int32_t monthLength, UErrorCode& status) const = 0;
00391 
00415     virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
00416                            int32_t& dstOffset, UErrorCode& ec) const;
00417 
00425     virtual void setRawOffset(int32_t offsetMillis) = 0;
00426 
00434     virtual int32_t getRawOffset(void) const = 0;
00435 
00443     UnicodeString& getID(UnicodeString& ID) const;
00444 
00458     void setID(const UnicodeString& ID);
00459 
00464     enum EDisplayType {
00469         SHORT = 1,
00474         LONG
00475     };
00476 
00488     UnicodeString& getDisplayName(UnicodeString& result) const;
00489 
00503     UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
00504 
00517     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
00518 
00533     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
00534 
00541     virtual UBool useDaylightTime(void) const = 0;
00542 
00556     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
00557 
00566     virtual UBool hasSameRules(const TimeZone& other) const;
00567 
00575     virtual TimeZone* clone(void) const = 0;
00576 
00592     virtual UClassID getDynamicClassID(void) const = 0;
00593 
00594 protected:
00595 
00600     TimeZone();
00601 
00607     TimeZone(const UnicodeString &id);
00608 
00614     TimeZone(const TimeZone& source);
00615 
00621     TimeZone& operator=(const TimeZone& right);
00622 
00632     static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status);
00633 
00634 private:
00635     static TimeZone*        createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.
00636 
00642     static void             initDefault(void);
00643 
00644     // See source file for documentation
00652     static TimeZone*        createSystemTimeZone(const UnicodeString& name);
00653 
00654     UnicodeString           fID;    // this time zone's ID
00655 };
00656 
00657 
00658 // -------------------------------------
00659 
00660 inline UnicodeString&
00661 TimeZone::getID(UnicodeString& ID) const
00662 {
00663     ID = fID;
00664     return ID;
00665 }
00666 
00667 // -------------------------------------
00668 
00669 inline void
00670 TimeZone::setID(const UnicodeString& ID)
00671 {
00672     fID = ID;
00673 }
00674 U_NAMESPACE_END
00675 
00676 #endif /* #if !UCONFIG_NO_FORMATTING */
00677 
00678 #endif //_TIMEZONE
00679 //eof

Generated on Wed May 18 17:29:14 2005 for ICU 2.8 by  doxygen 1.4.2