ICU 54.1 54.1

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

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
timezone.h
Go to the documentation of this file.
1 /*************************************************************************
2 * Copyright (c) 1997-2014, International Business Machines Corporation
3 * and others. All Rights Reserved.
4 **************************************************************************
5 *
6 * File TIMEZONE.H
7 *
8 * Modification History:
9 *
10 * Date Name Description
11 * 04/21/97 aliu Overhauled header.
12 * 07/09/97 helena Changed createInstance to createDefault.
13 * 08/06/97 aliu Removed dependency on internal header for Hashtable.
14 * 08/10/98 stephen Changed getDisplayName() API conventions to match
15 * 08/19/98 stephen Changed createTimeZone() to never return 0
16 * 09/02/98 stephen Sync to JDK 1.2 8/31
17 * - Added getOffset(... monthlen ...)
18 * - Added hasSameRules()
19 * 09/15/98 stephen Added getStaticClassID
20 * 12/03/99 aliu Moved data out of static table into icudata.dll.
21 * Hashtable replaced by new static data structures.
22 * 12/14/99 aliu Made GMT public.
23 * 08/15/01 grhoten Made GMT private and added the getGMT() function
24 **************************************************************************
25 */
26
27 #ifndef TIMEZONE_H
28 #define TIMEZONE_H
29
30 #include "unicode/utypes.h"
31
37 #if !UCONFIG_NO_FORMATTING
38
39 #include "unicode/uobject.h"
40 #include "unicode/unistr.h"
41 #include "unicode/ures.h"
42 #include "unicode/ucal.h"
43
44 U_NAMESPACE_BEGIN
45
46 class StringEnumeration;
47
129 class U_I18N_API TimeZone : public UObject {
130 public:
134 virtual ~TimeZone();
135
148 static const TimeZone& U_EXPORT2 getUnknown();
149
162 static const TimeZone* U_EXPORT2 getGMT(void);
163
175 static TimeZone* U_EXPORT2 createTimeZone(const UnicodeString& ID);
176
192 static StringEnumeration* U_EXPORT2 createTimeZoneIDEnumeration(
193 USystemTimeZoneType zoneType,
194 const char* region,
195 const int32_t* rawOffset,
196 UErrorCode& ec);
197
205 static StringEnumeration* U_EXPORT2 createEnumeration();
206
224 static StringEnumeration* U_EXPORT2 createEnumeration(int32_t rawOffset);
225
236 static StringEnumeration* U_EXPORT2 createEnumeration(const char* country);
237
252 static int32_t U_EXPORT2 countEquivalentIDs(const UnicodeString& id);
253
273 static const UnicodeString U_EXPORT2 getEquivalentID(const UnicodeString& id,
274 int32_t index);
275
288 static TimeZone* U_EXPORT2 createDefault(void);
289
303 static void U_EXPORT2 adoptDefault(TimeZone* zone);
304
305 #ifndef U_HIDE_SYSTEM_API
306
316 static void U_EXPORT2 setDefault(const TimeZone& zone);
317 #endif /* U_HIDE_SYSTEM_API */
318
325 static const char* U_EXPORT2 getTZDataVersion(UErrorCode& status);
326
340 static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,
341 UnicodeString& canonicalID, UErrorCode& status);
342
358 static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,
359 UnicodeString& canonicalID, UBool& isSystemID, UErrorCode& status);
360
383 static UnicodeString& U_EXPORT2 getWindowsID(const UnicodeString& id,
384 UnicodeString& winid, UErrorCode& status);
385
412 static UnicodeString& U_EXPORT2 getIDForWindowsID(const UnicodeString& winid, const char* region,
413 UnicodeString& id, UErrorCode& status);
414
424 virtual UBool operator==(const TimeZone& that) const;
425
435 UBool operator!=(const TimeZone& that) const {return !operator==(that);}
436
461 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
462 uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
463
484 virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
485 uint8_t dayOfWeek, int32_t milliseconds,
486 int32_t monthLength, UErrorCode& status) const = 0;
487
511 virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
512 int32_t& dstOffset, UErrorCode& ec) const;
513
521 virtual void setRawOffset(int32_t offsetMillis) = 0;
522
530 virtual int32_t getRawOffset(void) const = 0;
531
539 UnicodeString& getID(UnicodeString& ID) const;
540
554 void setID(const UnicodeString& ID);
555
560 enum EDisplayType {
565 SHORT = 1,
570 LONG,
575 SHORT_GENERIC,
580 LONG_GENERIC,
586 SHORT_GMT,
592 LONG_GMT,
598 SHORT_COMMONLY_USED,
604 GENERIC_LOCATION
605 };
606
618 UnicodeString& getDisplayName(UnicodeString& result) const;
619
633 UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
634
647 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, UnicodeString& result) const;
648
663 UnicodeString& getDisplayName(UBool daylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
664
699 virtual UBool useDaylightTime(void) const = 0;
700
714 virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
715
724 virtual UBool hasSameRules(const TimeZone& other) const;
725
733 virtual TimeZone* clone(void) const = 0;
734
741 static UClassID U_EXPORT2 getStaticClassID(void);
742
754 virtual UClassID getDynamicClassID(void) const = 0;
755
771 virtual int32_t getDSTSavings() const;
772
790 static int32_t U_EXPORT2 getRegion(const UnicodeString& id,
791 char *region, int32_t capacity, UErrorCode& status);
792
793 protected:
794
799 TimeZone();
800
806 TimeZone(const UnicodeString &id);
807
813 TimeZone(const TimeZone& source);
814
820 TimeZone& operator=(const TimeZone& right);
821
822 #ifndef U_HIDE_INTERNAL_API
823
832 static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status);
833 #endif /* U_HIDE_INTERNAL_API */
834
835 private:
836 friend class ZoneMeta;
837
838
839 static TimeZone* createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.
840
849 static const UChar* findID(const UnicodeString& id);
850
859 static const UChar* dereferOlsonLink(const UnicodeString& id);
860
867 static const UChar* getRegion(const UnicodeString& id);
868
869 public:
870 #ifndef U_HIDE_INTERNAL_API
871
879 static const UChar* getRegion(const UnicodeString& id, UErrorCode& status);
880 #endif /* U_HIDE_INTERNAL_API */
881
882 private:
893 static UBool parseCustomID(const UnicodeString& id, int32_t& sign, int32_t& hour,
894 int32_t& minute, int32_t& second);
895
906 static UnicodeString& getCustomID(const UnicodeString& id, UnicodeString& normalized,
907 UErrorCode& status);
908
918 static UnicodeString& formatCustomID(int32_t hour, int32_t min, int32_t sec,
919 UBool negative, UnicodeString& id);
920
921 UnicodeString fID; // this time zone's ID
922
923 friend class TZEnumeration;
924 };
925
926
927 // -------------------------------------
928
929 inline UnicodeString&
930 TimeZone::getID(UnicodeString& ID) const
931 {
932 ID = fID;
933 return ID;
934 }
935
936 // -------------------------------------
937
938 inline void
939 TimeZone::setID(const UnicodeString& ID)
940 {
941 fID = ID;
942 }
943 U_NAMESPACE_END
944
945 #endif /* #if !UCONFIG_NO_FORMATTING */
946
947 #endif //_TIMEZONE
948 //eof