Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

timezone.h

Go to the documentation of this file.
00001 /*
00002 * Copyright (C) {1997-2001}, 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 ********************************************************************************
00023 */
00024 
00025 #ifndef TIMEZONE_H
00026 #define TIMEZONE_H
00027 
00028 
00029 #include "unicode/unistr.h"
00030 #include "unicode/locid.h"
00031 
00032 #include "unicode/udata.h"
00033 
00034 class SimpleTimeZone;
00035 struct TZHeader;
00036 struct OffsetIndex;
00037 struct CountryIndex;
00038 struct TZEquivalencyGroup;
00039 
00114 class U_I18N_API TimeZone {
00115 public:
00119     virtual ~TimeZone();
00120 
00125     static const TimeZone* GMT;
00126 
00138     static TimeZone* createTimeZone(const UnicodeString& ID);
00139 
00161     static const UnicodeString** const createAvailableIDs(int32_t rawOffset, int32_t& numIDs);
00162 
00181     static const UnicodeString** const createAvailableIDs(const char* country,
00182                                                           int32_t& numIDs);
00183 
00195     static const UnicodeString** const createAvailableIDs(int32_t& numIDs);
00196 
00211     static int32_t countEquivalentIDs(const UnicodeString& id);
00212 
00232     static const UnicodeString getEquivalentID(const UnicodeString& id,
00233                                                int32_t index);
00234 
00247     static TimeZone* createDefault(void);
00248 
00258     static void adoptDefault(TimeZone* zone);
00259 
00267     static void setDefault(const TimeZone& zone);
00268 
00278     virtual UBool operator==(const TimeZone& that) const;
00279 
00289     UBool operator!=(const TimeZone& that) const {return !operator==(that);}
00290 
00310     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00311                               uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
00315     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00316                               uint8_t dayOfWeek, int32_t millis) const = 0;
00317 
00332     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00333                            uint8_t dayOfWeek, int32_t milliseconds,
00334                            int32_t monthLength, UErrorCode& status) const = 0;
00335 
00343     virtual void setRawOffset(int32_t offsetMillis) = 0;
00344 
00352     virtual int32_t getRawOffset(void) const = 0;
00353 
00361     UnicodeString& getID(UnicodeString& ID) const;
00362 
00376     void setID(const UnicodeString& ID);
00377 
00382     enum EDisplayType {
00383         SHORT = 1,
00384         LONG
00385     };
00386 
00397     UnicodeString& getDisplayName(UnicodeString& result) const;
00398 
00411     UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
00412 
00424     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
00425 
00439     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
00440 
00447     virtual UBool useDaylightTime(void) const = 0;
00448 
00457     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
00458 
00467     virtual UBool hasSameRules(const TimeZone& other) const;
00468 
00476     virtual TimeZone* clone(void) const = 0;
00477 
00489     static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00490 
00506     virtual UClassID getDynamicClassID(void) const = 0;
00507 
00508 protected:
00509 
00514     TimeZone();
00515 
00520     TimeZone(const TimeZone& source);
00521 
00526     TimeZone& operator=(const TimeZone& right);
00527 
00528 private:
00529     static char fgClassID;
00530 
00531     static TimeZone*        createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.
00532 
00533     static TimeZone*        fgDefaultZone; // default time zone (lazy evaluated)
00534 
00535     static const UnicodeString      GMT_ID;
00536     static const int32_t            GMT_ID_LENGTH;
00537     static const UnicodeString      CUSTOM_ID;
00538 
00540     // Pointers into memory-mapped icudata.  Writing to this memory
00541     // will segfault!  See tzdat.h for more details.
00543 
00549     static const TZHeader *    DATA;
00550 
00555     static const uint32_t*     INDEX_BY_ID;
00556 
00562     static const OffsetIndex*  INDEX_BY_OFFSET;
00563 
00569     static const CountryIndex* INDEX_BY_COUNTRY;
00570 
00572     // Other system zone data structures
00574 
00579     static UnicodeString*      ZONE_IDS;
00580 
00587     static UBool              DATA_LOADED;
00588     static UDataMemory*       UDATA_POINTER;
00589 
00595     static UMTX                LOCK;
00596 
00602     static void             initDefault(void);
00603 
00604     // See source file for documentation
00605     static void   loadZoneData(void);
00606 
00607     // See source file for documentation
00608     static UBool U_CALLCONV isDataAcceptable(void *context,
00609                                    const char *type, const char *name,
00610                                    const UDataInfo *pInfo);
00611 
00612     // See source file for documentation
00613     static TimeZone* createSystemTimeZone(const UnicodeString& name);
00614 
00615     // See source file for documentation
00616     static const TZEquivalencyGroup* lookupEquivalencyGroup(const UnicodeString& id);
00617 
00618     UnicodeString           fID;    // this time zone's ID
00619 };
00620 
00621 
00622 // -------------------------------------
00623 
00624 inline UnicodeString&
00625 TimeZone::getID(UnicodeString& ID) const
00626 {
00627     ID = fID;
00628     return ID;
00629 }
00630 
00631 // -------------------------------------
00632 
00633 inline void
00634 TimeZone::setID(const UnicodeString& ID)
00635 {
00636     fID = ID;
00637 }
00638 
00639 #endif //_TIMEZONE
00640 //eof

Generated at Thu Mar 22 16:12:38 2001 for ICU 1.8 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000