]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/zonemeta.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2007-2013, International Business Machines Corporation and *
6 * others. All Rights Reserved. *
7 *******************************************************************************
12 #include "unicode/utypes.h"
14 #if !UCONFIG_NO_FORMATTING
16 #include "unicode/unistr.h"
21 typedef struct OlsonToMetaMappingEntry
{
22 const UChar
*mzid
; // const because it's a reference to a resource bundle string.
25 } OlsonToMetaMappingEntry
;
30 class U_I18N_API ZoneMeta
{
33 * Return the canonical id for this tzid defined by CLDR, which might be the id itself.
34 * If the given system tzid is not known, U_ILLEGAL_ARGUMENT_ERROR is set in the status.
36 * Note: this internal API supports all known system IDs and "Etc/Unknown" (which is
39 static UnicodeString
& U_EXPORT2
getCanonicalCLDRID(const UnicodeString
&tzid
, UnicodeString
&systemID
, UErrorCode
& status
);
42 * Return the canonical id for this tzid defined by CLDR, which might be the id itself.
43 * This overload method returns a persistent const UChar*, which is guranteed to persist
44 * (a pointer to a resource). If the given system tzid is not known, U_ILLEGAL_ARGUMENT_ERROR
45 * is set in the status.
47 * @param status Receives the status
48 * @return The canonical ID for the input time zone ID
50 static const UChar
* U_EXPORT2
getCanonicalCLDRID(const UnicodeString
&tzid
, UErrorCode
& status
);
53 * Conveninent method returning CLDR canonical ID for the given time zone
55 static const UChar
* U_EXPORT2
getCanonicalCLDRID(const TimeZone
& tz
);
58 * Return the canonical country code for this tzid. If we have none, or if the time zone
59 * is not associated with a country, return bogus string.
61 * @param country [output] Country code
62 * @param isPrimary [output] TRUE if the zone is the primary zone for the country
63 * @return A reference to the result country
65 static UnicodeString
& U_EXPORT2
getCanonicalCountry(const UnicodeString
&tzid
, UnicodeString
&country
, UBool
*isPrimary
= NULL
);
68 * Returns a CLDR metazone ID for the given Olson tzid and time.
70 static UnicodeString
& U_EXPORT2
getMetazoneID(const UnicodeString
&tzid
, UDate date
, UnicodeString
&result
);
72 * Returns an Olson ID for the ginve metazone and region
74 static UnicodeString
& U_EXPORT2
getZoneIdByMetazone(const UnicodeString
&mzid
, const UnicodeString
®ion
, UnicodeString
&result
);
76 static const UVector
* U_EXPORT2
getMetazoneMappings(const UnicodeString
&tzid
);
78 static const UVector
* U_EXPORT2
getAvailableMetazoneIDs();
81 * Returns the pointer to the persistent time zone ID string, or NULL if the given tzid is not in the
82 * tz database. This method is useful when you maintain persistent zone IDs without duplication.
84 static const UChar
* U_EXPORT2
findTimeZoneID(const UnicodeString
& tzid
);
87 * Returns the pointer to the persistent meta zone ID string, or NULL if the given mzid is not available.
88 * This method is useful when you maintain persistent meta zone IDs without duplication.
90 static const UChar
* U_EXPORT2
findMetaZoneID(const UnicodeString
& mzid
);
93 * Creates a custom zone for the offset
94 * @param offset GMT offset in milliseconds
95 * @return A custom TimeZone for the offset with normalized time zone id
97 static TimeZone
* createCustomTimeZone(int32_t offset
);
100 * Returns the time zone's short ID (null terminated) for the zone.
101 * For example, "uslax" for zone "America/Los_Angeles".
102 * @param tz the time zone
103 * @return the short ID of the time zone, or null if the short ID is not available.
105 static const UChar
* U_EXPORT2
getShortID(const TimeZone
& tz
);
108 * Returns the time zone's short ID (null terminated) for the zone ID.
109 * For example, "uslax" for zone ID "America/Los_Angeles".
110 * @param tz the time zone ID
111 * @return the short ID of the time zone ID, or null if the short ID is not available.
113 static const UChar
* U_EXPORT2
getShortID(const UnicodeString
& id
);
116 ZoneMeta(); // Prevent construction.
117 static UVector
* createMetazoneMappings(const UnicodeString
&tzid
);
118 static UnicodeString
& formatCustomID(uint8_t hour
, uint8_t min
, uint8_t sec
, UBool negative
, UnicodeString
& id
);
119 static const UChar
* getShortIDFromCanonical(const UChar
* canonicalID
);
124 #endif /* #if !UCONFIG_NO_FORMATTING */