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 © {1997-1999}, 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 TZEquivalencyGroup;
00038   
00113 class U_I18N_API TimeZone {
00114 public:
00118     virtual ~TimeZone();
00119 
00124     static const TimeZone* GMT;
00125 
00137     static TimeZone* createTimeZone(const UnicodeString& ID);
00138 
00160     static const UnicodeString** const createAvailableIDs(int32_t rawOffset, int32_t& numIDs);
00161 
00173     static const UnicodeString** const createAvailableIDs(int32_t& numIDs);
00174 
00189     static int32_t countEquivalentIDs(const UnicodeString& id);
00190 
00210     static const UnicodeString getEquivalentID(const UnicodeString& id,
00211                                                int32_t index);
00212 
00225     static TimeZone* createDefault(void);
00226 
00236     static void adoptDefault(TimeZone* zone);
00237 
00245     static void setDefault(const TimeZone& zone);
00246 
00256     virtual UBool operator==(const TimeZone& that) const;
00257 
00267     UBool operator!=(const TimeZone& that) const {return !operator==(that);}
00268 
00288     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00289                               uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
00293     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00294                               uint8_t dayOfWeek, int32_t millis) const = 0;
00295 
00310     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
00311                            uint8_t dayOfWeek, int32_t milliseconds, 
00312                            int32_t monthLength, UErrorCode& status) const = 0;
00313 
00321     virtual void setRawOffset(int32_t offsetMillis) = 0;
00322 
00330     virtual int32_t getRawOffset(void) const = 0;
00331 
00339     UnicodeString& getID(UnicodeString& ID) const;
00340 
00354     void setID(const UnicodeString& ID);
00355 
00360     enum EDisplayType { 
00361         SHORT = 1,
00362         LONG 
00363     };
00364 
00375     UnicodeString& getDisplayName(UnicodeString& result) const;
00376 
00389     UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
00390 
00402     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
00403 
00417     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
00418 
00425     virtual UBool useDaylightTime(void) const = 0;
00426 
00435     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
00436 
00445     virtual UBool hasSameRules(const TimeZone& other) const;
00446 
00454     virtual TimeZone* clone(void) const = 0;
00455 
00467     static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00468 
00484     virtual UClassID getDynamicClassID(void) const = 0;
00485 
00486 protected:
00487 
00492     TimeZone();
00493 
00498     TimeZone(const TimeZone& source);
00499 
00504     TimeZone& operator=(const TimeZone& right);
00505 
00506 private:
00507     static char fgClassID;
00508 
00509     static TimeZone*        createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.
00510 
00511     static TimeZone*        fgDefaultZone; // default time zone (lazy evaluated)
00512 
00513     static const UnicodeString      GMT_ID;
00514     static const int32_t            GMT_ID_LENGTH;
00515     static const UnicodeString      CUSTOM_ID;
00516 
00518     // Pointers into memory-mapped icudata.  Writing to this memory
00519     // will segfault!  See tzdat.h for more details.
00521 
00527     static const TZHeader *    DATA;
00528 
00533     static const uint32_t*     INDEX_BY_ID;
00534 
00540     static const OffsetIndex*  INDEX_BY_OFFSET;
00541 
00543     // Other system zone data structures
00545 
00550     static UnicodeString*      ZONE_IDS;
00551 
00558     static UBool              DATA_LOADED;
00559     static UDataMemory*       UDATA_POINTER;
00560 
00566     static UMTX                LOCK;    
00567 
00573     static void             initDefault(void);
00574 
00575     // See source file for documentation
00576     static void   loadZoneData(void);
00577 
00578     // See source file for documentation
00579     static UBool U_CALLCONV isDataAcceptable(void *context,
00580                                    const char *type, const char *name,
00581                                    const UDataInfo *pInfo);
00582 
00583     // See source file for documentation
00584     static TimeZone* createSystemTimeZone(const UnicodeString& name);
00585 
00586     // See source file for documentation
00587     static const TZEquivalencyGroup* lookupEquivalencyGroup(const UnicodeString& id);
00588 
00589     UnicodeString           fID;    // this time zone's ID
00590 };
00591 
00592 
00593 // -------------------------------------
00594 
00595 inline UnicodeString&
00596 TimeZone::getID(UnicodeString& ID) const
00597 {
00598     ID = fID;
00599     return ID;
00600 }
00601 
00602 // -------------------------------------
00603 
00604 inline void
00605 TimeZone::setID(const UnicodeString& ID)
00606 {
00607     fID = ID;
00608 }
00609 
00610 #endif //_TIMEZONE
00611 //eof

Generated at Fri Dec 15 12:12:35 2000 for ICU 1.7 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000