Home | History | Annotate | Download | only in i18n
      1 /*
      2 *******************************************************************************
      3 * Copyright (C) 2007-2009, International Business Machines Corporation and    *
      4 * others. All Rights Reserved.                                                *
      5 *******************************************************************************
      6 */
      7 #ifndef ZONEMETA_H
      8 #define ZONEMETA_H
      9 
     10 #include "unicode/utypes.h"
     11 
     12 #if !UCONFIG_NO_FORMATTING
     13 
     14 #include "unicode/unistr.h"
     15 #include "hash.h"
     16 
     17 U_NAMESPACE_BEGIN
     18 
     19 typedef struct CanonicalMapEntry {
     20     const UChar *id; // const because it's a reference to a resource bundle string.
     21     const UChar *country; // const because it's a reference to a resource bundle string.
     22 } CanonicalMapEntry;
     23 
     24 typedef struct OlsonToMetaMappingEntry {
     25     const UChar *mzid; // const because it's a reference to a resource bundle string.
     26     UDate from;
     27     UDate to;
     28 } OlsonToMetaMappingEntry;
     29 
     30 typedef struct MetaToOlsonMappingEntry {
     31     const UChar *id; // const because it's a reference to a resource bundle string.
     32     UChar *territory;
     33 } MetaToOlsonMappingEntry;
     34 
     35 class UVector;
     36 
     37 class U_I18N_API ZoneMeta {
     38 public:
     39     /**
     40      * Return the canonical id for this system tzid, which might be the id itself.
     41      * If the given system tzid is not know, U_ILLEGAL_ARGUMENT_ERROR is set in the status.
     42      */
     43     static UnicodeString& U_EXPORT2 getCanonicalSystemID(const UnicodeString &tzid, UnicodeString &systemID, UErrorCode& status);
     44 
     45     /**
     46      * Return the canonical country code for this tzid.  If we have none, or if the time zone
     47      * is not associated with a country, return null.
     48      */
     49     static UnicodeString& U_EXPORT2 getCanonicalCountry(const UnicodeString &tzid, UnicodeString &canonicalCountry);
     50 
     51     /**
     52      * Return the country code if this is a 'single' time zone that can fallback to just
     53      * the country, otherwise return empty string.  (Note, one must also check the locale data
     54      * to see that there is a localization for the country in order to implement
     55      * tr#35 appendix J step 5.)
     56      */
     57     static UnicodeString& U_EXPORT2 getSingleCountry(const UnicodeString &tzid, UnicodeString &country);
     58 
     59     /**
     60      * Returns a CLDR metazone ID for the given Olson tzid and time.
     61      */
     62     static UnicodeString& U_EXPORT2 getMetazoneID(const UnicodeString &tzid, UDate date, UnicodeString &result);
     63     /**
     64      * Returns an Olson ID for the ginve metazone and region
     65      */
     66     static UnicodeString& U_EXPORT2 getZoneIdByMetazone(const UnicodeString &mzid, const UnicodeString &region, UnicodeString &result);
     67 
     68     static const UVector* U_EXPORT2 getMetazoneMappings(const UnicodeString &tzid);
     69 
     70 private:
     71     ZoneMeta(); // Prevent construction.
     72     static const CanonicalMapEntry* U_EXPORT2 getCanonicalInfo(const UnicodeString &tzid);
     73 
     74     static void initializeCanonicalMap(void);
     75     static void initializeOlsonToMeta(void);
     76     static void initializeMetaToOlson(void);
     77     static UHashtable* createCanonicalMap(void);
     78     static UHashtable* createOlsonToMetaMap(void);
     79     static UHashtable* createMetaToOlsonMap(void);
     80 };
     81 
     82 U_NAMESPACE_END
     83 
     84 #endif /* #if !UCONFIG_NO_FORMATTING */
     85 #endif // ZONEMETA_H
     86