ICU 76.1 76.1
|
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>
Data Structures | |
class | MatchInfoCollection |
MatchInfoCollection represents a collection of time zone name matches used by TimeZoneNames#find . More... | |
Public Member Functions | |
virtual | ~TimeZoneNames () |
Destructor. | |
virtual bool | operator== (const TimeZoneNames &other) const =0 |
Return true if the given TimeZoneNames objects are semantically equal. | |
bool | operator!= (const TimeZoneNames &other) const |
Return true if the given TimeZoneNames objects are not semantically equal. | |
virtual TimeZoneNames * | clone () const =0 |
Clone this object polymorphically. | |
virtual StringEnumeration * | getAvailableMetaZoneIDs (UErrorCode &status) const =0 |
Returns an enumeration of all available meta zone IDs. | |
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. | |
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. | |
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. | |
virtual UnicodeString & | getMetaZoneDisplayName (const UnicodeString &mzID, UTimeZoneNameType type, UnicodeString &name) const =0 |
Returns the display name of the meta zone. | |
virtual UnicodeString & | getTimeZoneDisplayName (const UnicodeString &tzID, UTimeZoneNameType type, UnicodeString &name) const =0 |
Returns the display name of the time zone. | |
virtual UnicodeString & | getExemplarLocationName (const UnicodeString &tzID, UnicodeString &name) const |
Returns the exemplar location name for the given time zone. | |
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. | |
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. | |
Public Member Functions inherited from icu::UObject | |
virtual | ~UObject () |
Destructor. | |
virtual UClassID | getDynamicClassID () const |
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class. | |
Static Public Member Functions | |
static TimeZoneNames * | createInstance (const Locale &locale, UErrorCode &status) |
Returns an instance of TimeZoneNames for the specified locale. | |
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). | |
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
.
|
pure virtual |
Clone this object polymorphically.
The caller is responsible for deleting the result when done.
|
static |
Returns an instance of TimeZoneNames
for the specified locale.
locale | The locale. |
status | Receives the status. |
TimeZoneNames
|
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.
|
pure virtual |
Finds time zone name prefix matches for the input text at the given offset and returns a collection of the matches.
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. |
|
pure virtual |
Returns an enumeration of all available meta zone IDs used by the given time zone.
tzID | The canonical time zone ID. |
status | Receives the status. |
|
pure virtual |
Returns an enumeration of all available meta zone IDs.
status | Receives the status. |
|
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
.
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. |
|
virtual |
|
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.
For example, "New York" is returned for the time zone ID "America/New_York" when this object does not have the localized location name.
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. |
|
pure virtual |
Returns the display name of the meta zone.
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. |
|
pure virtual |
Returns the meta zone ID for the given canonical time zone ID at the given date.
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. |
|
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).
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. |
|
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.
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. |
|
virtual |
|
inline |
Return true if the given TimeZoneNames objects are not semantically equal.
other | the object to be compared with. |
Definition at line 154 of file tznames.h.
References icu::operator==().
|
pure virtual |
Return true if the given TimeZoneNames objects are semantically equal.
other | the object to be compared with. |