"Fossies" - the Fresh Open Source Software Archive

Member "timezone_8h_source.html" (3 Oct 2019, 56252 Bytes) of package /linux/misc/icu4c-65_1-docs.zip:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the project site itself.

ICU 65.1  65.1
timezone.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*************************************************************************
4 * Copyright (c) 1997-2016, International Business Machines Corporation
5 * and others. All Rights Reserved.
6 **************************************************************************
7 *
8 * File TIMEZONE.H
9 *
10 * Modification History:
11 *
12 * Date Name Description
13 * 04/21/97 aliu Overhauled header.
14 * 07/09/97 helena Changed createInstance to createDefault.
15 * 08/06/97 aliu Removed dependency on internal header for Hashtable.
16 * 08/10/98 stephen Changed getDisplayName() API conventions to match
17 * 08/19/98 stephen Changed createTimeZone() to never return 0
18 * 09/02/98 stephen Sync to JDK 1.2 8/31
19 * - Added getOffset(... monthlen ...)
20 * - Added hasSameRules()
21 * 09/15/98 stephen Added getStaticClassID
22 * 12/03/99 aliu Moved data out of static table into icudata.dll.
23 * Hashtable replaced by new static data structures.
24 * 12/14/99 aliu Made GMT public.
25 * 08/15/01 grhoten Made GMT private and added the getGMT() function
26 **************************************************************************
27 */
28 
29 #ifndef TIMEZONE_H
30 #define TIMEZONE_H
31 
32 #include "unicode/utypes.h"
33 
34 #if U_SHOW_CPLUSPLUS_API
35 
41 #if !UCONFIG_NO_FORMATTING
42 
43 #include "unicode/uobject.h"
44 #include "unicode/unistr.h"
45 #include "unicode/ures.h"
46 #include "unicode/ucal.h"
47 
48 U_NAMESPACE_BEGIN
49 
50 class StringEnumeration;
51 
133 class U_I18N_API TimeZone : public UObject {
134 public:
138  virtual ~TimeZone();
139 
152  static const TimeZone& U_EXPORT2 getUnknown();
153 
166  static const TimeZone* U_EXPORT2 getGMT(void);
167 
179  static TimeZone* U_EXPORT2 createTimeZone(const UnicodeString& ID);
180 
196  static StringEnumeration* U_EXPORT2 createTimeZoneIDEnumeration(
197  USystemTimeZoneType zoneType,
198  const char* region,
199  const int32_t* rawOffset,
200  UErrorCode& ec);
201 
209  static StringEnumeration* U_EXPORT2 createEnumeration();
210 
228  static StringEnumeration* U_EXPORT2 createEnumeration(int32_t rawOffset);
229 
240  static StringEnumeration* U_EXPORT2 createEnumeration(const char* country);
241 
256  static int32_t U_EXPORT2 countEquivalentIDs(const UnicodeString& id);
257 
277  static const UnicodeString U_EXPORT2 getEquivalentID(const UnicodeString& id,
278  int32_t index);
279 
303  static TimeZone* U_EXPORT2 detectHostTimeZone();
304 
318  static TimeZone* U_EXPORT2 createDefault(void);
319 
329  static void U_EXPORT2 adoptDefault(TimeZone* zone);
330 
331 #ifndef U_HIDE_SYSTEM_API
332 
340  static void U_EXPORT2 setDefault(const TimeZone& zone);
341 #endif /* U_HIDE_SYSTEM_API */
342 
349  static const char* U_EXPORT2 getTZDataVersion(UErrorCode& status);
350 
364  static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,
365  UnicodeString& canonicalID, UErrorCode& status);
366 
382  static UnicodeString& U_EXPORT2 getCanonicalID(const UnicodeString& id,
383  UnicodeString& canonicalID, UBool& isSystemID, UErrorCode& status);
384 
407  static UnicodeString& U_EXPORT2 getWindowsID(const UnicodeString& id,
408  UnicodeString& winid, UErrorCode& status);
409 
436  static UnicodeString& U_EXPORT2 getIDForWindowsID(const UnicodeString& winid, const char* region,
437  UnicodeString& id, UErrorCode& status);
438 
448  virtual UBool operator==(const TimeZone& that) const;
449 
459  UBool operator!=(const TimeZone& that) const {return !operator==(that);}
460 
485  virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
486  uint8_t dayOfWeek, int32_t millis, UErrorCode& status) const = 0;
487 
508  virtual int32_t getOffset(uint8_t era, int32_t year, int32_t month, int32_t day,
509  uint8_t dayOfWeek, int32_t milliseconds,
510  int32_t monthLength, UErrorCode& status) const = 0;
511 
535  virtual void getOffset(UDate date, UBool local, int32_t& rawOffset,
536  int32_t& dstOffset, UErrorCode& ec) const;
537 
545  virtual void setRawOffset(int32_t offsetMillis) = 0;
546 
554  virtual int32_t getRawOffset(void) const = 0;
555 
563  UnicodeString& getID(UnicodeString& ID) const;
564 
578  void setID(const UnicodeString& ID);
579 
589  SHORT = 1,
628  GENERIC_LOCATION
629  };
630 
642  UnicodeString& getDisplayName(UnicodeString& result) const;
643 
657  UnicodeString& getDisplayName(const Locale& locale, UnicodeString& result) const;
658 
671  UnicodeString& getDisplayName(UBool inDaylight, EDisplayType style, UnicodeString& result) const;
672 
687  UnicodeString& getDisplayName(UBool inDaylight, EDisplayType style, const Locale& locale, UnicodeString& result) const;
688 
723  virtual UBool useDaylightTime(void) const = 0;
724 
725 #ifndef U_FORCE_HIDE_DEPRECATED_API
726 
739  virtual UBool inDaylightTime(UDate date, UErrorCode& status) const = 0;
740 #endif // U_FORCE_HIDE_DEPRECATED_API
741 
750  virtual UBool hasSameRules(const TimeZone& other) const;
751 
759  virtual TimeZone* clone() const = 0;
760 
767  static UClassID U_EXPORT2 getStaticClassID(void);
768 
780  virtual UClassID getDynamicClassID(void) const = 0;
781 
797  virtual int32_t getDSTSavings() const;
798 
816  static int32_t U_EXPORT2 getRegion(const UnicodeString& id,
817  char *region, int32_t capacity, UErrorCode& status);
818 
819 protected:
820 
825  TimeZone();
826 
832  TimeZone(const UnicodeString &id);
833 
839  TimeZone(const TimeZone& source);
840 
846  TimeZone& operator=(const TimeZone& right);
847 
848 #ifndef U_HIDE_INTERNAL_API
849 
858  static UResourceBundle* loadRule(const UResourceBundle* top, const UnicodeString& ruleid, UResourceBundle* oldbundle, UErrorCode&status);
859 #endif /* U_HIDE_INTERNAL_API */
860 
861 private:
862  friend class ZoneMeta;
863 
864 
865  static TimeZone* createCustomTimeZone(const UnicodeString&); // Creates a time zone based on the string.
866 
875  static const char16_t* findID(const UnicodeString& id);
876 
885  static const char16_t* dereferOlsonLink(const UnicodeString& id);
886 
893  static const char16_t* getRegion(const UnicodeString& id);
894 
895  public:
896 #ifndef U_HIDE_INTERNAL_API
897 
905  static const char16_t* getRegion(const UnicodeString& id, UErrorCode& status);
906 #endif /* U_HIDE_INTERNAL_API */
907 
908  private:
919  static UBool parseCustomID(const UnicodeString& id, int32_t& sign, int32_t& hour,
920  int32_t& minute, int32_t& second);
921 
932  static UnicodeString& getCustomID(const UnicodeString& id, UnicodeString& normalized,
933  UErrorCode& status);
934 
944  static UnicodeString& formatCustomID(int32_t hour, int32_t min, int32_t sec,
945  UBool negative, UnicodeString& id);
946 
947  UnicodeString fID; // this time zone's ID
948 
949  friend class TZEnumeration;
950 };
951 
952 
953 // -------------------------------------
954 
955 inline UnicodeString&
957 {
958  ID = fID;
959  return ID;
960 }
961 
962 // -------------------------------------
963 
964 inline void
966 {
967  fID = ID;
968 }
969 U_NAMESPACE_END
970 
971 #endif /* #if !UCONFIG_NO_FORMATTING */
972 
973 #endif /* U_SHOW_CPLUSPLUS_API */
974 
975 #endif //_TIMEZONE
976 //eof
void setID(const UnicodeString &ID)
Sets the TimeZone's ID to the specified value.
Definition: timezone.h:965
C API: Calendar.
UnicodeString & getID(UnicodeString &ID) const
Fills in "ID" with the TimeZone's ID.
Definition: timezone.h:956
double UDate
Date and Time data type.
Definition: utypes.h:203
C++ API: Unicode String.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:61
EDisplayType
Enum for use with getDisplayName.
Definition: timezone.h:584
TimeZone represents a time zone offset, and also figures out daylight savings.
Definition: timezone.h:133
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:301
Selector for short display name derived from time zone offset.
Definition: timezone.h:610
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
Selector for short generic display name.
Definition: timezone.h:599
Selector for long generic display name.
Definition: timezone.h:604
Selector for long display name.
Definition: timezone.h:594
C++ API: Common ICU base class UObject.
Selector for short display name derived from the time zone's fallback name.
Definition: timezone.h:622
USystemTimeZoneType
System time zone type constants used by filtering zones in ucal_openTimeZoneIDEnumeration.
Definition: ucal.h:550
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
Basic definitions for ICU, for both C and C++ APIs.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
struct UResourceBundle UResourceBundle
Definition: ures.h:59
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
Selector for long display name derived from time zone offset.
Definition: timezone.h:616
UBool operator!=(const TimeZone &that) const
Returns true if the two TimeZones are NOT equal; that is, if operator==() returns false...
Definition: timezone.h:459
C API: Resource Bundle.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195