1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/zonemeta.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,119 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* Copyright (C) 2007-2013, International Business Machines Corporation and * 1.7 +* others. All Rights Reserved. * 1.8 +******************************************************************************* 1.9 +*/ 1.10 +#ifndef ZONEMETA_H 1.11 +#define ZONEMETA_H 1.12 + 1.13 +#include "unicode/utypes.h" 1.14 + 1.15 +#if !UCONFIG_NO_FORMATTING 1.16 + 1.17 +#include "unicode/unistr.h" 1.18 +#include "hash.h" 1.19 + 1.20 +U_NAMESPACE_BEGIN 1.21 + 1.22 +typedef struct OlsonToMetaMappingEntry { 1.23 + const UChar *mzid; // const because it's a reference to a resource bundle string. 1.24 + UDate from; 1.25 + UDate to; 1.26 +} OlsonToMetaMappingEntry; 1.27 + 1.28 +class UVector; 1.29 +class TimeZone; 1.30 + 1.31 +class U_I18N_API ZoneMeta { 1.32 +public: 1.33 + /** 1.34 + * Return the canonical id for this tzid defined by CLDR, which might be the id itself. 1.35 + * If the given system tzid is not known, U_ILLEGAL_ARGUMENT_ERROR is set in the status. 1.36 + * 1.37 + * Note: this internal API supports all known system IDs and "Etc/Unknown" (which is 1.38 + * NOT a system ID). 1.39 + */ 1.40 + static UnicodeString& U_EXPORT2 getCanonicalCLDRID(const UnicodeString &tzid, UnicodeString &systemID, UErrorCode& status); 1.41 + 1.42 + /** 1.43 + * Return the canonical id for this tzid defined by CLDR, which might be the id itself. 1.44 + * This overload method returns a persistent const UChar*, which is guranteed to persist 1.45 + * (a pointer to a resource). 1.46 + */ 1.47 + static const UChar* U_EXPORT2 getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status); 1.48 + 1.49 + /* 1.50 + * Conveninent method returning CLDR canonical ID for the given time zone 1.51 + */ 1.52 + static const UChar* U_EXPORT2 getCanonicalCLDRID(const TimeZone& tz); 1.53 + 1.54 + /** 1.55 + * Return the canonical country code for this tzid. If we have none, or if the time zone 1.56 + * is not associated with a country, return bogus string. 1.57 + * @param tzid Zone ID 1.58 + * @param country [output] Country code 1.59 + * @param isPrimary [output] TRUE if the zone is the primary zone for the country 1.60 + * @return A reference to the result country 1.61 + */ 1.62 + static UnicodeString& U_EXPORT2 getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country, UBool *isPrimary = NULL); 1.63 + 1.64 + /** 1.65 + * Returns a CLDR metazone ID for the given Olson tzid and time. 1.66 + */ 1.67 + static UnicodeString& U_EXPORT2 getMetazoneID(const UnicodeString &tzid, UDate date, UnicodeString &result); 1.68 + /** 1.69 + * Returns an Olson ID for the ginve metazone and region 1.70 + */ 1.71 + static UnicodeString& U_EXPORT2 getZoneIdByMetazone(const UnicodeString &mzid, const UnicodeString ®ion, UnicodeString &result); 1.72 + 1.73 + static const UVector* U_EXPORT2 getMetazoneMappings(const UnicodeString &tzid); 1.74 + 1.75 + static const UVector* U_EXPORT2 getAvailableMetazoneIDs(); 1.76 + 1.77 + /** 1.78 + * Returns the pointer to the persistent time zone ID string, or NULL if the given tzid is not in the 1.79 + * tz database. This method is useful when you maintain persistent zone IDs without duplication. 1.80 + */ 1.81 + static const UChar* U_EXPORT2 findTimeZoneID(const UnicodeString& tzid); 1.82 + 1.83 + /** 1.84 + * Returns the pointer to the persistent meta zone ID string, or NULL if the given mzid is not available. 1.85 + * This method is useful when you maintain persistent meta zone IDs without duplication. 1.86 + */ 1.87 + static const UChar* U_EXPORT2 findMetaZoneID(const UnicodeString& mzid); 1.88 + 1.89 + /** 1.90 + * Creates a custom zone for the offset 1.91 + * @param offset GMT offset in milliseconds 1.92 + * @return A custom TimeZone for the offset with normalized time zone id 1.93 + */ 1.94 + static TimeZone* createCustomTimeZone(int32_t offset); 1.95 + 1.96 + /** 1.97 + * Returns the time zone's short ID (null terminated) for the zone. 1.98 + * For example, "uslax" for zone "America/Los_Angeles". 1.99 + * @param tz the time zone 1.100 + * @return the short ID of the time zone, or null if the short ID is not available. 1.101 + */ 1.102 + static const UChar* U_EXPORT2 getShortID(const TimeZone& tz); 1.103 + 1.104 + /** 1.105 + * Returns the time zone's short ID (null terminated) for the zone ID. 1.106 + * For example, "uslax" for zone ID "America/Los_Angeles". 1.107 + * @param tz the time zone ID 1.108 + * @return the short ID of the time zone ID, or null if the short ID is not available. 1.109 + */ 1.110 + static const UChar* U_EXPORT2 getShortID(const UnicodeString& id); 1.111 + 1.112 +private: 1.113 + ZoneMeta(); // Prevent construction. 1.114 + static UVector* createMetazoneMappings(const UnicodeString &tzid); 1.115 + static UnicodeString& formatCustomID(uint8_t hour, uint8_t min, uint8_t sec, UBool negative, UnicodeString& id); 1.116 + static const UChar* getShortIDFromCanonical(const UChar* canonicalID); 1.117 +}; 1.118 + 1.119 +U_NAMESPACE_END 1.120 + 1.121 +#endif /* #if !UCONFIG_NO_FORMATTING */ 1.122 +#endif // ZONEMETA_H