/* * Copyright © {1997-1999}, International Business Machines Corporation and others. All Rights Reserved. ******************************************************************************** * * File TIMEZONE.H * * Modification History: * * Date Name Description * 04/21/97 aliu Overhauled header. * 07/09/97 helena Changed createInstance to createDefault. * 08/06/97 aliu Removed dependency on internal header for Hashtable. * 08/10/98 stephen Changed getDisplayName() API conventions to match * 08/19/98 stephen Changed createTimeZone() to never return 0 * 09/02/98 stephen Sync to JDK 1.2 8/31 * - Added getOffset(... monthlen ...) * - Added hasSameRules() * 09/15/98 stephen Added getStaticClassID * 12/03/99 aliu Moved data out of static table into icudata.dll. * Hashtable replaced by new static data structures. * 12/14/99 aliu Made GMT public. ******************************************************************************** */ #ifndef TIMEZONE_H #define TIMEZONE_H #include "unicode/unistr.h" #include "unicode/locid.h" #include "unicode/udata.h" class SimpleTimeZone; struct TZHeader; struct OffsetIndex; class U_I18N_API TimeZone { public: virtual ~TimeZone(); static const TimeZone* GMT; static TimeZone* createTimeZone(const UnicodeString& ID); static const UnicodeString** const createAvailableIDs(int32_t rawOffset, int32_t& numIDs); static const UnicodeString** const createAvailableIDs(int32_t& numIDs); static TimeZone* createDefault(void); static void adoptDefault(TimeZone* zone); static void setDefault(const TimeZone& zone); virtual UBool operator==(const TimeZone& that) const; UBool operator!=(const TimeZone& that) const {return !operator==(that);} virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0; virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, uint8_t dayOfWeek, int32_t millis) const = 0; virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day, uint8_t dayOfWeek, int32_t milliseconds, int32_t monthLength, UErrorCode& status) const = 0; virtual void setRawOffset(int32_t offsetMillis) = 0; virtual int32_t getRawOffset(void) const = 0; UnicodeString& getID(UnicodeString& ID) const; void setID(const UnicodeString& ID); enum EDisplayType { SHORT = 1, LONG }; UnicodeString& getDisplayName(UnicodeString& result) const; UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const; UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const; UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const; virtual UBool useDaylightTime(void) const = 0; virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0; virtual UBool hasSameRules(const TimeZone& other) const; virtual TimeZone* clone(void) const = 0; static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; } virtual UClassID getDynamicClassID(void) const = 0; protected: TimeZone(); TimeZone(const TimeZone& source); TimeZone& operator=(const TimeZone& right); private: static char fgClassID; static TimeZone* createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string. static TimeZone* fgDefaultZone; // default time zone (lazy evaluated) static const UnicodeString GMT_ID; static const int32_t GMT_ID_LENGTH; static const UnicodeString CUSTOM_ID; // Pointers into memory-mapped icudata. Writing to this memory // will segfault! See tzdat.h for more details. static const TZHeader * DATA; static const uint32_t* INDEX_BY_ID; static const OffsetIndex* INDEX_BY_OFFSET; // Other system zone data structures static UnicodeString* ZONE_IDS; static UBool DATA_LOADED; static UDataMemory* UDATA_POINTER; static UMTX LOCK; static void initDefault(void); // See source file for documentation static void loadZoneData(void); // See source file for documentation static UBool U_CALLCONV isDataAcceptable(void *context, const char *type, const char *name, const UDataInfo *pInfo); // See source file for documentation static TimeZone* createSystemTimeZone(const UnicodeString& name); UnicodeString fID; // this time zone's ID }; // ------------------------------------- inline UnicodeString& TimeZone::getID(UnicodeString& ID) const { ID = fID; return ID; } // ------------------------------------- inline void TimeZone::setID(const UnicodeString& ID) { fID = ID; } #endif //_TIMEZONE //eof