ICU 69.1 69.1

Data Structures | Public Member Functions | Static Public Member Functions
icu::TimeZoneNames Class Referenceabstract

`TimeZoneNames` is an abstract class representing the time zone display name data model defined by UTS#35 Unicode Locale Data Markup Language (LDML). More...

`#include <tznames.h>`

Inheritance diagram for icu::TimeZoneNames:

## Data Structures
class | MatchInfoCollection
| `MatchInfoCollection` represents a collection of time zone name matches used by TimeZoneNames#find. More...

## Public Member Functions
virtual | ~TimeZoneNames ()
| Destructor. More...
virtual UBool | operator== (const TimeZoneNames &other) const =0
| Return true if the given TimeZoneNames objects are semantically equal. More...
UBool | operator!= (const TimeZoneNames &other) const
| Return true if the given TimeZoneNames objects are not semantically equal. More...
virtual TimeZoneNames * | clone () const =0
| Clone this object polymorphically. More...
virtual StringEnumeration * | getAvailableMetaZoneIDs (UErrorCode &status) const =0
| Returns an enumeration of all available meta zone IDs. More...
virtual StringEnumeration * | getAvailableMetaZoneIDs (const UnicodeString &tzID, UErrorCode &status) const =0
| Returns an enumeration of all available meta zone IDs used by the given time zone. More...
virtual UnicodeString & | getMetaZoneID (const UnicodeString &tzID, UDate date, UnicodeString &mzID) const =0
| Returns the meta zone ID for the given canonical time zone ID at the given date. More...
virtual UnicodeString & | getReferenceZoneID (const UnicodeString &mzID, const char *region, UnicodeString &tzID) const =0
| Returns the reference zone ID for the given meta zone ID for the region. More...
virtual UnicodeString & | getMetaZoneDisplayName (const UnicodeString &mzID, UTimeZoneNameType type, UnicodeString &name) const =0
| Returns the display name of the meta zone. More...
virtual UnicodeString & | getTimeZoneDisplayName (const UnicodeString &tzID, UTimeZoneNameType type, UnicodeString &name) const =0
| Returns the display name of the time zone. More...
virtual UnicodeString & | getExemplarLocationName (const UnicodeString &tzID, UnicodeString &name) const
| Returns the exemplar location name for the given time zone. More...
virtual UnicodeString & | getDisplayName (const UnicodeString &tzID, UTimeZoneNameType type, UDate date, UnicodeString &name) const
| Returns the display name of the time zone at the given date. More...
virtual void | loadAllDisplayNames (UErrorCode &status)
virtual void | getDisplayNames (const UnicodeString &tzID, const UTimeZoneNameType types[], int32_t numTypes, UDate date, UnicodeString dest[], UErrorCode &status) const
virtual MatchInfoCollection * | find (const UnicodeString &text, int32_t start, uint32_t types, UErrorCode &status) const =0
| Finds time zone name prefix matches for the input text at the given offset and returns a collection of the matches. More...
Public Member Functions inherited from icu::UObject
virtual | ~UObject ()
| Destructor. More...
virtual UClassID | getDynamicClassID () const
| ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class. More...

## Static Public Member Functions
static TimeZoneNames * | createInstance (const Locale &locale, UErrorCode &status)
| Returns an instance of `TimeZoneNames` for the specified locale. More...
static TimeZoneNames * | createTZDBInstance (const Locale &locale, UErrorCode &status)
| Returns an instance of `TimeZoneNames` containing only short specific zone names (SHORT_STANDARD and SHORT_DAYLIGHT), compatible with the IANA tz database's zone abbreviations (not localized). More...

## Detailed Description

`TimeZoneNames` is an abstract class representing the time zone display name data model defined by UTS#35 Unicode Locale Data Markup Language (LDML).

The model defines meta zone, which is used for storing a set of display names. A meta zone can be shared by multiple time zones. Also a time zone may have multiple meta zone historic mappings.

For example, people in the United States refer the zone used by the east part of North America as "Eastern Time". The tz database contains multiple time zones "America/New_York", "America/Detroit", "America/Montreal" and some others that belong to "Eastern Time". However, assigning different display names to these time zones does not make much sense for most of people.

In CLDR (which uses LDML for representing locale data), the display name "Eastern Time" is stored as long generic display name of a meta zone identified by the ID "America_Eastern". Then, there is another table maintaining the historic mapping to meta zones for each time zone. The time zones in the above example ("America/New_York", "America/Detroit"...) are mapped to the meta zone "America_Eastern".

Sometimes, a time zone is mapped to a different time zone in the past. For example, "America/Indiana/Knox" had been moving "Eastern Time" and "Central Time" back and forth. Therefore, it is necessary that time zone to meta zones mapping data are stored by date range.

Note: The methods in this class assume that time zone IDs are already canonicalized. For example, you may not get proper result returned by a method with time zone ID "America/Indiana/Indianapolis", because it's not a canonical time zone ID (the canonical time zone ID for the time zone is "America/Indianapolis". See TimeZone#getCanonicalID(const UnicodeString& id, UnicodeString& canonicalID, UErrorCode& status) about ICU canonical time zone IDs.

In CLDR, most of time zone display names except location names are provided through meta zones. But a time zone may have a specific name that is not shared with other time zones.

For example, time zone "Europe/London" has English long name for standard time "Greenwich Mean Time", which is also shared with other time zones. However, the long name for daylight saving time is "British Summer Time", which is only used for "Europe/London".

getTimeZoneDisplayName is designed for accessing a name only used by a single time zone. But is not necessarily mean that a subclass implementation use the same model with CLDR. A subclass implementation may provide time zone names only through getTimeZoneDisplayName, or only through getMetaZoneDisplayName, or both.

The default `TimeZoneNames` implementation returned by createInstance uses the locale data imported from CLDR. In CLDR, set of meta zone IDs and mappings between zone IDs and meta zone IDs are shared by all locales. Therefore, the behavior of getAvailableMetaZoneIDs, getMetaZoneID, and getReferenceZoneID won't be changed no matter what locale is used for getting an instance of `TimeZoneNames`.

Stable:
  ICU 50

Definition at line 131 of file tznames.h.

## Constructor & Destructor Documentation

## ◆ ~TimeZoneNames()

virtual icu::TimeZoneNames::~TimeZoneNames | ( |  | ) |
| virtual

Destructor.

Stable:
  ICU 50

## Member Function Documentation

## ◆ clone()

virtual TimeZoneNames* icu::TimeZoneNames::clone | ( |  | ) | const
| pure virtual

Clone this object polymorphically.

The caller is responsible for deleting the result when done.

Returns
  A copy of the object

Stable:
  ICU 50

## ◆ createInstance()

static TimeZoneNames* icu::TimeZoneNames::createInstance | ( | const Locale & | locale,
|  | UErrorCode & | status
| ) |  |
| static

Returns an instance of `TimeZoneNames` for the specified locale.

Parameters

  locale | The locale.
  status | Receives the status.

Returns
  An instance of `TimeZoneNames`

Stable:
  ICU 50

## ◆ createTZDBInstance()

static TimeZoneNames* icu::TimeZoneNames::createTZDBInstance | ( | const Locale & | locale,
|  | UErrorCode & | status
| ) |  |
| static

Returns an instance of `TimeZoneNames` containing only short specific zone names (SHORT_STANDARD and SHORT_DAYLIGHT), compatible with the IANA tz database's zone abbreviations (not localized).

Note: The input locale is used for resolving ambiguous names (e.g. "IST" is parsed as Israel Standard Time for Israel, while it is parsed as India Standard Time for all other regions). The zone names returned by this instance are not localized.

Stable:
  ICU 54

## ◆ find()

virtual MatchInfoCollection* icu::TimeZoneNames::find | ( | const UnicodeString & | text,
|  | int32_t | start,
|  | uint32_t | types,
|  | UErrorCode & | status
| ) |  | const
| pure virtual

Finds time zone name prefix matches for the input text at the given offset and returns a collection of the matches.

Parameters

  text | The text.
  start | The starting offset within the text.
  types | The set of name types represented by bitwise flags of UTimeZoneNameType enums, or UTZNM_UNKNOWN for all name types.
  status | Receives the status.

Returns
  A collection of matches (owned by the caller), or NULL if no matches are found.

See also
  UTimeZoneNameType
  MatchInfoCollection

Internal:
  Do not use. This API is for internal use only.

## ◆ getAvailableMetaZoneIDs() [1/2]

virtual StringEnumeration* icu::TimeZoneNames::getAvailableMetaZoneIDs | ( | const UnicodeString & | tzID,
|  | UErrorCode & | status
| ) |  | const
| pure virtual

Returns an enumeration of all available meta zone IDs used by the given time zone.

Parameters

  tzID | The canonical time zone ID.
  status | Receives the status.

Returns
  an enumeration object, owned by the caller.

Stable:
  ICU 50

## ◆ getAvailableMetaZoneIDs() [2/2]

virtual StringEnumeration* icu::TimeZoneNames::getAvailableMetaZoneIDs | ( | UErrorCode & | status | ) | const
| pure virtual

Returns an enumeration of all available meta zone IDs.

Parameters

  status | Receives the status.

Returns
  an enumeration object, owned by the caller.

Stable:
  ICU 50

## ◆ getDisplayName()

virtual UnicodeString& icu::TimeZoneNames::getDisplayName | ( | const UnicodeString & | tzID,
|  | UTimeZoneNameType | type,
|  | UDate | date,
|  | UnicodeString & | name
| ) |  | const
| virtual

Returns the display name of the time zone at the given date.

Note: This method calls the subclass's getTimeZoneDisplayName first. When the result is bogus, this method calls getMetaZoneID to get the meta zone ID mapped from the time zone, then calls getMetaZoneDisplayName.

Parameters

  tzID | The canonical time zone ID.
  type | The display name type. See UTimeZoneNameType.
  date | The date.
  name | Receives the display name for the time zone at the given date. When this object does not have a localized display name for the time zone with the specified type and date, "bogus" state is set.

Returns
  A reference to the result.

Stable:
  ICU 50

## ◆ getDisplayNames()

virtual void icu::TimeZoneNames::getDisplayNames | ( | const UnicodeString & | tzID,
|  | const UTimeZoneNameType | types[],
|  | int32_t | numTypes,
|  | UDate | date,
|  | UnicodeString | dest[],
|  | UErrorCode & | status
| ) |  | const
| virtual

Internal:
  Do not use.

This API is for internal use only. ICU internal only, for specific users only until proposed publicly.

## ◆ getExemplarLocationName()

virtual UnicodeString& icu::TimeZoneNames::getExemplarLocationName | ( | const UnicodeString & | tzID,
|  | UnicodeString & | name
| ) |  | const
| virtual

Returns the exemplar location name for the given time zone.

When this object does not have a localized location name, the default implementation may still returns a programmatically generated name with the logic described below.

1. Check if the ID contains "/". If not, return null.
2. Check if the ID does not start with "Etc/" or "SystemV/". If it does, return null.
3. Extract a substring after the last occurrence of "/".
4. Replace "_" with " ".

For example, "New York" is returned for the time zone ID "America/New_York" when this object does not have the localized location name.

Parameters

  tzID | The canonical time zone ID
  name | Receives the exemplar location name for the given time zone, or "bogus" state is set when a localized location name is not available and the fallback logic described above cannot extract location from the ID.

Returns
  A reference to the result.

Stable:
  ICU 50

## ◆ getMetaZoneDisplayName()

virtual UnicodeString& icu::TimeZoneNames::getMetaZoneDisplayName | ( | const UnicodeString & | mzID,
|  | UTimeZoneNameType | type,
|  | UnicodeString & | name
| ) |  | const
| pure virtual

Returns the display name of the meta zone.

Parameters

  mzID | The meta zone ID.
  type | The display name type. See UTimeZoneNameType.
  name | Receives the display name of the meta zone. When this object does not have a localized display name for the given meta zone with the specified type or the implementation does not provide any display names associated with meta zones, "bogus" state is set.

Returns
  A reference to the result.

Stable:
  ICU 50

## ◆ getMetaZoneID()

virtual UnicodeString& icu::TimeZoneNames::getMetaZoneID | ( | const UnicodeString & | tzID,
|  | UDate | date,
|  | UnicodeString & | mzID
| ) |  | const
| pure virtual

Returns the meta zone ID for the given canonical time zone ID at the given date.

Parameters

  tzID | The canonical time zone ID.
  date | The date.
  mzID | Receives the meta zone ID for the given time zone ID at the given date. If the time zone does not have a corresponding meta zone at the given date or the implementation does not support meta zones, "bogus" state is set.

Returns
  A reference to the result.

Stable:
  ICU 50

## ◆ getReferenceZoneID()

virtual UnicodeString& icu::TimeZoneNames::getReferenceZoneID | ( | const UnicodeString & | mzID,
|  | const char * | region,
|  | UnicodeString & | tzID
| ) |  | const
| pure virtual

Returns the reference zone ID for the given meta zone ID for the region.

Note: Each meta zone must have a reference zone associated with a special region "001" (world). Some meta zones may have region specific reference zone IDs other than the special region "001". When a meta zone does not have any region specific reference zone IDs, this method return the reference zone ID for the special region "001" (world).

Parameters

  mzID | The meta zone ID.
  region | The region.
  tzID | Receives the reference zone ID ("golden zone" in the LDML specification) for the given time zone ID for the region. If the meta zone is unknown or the implementation does not support meta zones, "bogus" state is set.

Returns
  A reference to the result.

Stable:
  ICU 50

## ◆ getTimeZoneDisplayName()

virtual UnicodeString& icu::TimeZoneNames::getTimeZoneDisplayName | ( | const UnicodeString & | tzID,
|  | UTimeZoneNameType | type,
|  | UnicodeString & | name
| ) |  | const
| pure virtual

Returns the display name of the time zone.

Unlike getDisplayName, this method does not get a name from a meta zone used by the time zone.

Parameters

  tzID | The canonical time zone ID.
  type | The display name type. See UTimeZoneNameType.
  name | Receives the display name for the time zone. When this object does not have a localized display name for the given time zone with the specified type, "bogus" state is set.

Returns
  A reference to the result.

Stable:
  ICU 50

## ◆ loadAllDisplayNames()

virtual void icu::TimeZoneNames::loadAllDisplayNames | ( | UErrorCode & | status | ) |
| virtual

Internal:
  Do not use.

This API is for internal use only. ICU internal only, for specific users only until proposed publicly.

## ◆ operator!=()

UBool icu::TimeZoneNames::operator!= | ( | const TimeZoneNames & | other | ) | const
| inline

Return true if the given TimeZoneNames objects are not semantically equal.

Parameters

  other | the object to be compared with.

Returns
  Return true if the given Format objects are not semantically equal.

Stable:
  ICU 50

Definition at line 154 of file tznames.h.

References icu::operator==().

## ◆ operator==()

virtual UBool icu::TimeZoneNames::operator== | ( | const TimeZoneNames & | other | ) | const
| pure virtual

Return true if the given TimeZoneNames objects are semantically equal.

Parameters

  other | the object to be compared with.

Returns
  Return true if the given Format objects are semantically equal.

Stable:
  ICU 50

The documentation for this class was generated from the following file:

- tznames.h