- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- Search for |

- File List
- Globals

# timezone.h

Go to the documentation of this file.

    00001 /*************************************************************************
    00002 * Copyright (c) 1997-2009, International Business Machines Corporation
    00003 * and others. All Rights Reserved.
    00004 **************************************************************************
    00005 *
    00006 * File TIMEZONE.H
    00007 *
    00008 * Modification History:
    00009 *
    00010 *   Date        Name        Description
    00011 *   04/21/97    aliu        Overhauled header.
    00012 *   07/09/97    helena      Changed createInstance to createDefault.
    00013 *   08/06/97    aliu        Removed dependency on internal header for Hashtable.
    00014 *   08/10/98    stephen        Changed getDisplayName() API conventions to match
    00015 *   08/19/98    stephen        Changed createTimeZone() to never return 0
    00016 *   09/02/98    stephen        Sync to JDK 1.2 8/31
    00017 *                            - Added getOffset(... monthlen ...)
    00018 *                            - Added hasSameRules()
    00019 *   09/15/98    stephen        Added getStaticClassID
    00020 *   12/03/99    aliu        Moved data out of static table into icudata.dll.
    00021 *                           Hashtable replaced by new static data structures.
    00022 *   12/14/99    aliu        Made GMT public.
    00023 *   08/15/01    grhoten     Made GMT private and added the getGMT() function
    00024 **************************************************************************
    00025 */
    00026
    00027 #ifndef TIMEZONE_H
    00028 #define TIMEZONE_H
    00029
    00030 #include "unicode/utypes.h"
    00031
    00037 #if !UCONFIG_NO_FORMATTING
    00038
    00039 #include "unicode/uobject.h"
    00040 #include "unicode/unistr.h"
    00041 #include "unicode/ures.h"
    00042
    00043 U_NAMESPACE_BEGIN
    00044
    00045 class StringEnumeration;
    00046
    00122 class U_I18N_API TimeZone : public UObject {
    00123 public:
    00127     virtual ~TimeZone();
    00128
    00135     static const TimeZone* U_EXPORT2 getGMT(void);
    00136
    00147     static TimeZone* U_EXPORT2 createTimeZone(const UnicodeString& ID);
    00148
    00156     static StringEnumeration* U_EXPORT2 createEnumeration();
    00157
    00175     static StringEnumeration* U_EXPORT2 createEnumeration(int32_t rawOffset);
    00176
    00187     static StringEnumeration* U_EXPORT2 createEnumeration(const char* country);
    00188
    00189 #ifdef U_USE_TIMEZONE_OBSOLETE_2_8
    00190
    00213     static const UnicodeString** createAvailableIDs(int32_t rawOffset, int32_t& numIDs);
    00214
    00236     static const UnicodeString** createAvailableIDs(const char* country,
    00237                                                           int32_t& numIDs);
    00238
    00252     static const UnicodeString** createAvailableIDs(int32_t& numIDs);
    00253 #endif
    00254
    00269     static int32_t U_EXPORT2 countEquivalentIDs(const UnicodeString& id);
    00270
    00290     static const UnicodeString U_EXPORT2 getEquivalentID(const UnicodeString& id,
    00291                                                int32_t index);
    00292
    00305     static TimeZone* U_EXPORT2 createDefault(void);
    00306
    00316     static void U_EXPORT2 adoptDefault(TimeZone* zone);
    00317
    00325     static void U_EXPORT2 setDefault(const TimeZone& zone);
    00326
    00333     static const char* U_EXPORT2 getTZDataVersion(UErrorCode& status);
    00334
    00348     static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,
    00349         UnicodeString& canonicalID, UErrorCode& status);
    00350
    00366     static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,
    00367         UnicodeString& canonicalID, UBool& isSystemID, UErrorCode& status);
    00368
    00378     virtual UBool operator==(const TimeZone& that) const;
    00379
    00389     UBool operator!=(const TimeZone& that) const {return !operator==(that);}
    00390
    00415     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
    00416                               uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
    00417
    00438     virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
    00439                            uint8_t dayOfWeek, int32_t milliseconds,
    00440                            int32_t monthLength, UErrorCode& status) const = 0;
    00441
    00465     virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
    00466                            int32_t& dstOffset, UErrorCode& ec) const;
    00467
    00475     virtual void setRawOffset(int32_t offsetMillis) = 0;
    00476
    00484     virtual int32_t getRawOffset(void) const = 0;
    00485
    00493     UnicodeString& getID(UnicodeString& ID) const;
    00494
    00508     void setID(const UnicodeString& ID);
    00509
    00514     enum EDisplayType {
    00519         SHORT = 1,
    00524         LONG
    00525     };
    00526
    00538     UnicodeString& getDisplayName(UnicodeString& result) const;
    00539
    00553     UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
    00554
    00567     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
    00568
    00583     UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
    00584
    00591     virtual UBool useDaylightTime(void) const = 0;
    00592
    00606     virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
    00607
    00616     virtual UBool hasSameRules(const TimeZone& other) const;
    00617
    00625     virtual TimeZone* clone(void) const = 0;
    00626
    00633     static UClassID U_EXPORT2 getStaticClassID(void);
    00634
    00646     virtual UClassID getDynamicClassID(void) const = 0;
    00647
    00663     virtual int32_t getDSTSavings() const;
    00664
    00665 protected:
    00666
    00671     TimeZone();
    00672
    00678     TimeZone(const UnicodeString &id);
    00679
    00685     TimeZone(const TimeZone& source);
    00686
    00692     TimeZone& operator=(const TimeZone& right);
    00693
    00703     static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status);
    00704
    00705 private:
    00706     friend class ZoneMeta;
    00707
    00708
    00709     static TimeZone*        createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.
    00710
    00720     static UnicodeString& dereferOlsonLink(const UnicodeString& linkTo, UnicodeString& linkFrom);
    00721
    00732     static UBool parseCustomID(const UnicodeString& id, int32_t& sign, int32_t& hour,
    00733         int32_t& min, int32_t& sec);
    00734
    00745     static UnicodeString& getCustomID(const UnicodeString& id, UnicodeString& normalized,
    00746         UErrorCode& status);
    00747
    00757     static UnicodeString& formatCustomID(int32_t hour, int32_t min, int32_t sec,
    00758         UBool negative, UnicodeString& id);
    00759
    00765     static void             initDefault(void);
    00766
    00767     // See source file for documentation
    00775     static TimeZone*        createSystemTimeZone(const UnicodeString& name);
    00776
    00777     UnicodeString           fID;    // this time zone's ID
    00778 };
    00779
    00780
    00781 // -------------------------------------
    00782
    00783 inline UnicodeString&
    00784 TimeZone::getID(UnicodeString& ID) const
    00785 {
    00786     ID = fID;
    00787     return ID;
    00788 }
    00789
    00790 // -------------------------------------
    00791
    00792 inline void
    00793 TimeZone::setID(const UnicodeString& ID)
    00794 {
    00795     fID = ID;
    00796 }
    00797 U_NAMESPACE_END
    00798
    00799 #endif /* #if !UCONFIG_NO_FORMATTING */
    00800
    00801 #endif //_TIMEZONE
    00802 //eof