intl/icu/source/i18n/zonemeta.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 *******************************************************************************
michael@0 3 * Copyright (C) 2007-2013, International Business Machines Corporation and *
michael@0 4 * others. All Rights Reserved. *
michael@0 5 *******************************************************************************
michael@0 6 */
michael@0 7 #ifndef ZONEMETA_H
michael@0 8 #define ZONEMETA_H
michael@0 9
michael@0 10 #include "unicode/utypes.h"
michael@0 11
michael@0 12 #if !UCONFIG_NO_FORMATTING
michael@0 13
michael@0 14 #include "unicode/unistr.h"
michael@0 15 #include "hash.h"
michael@0 16
michael@0 17 U_NAMESPACE_BEGIN
michael@0 18
michael@0 19 typedef struct OlsonToMetaMappingEntry {
michael@0 20 const UChar *mzid; // const because it's a reference to a resource bundle string.
michael@0 21 UDate from;
michael@0 22 UDate to;
michael@0 23 } OlsonToMetaMappingEntry;
michael@0 24
michael@0 25 class UVector;
michael@0 26 class TimeZone;
michael@0 27
michael@0 28 class U_I18N_API ZoneMeta {
michael@0 29 public:
michael@0 30 /**
michael@0 31 * Return the canonical id for this tzid defined by CLDR, which might be the id itself.
michael@0 32 * If the given system tzid is not known, U_ILLEGAL_ARGUMENT_ERROR is set in the status.
michael@0 33 *
michael@0 34 * Note: this internal API supports all known system IDs and "Etc/Unknown" (which is
michael@0 35 * NOT a system ID).
michael@0 36 */
michael@0 37 static UnicodeString& U_EXPORT2 getCanonicalCLDRID(const UnicodeString &tzid, UnicodeString &systemID, UErrorCode& status);
michael@0 38
michael@0 39 /**
michael@0 40 * Return the canonical id for this tzid defined by CLDR, which might be the id itself.
michael@0 41 * This overload method returns a persistent const UChar*, which is guranteed to persist
michael@0 42 * (a pointer to a resource).
michael@0 43 */
michael@0 44 static const UChar* U_EXPORT2 getCanonicalCLDRID(const UnicodeString &tzid, UErrorCode& status);
michael@0 45
michael@0 46 /*
michael@0 47 * Conveninent method returning CLDR canonical ID for the given time zone
michael@0 48 */
michael@0 49 static const UChar* U_EXPORT2 getCanonicalCLDRID(const TimeZone& tz);
michael@0 50
michael@0 51 /**
michael@0 52 * Return the canonical country code for this tzid. If we have none, or if the time zone
michael@0 53 * is not associated with a country, return bogus string.
michael@0 54 * @param tzid Zone ID
michael@0 55 * @param country [output] Country code
michael@0 56 * @param isPrimary [output] TRUE if the zone is the primary zone for the country
michael@0 57 * @return A reference to the result country
michael@0 58 */
michael@0 59 static UnicodeString& U_EXPORT2 getCanonicalCountry(const UnicodeString &tzid, UnicodeString &country, UBool *isPrimary = NULL);
michael@0 60
michael@0 61 /**
michael@0 62 * Returns a CLDR metazone ID for the given Olson tzid and time.
michael@0 63 */
michael@0 64 static UnicodeString& U_EXPORT2 getMetazoneID(const UnicodeString &tzid, UDate date, UnicodeString &result);
michael@0 65 /**
michael@0 66 * Returns an Olson ID for the ginve metazone and region
michael@0 67 */
michael@0 68 static UnicodeString& U_EXPORT2 getZoneIdByMetazone(const UnicodeString &mzid, const UnicodeString &region, UnicodeString &result);
michael@0 69
michael@0 70 static const UVector* U_EXPORT2 getMetazoneMappings(const UnicodeString &tzid);
michael@0 71
michael@0 72 static const UVector* U_EXPORT2 getAvailableMetazoneIDs();
michael@0 73
michael@0 74 /**
michael@0 75 * Returns the pointer to the persistent time zone ID string, or NULL if the given tzid is not in the
michael@0 76 * tz database. This method is useful when you maintain persistent zone IDs without duplication.
michael@0 77 */
michael@0 78 static const UChar* U_EXPORT2 findTimeZoneID(const UnicodeString& tzid);
michael@0 79
michael@0 80 /**
michael@0 81 * Returns the pointer to the persistent meta zone ID string, or NULL if the given mzid is not available.
michael@0 82 * This method is useful when you maintain persistent meta zone IDs without duplication.
michael@0 83 */
michael@0 84 static const UChar* U_EXPORT2 findMetaZoneID(const UnicodeString& mzid);
michael@0 85
michael@0 86 /**
michael@0 87 * Creates a custom zone for the offset
michael@0 88 * @param offset GMT offset in milliseconds
michael@0 89 * @return A custom TimeZone for the offset with normalized time zone id
michael@0 90 */
michael@0 91 static TimeZone* createCustomTimeZone(int32_t offset);
michael@0 92
michael@0 93 /**
michael@0 94 * Returns the time zone's short ID (null terminated) for the zone.
michael@0 95 * For example, "uslax" for zone "America/Los_Angeles".
michael@0 96 * @param tz the time zone
michael@0 97 * @return the short ID of the time zone, or null if the short ID is not available.
michael@0 98 */
michael@0 99 static const UChar* U_EXPORT2 getShortID(const TimeZone& tz);
michael@0 100
michael@0 101 /**
michael@0 102 * Returns the time zone's short ID (null terminated) for the zone ID.
michael@0 103 * For example, "uslax" for zone ID "America/Los_Angeles".
michael@0 104 * @param tz the time zone ID
michael@0 105 * @return the short ID of the time zone ID, or null if the short ID is not available.
michael@0 106 */
michael@0 107 static const UChar* U_EXPORT2 getShortID(const UnicodeString& id);
michael@0 108
michael@0 109 private:
michael@0 110 ZoneMeta(); // Prevent construction.
michael@0 111 static UVector* createMetazoneMappings(const UnicodeString &tzid);
michael@0 112 static UnicodeString& formatCustomID(uint8_t hour, uint8_t min, uint8_t sec, UBool negative, UnicodeString& id);
michael@0 113 static const UChar* getShortIDFromCanonical(const UChar* canonicalID);
michael@0 114 };
michael@0 115
michael@0 116 U_NAMESPACE_END
michael@0 117
michael@0 118 #endif /* #if !UCONFIG_NO_FORMATTING */
michael@0 119 #endif // ZONEMETA_H

mercurial