]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/zonemeta.h
2 *******************************************************************************
3 * Copyright (C) 2007-2013, International Business Machines Corporation and *
4 * others. All Rights Reserved. *
5 *******************************************************************************
10 #include "unicode/utypes.h"
12 #if !UCONFIG_NO_FORMATTING
14 #include "unicode/unistr.h"
19 typedef struct OlsonToMetaMappingEntry
{
20 const UChar
*mzid
; // const because it's a reference to a resource bundle string.
23 } OlsonToMetaMappingEntry
;
28 class U_I18N_API ZoneMeta
{
31 * Return the canonical id for this tzid defined by CLDR, which might be the id itself.
32 * If the given system tzid is not known, U_ILLEGAL_ARGUMENT_ERROR is set in the status.
34 * Note: this internal API supports all known system IDs and "Etc/Unknown" (which is
37 static UnicodeString
& U_EXPORT2
getCanonicalCLDRID(const UnicodeString
&tzid
, UnicodeString
&systemID
, UErrorCode
& status
);
40 * Return the canonical id for this tzid defined by CLDR, which might be the id itself.
41 * This overload method returns a persistent const UChar*, which is guranteed to persist
42 * (a pointer to a resource).
44 static const UChar
* U_EXPORT2
getCanonicalCLDRID(const UnicodeString
&tzid
, UErrorCode
& status
);
47 * Conveninent method returning CLDR canonical ID for the given time zone
49 static const UChar
* U_EXPORT2
getCanonicalCLDRID(const TimeZone
& tz
);
52 * Return the canonical country code for this tzid. If we have none, or if the time zone
53 * is not associated with a country, return bogus string.
55 * @param country [output] Country code
56 * @param isPrimary [output] TRUE if the zone is the primary zone for the country
57 * @return A reference to the result country
59 static UnicodeString
& U_EXPORT2
getCanonicalCountry(const UnicodeString
&tzid
, UnicodeString
&country
, UBool
*isPrimary
= NULL
);
62 * Returns a CLDR metazone ID for the given Olson tzid and time.
64 static UnicodeString
& U_EXPORT2
getMetazoneID(const UnicodeString
&tzid
, UDate date
, UnicodeString
&result
);
66 * Returns an Olson ID for the ginve metazone and region
68 static UnicodeString
& U_EXPORT2
getZoneIdByMetazone(const UnicodeString
&mzid
, const UnicodeString
®ion
, UnicodeString
&result
);
70 static const UVector
* U_EXPORT2
getMetazoneMappings(const UnicodeString
&tzid
);
72 static const UVector
* U_EXPORT2
getAvailableMetazoneIDs();
75 * Returns the pointer to the persistent time zone ID string, or NULL if the given tzid is not in the
76 * tz database. This method is useful when you maintain persistent zone IDs without duplication.
78 static const UChar
* U_EXPORT2
findTimeZoneID(const UnicodeString
& tzid
);
81 * Returns the pointer to the persistent meta zone ID string, or NULL if the given mzid is not available.
82 * This method is useful when you maintain persistent meta zone IDs without duplication.
84 static const UChar
* U_EXPORT2
findMetaZoneID(const UnicodeString
& mzid
);
87 * Creates a custom zone for the offset
88 * @param offset GMT offset in milliseconds
89 * @return A custom TimeZone for the offset with normalized time zone id
91 static TimeZone
* createCustomTimeZone(int32_t offset
);
94 * Returns the time zone's short ID (null terminated) for the zone.
95 * For example, "uslax" for zone "America/Los_Angeles".
96 * @param tz the time zone
97 * @return the short ID of the time zone, or null if the short ID is not available.
99 static const UChar
* U_EXPORT2
getShortID(const TimeZone
& tz
);
102 * Returns the time zone's short ID (null terminated) for the zone ID.
103 * For example, "uslax" for zone ID "America/Los_Angeles".
104 * @param tz the time zone ID
105 * @return the short ID of the time zone ID, or null if the short ID is not available.
107 static const UChar
* U_EXPORT2
getShortID(const UnicodeString
& id
);
110 ZoneMeta(); // Prevent construction.
111 static UVector
* createMetazoneMappings(const UnicodeString
&tzid
);
112 static void initAvailableMetaZoneIDs();
113 static UnicodeString
& formatCustomID(uint8_t hour
, uint8_t min
, uint8_t sec
, UBool negative
, UnicodeString
& id
);
114 static const UChar
* getShortIDFromCanonical(const UChar
* canonicalID
);
119 #endif /* #if !UCONFIG_NO_FORMATTING */