annotate modules/javafx.web/src/main/native/Source/ThirdParty/icu/source/i18n/zonemeta.h @ 10550:fee4ef5c87df

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