ICU 78.1 78.1 |
TimeZoneFormat supports time zone display name formatting and parsing.More...
#include <tzfmt.h>

Public Member Functions | |
| U_I18N_API | TimeZoneFormat (constTimeZoneFormat &other) |
| Copy constructor.More... | |
| virtualU_I18N_API | ~TimeZoneFormat () |
| Destructor.More... | |
| U_I18N_APITimeZoneFormat & | operator= (constTimeZoneFormat &other) |
| Assignment operator.More... | |
| virtualU_I18N_API bool | operator== (constFormat &other) const override |
| Return true if the givenFormat objects are semantically equal.More... | |
| virtualU_I18N_APITimeZoneFormat * | clone () const override |
| Clone this object polymorphically.More... | |
| U_I18N_API constTimeZoneNames * | getTimeZoneNames () const |
| Returns the time zone display name data used by this instance.More... | |
| U_I18N_API void | adoptTimeZoneNames (TimeZoneNames *tznames) |
| Sets the time zone display name data to this format instance.More... | |
| U_I18N_API void | setTimeZoneNames (constTimeZoneNames &tznames) |
| Sets the time zone display name data to this format instance.More... | |
| U_I18N_APIUnicodeString & | getGMTPattern (UnicodeString &pattern) const |
| Returns the localized GMT format pattern.More... | |
| U_I18N_API void | setGMTPattern (constUnicodeString &pattern,UErrorCode &status) |
| Sets the localized GMT format pattern.More... | |
| U_I18N_APIUnicodeString & | getGMTOffsetPattern (UTimeZoneFormatGMTOffsetPatternType type,UnicodeString &pattern) const |
| Returns the offset pattern used for localized GMT format.More... | |
| U_I18N_API void | setGMTOffsetPattern (UTimeZoneFormatGMTOffsetPatternType type, constUnicodeString &pattern,UErrorCode &status) |
| Sets the offset pattern for the given offset type.More... | |
| U_I18N_APIUnicodeString & | getGMTOffsetDigits (UnicodeString &digits) const |
| Returns the decimal digit characters used for localized GMT format.More... | |
| U_I18N_API void | setGMTOffsetDigits (constUnicodeString &digits,UErrorCode &status) |
| Sets the decimal digit characters used for localized GMT format.More... | |
| U_I18N_APIUnicodeString & | getGMTZeroFormat (UnicodeString &gmtZeroFormat) const |
| Returns the localized GMT format string for GMT(UTC) itself (GMT offset is 0).More... | |
| U_I18N_API void | setGMTZeroFormat (constUnicodeString &gmtZeroFormat,UErrorCode &status) |
| Sets the localized GMT format string for GMT(UTC) itself (GMT offset is 0).More... | |
| U_I18N_API uint32_t | getDefaultParseOptions () const |
| Returns the bitwise flags of UTimeZoneFormatParseOption representing the default parse options used by this object.More... | |
| U_I18N_API void | setDefaultParseOptions (uint32_t flags) |
| Sets the default parse options.More... | |
| U_I18N_APIUnicodeString & | formatOffsetISO8601Basic (int32_t offset,UBool useUtcIndicator,UBool isShort,UBool ignoreSeconds,UnicodeString &result,UErrorCode &status) const |
| Returns the ISO 8601 basic time zone string for the given offset.More... | |
| U_I18N_APIUnicodeString & | formatOffsetISO8601Extended (int32_t offset,UBool useUtcIndicator,UBool isShort,UBool ignoreSeconds,UnicodeString &result,UErrorCode &status) const |
| Returns the ISO 8601 extended time zone string for the given offset.More... | |
| U_I18N_APIUnicodeString & | formatOffsetLocalizedGMT (int32_t offset,UnicodeString &result,UErrorCode &status) const |
| Returns the localized GMT(UTC) offset format for the given offset.More... | |
| U_I18N_APIUnicodeString & | formatOffsetShortLocalizedGMT (int32_t offset,UnicodeString &result,UErrorCode &status) const |
| Returns the short localized GMT(UTC) offset format for the given offset.More... | |
| virtualU_I18N_APIUnicodeString & | format (UTimeZoneFormatStyle style, constTimeZone &tz,UDate date,UnicodeString &name,UTimeZoneFormatTimeType *timeType=nullptr) const |
| Returns the display name of the time zone at the given date for the style.More... | |
| U_I18N_API int32_t | parseOffsetISO8601 (constUnicodeString &text,ParsePosition &pos) const |
| Returns offset from GMT(UTC) in milliseconds for the given ISO 8601 style time zone string.More... | |
| U_I18N_API int32_t | parseOffsetLocalizedGMT (constUnicodeString &text,ParsePosition &pos) const |
| Returns offset from GMT(UTC) in milliseconds for the given localized GMT offset format string.More... | |
| U_I18N_API int32_t | parseOffsetShortLocalizedGMT (constUnicodeString &text,ParsePosition &pos) const |
| Returns offset from GMT(UTC) in milliseconds for the given short localized GMT offset format string.More... | |
| virtualU_I18N_APITimeZone * | parse (UTimeZoneFormatStyle style, constUnicodeString &text,ParsePosition &pos, int32_t parseOptions,UTimeZoneFormatTimeType *timeType=nullptr) const |
Returns aTimeZone by parsing the time zone string according to the given parse position, the specified format style and parse options.More... | |
| U_I18N_APITimeZone * | parse (UTimeZoneFormatStyle style, constUnicodeString &text,ParsePosition &pos,UTimeZoneFormatTimeType *timeType=nullptr) const |
Returns aTimeZone by parsing the time zone string according to the given parse position, the specified format style and the default parse options.More... | |
| virtualU_I18N_APIUnicodeString & | format (constFormattable &obj,UnicodeString &appendTo,FieldPosition &pos,UErrorCode &status) const override |
| Format an object to produce a time zone display string using localized GMT offset format.More... | |
| virtualU_I18N_API void | parseObject (constUnicodeString &source,Formattable &result,ParsePosition &parse_pos) const override |
| Parse a string to produce an object.More... | |
| virtualU_I18N_APIUClassID | getDynamicClassID () const override |
| ICU "poor man's RTTI", returns a UClassID for the actual class.More... | |
| U_I18N_APIUnicodeString & | format (constFormattable &obj,UnicodeString &appendTo,UErrorCode &status) const |
| Formats an object to produce a string.More... | |
| virtualU_I18N_APIUnicodeString & | format (constFormattable &obj,UnicodeString &appendTo,FieldPosition &pos,UErrorCode &status) const=0 |
| Format an object to produce a string.More... | |
| virtualU_I18N_APIUnicodeString & | format (constFormattable &obj,UnicodeString &appendTo,FieldPositionIterator *posIter,UErrorCode &status) const |
| Format an object to produce a string.More... | |
Public Member Functions inherited fromicu::Format | |
| virtualU_I18N_API | ~Format () |
| Destructor.More... | |
| U_I18N_API bool | operator!= (constFormat &other) const |
| Return true if the givenFormat objects are not semantically equal.More... | |
| U_I18N_APIUnicodeString & | format (constFormattable &obj,UnicodeString &appendTo,UErrorCode &status) const |
| Formats an object to produce a string.More... | |
| virtualU_I18N_APIUnicodeString & | format (constFormattable &obj,UnicodeString &appendTo,FieldPositionIterator *posIter,UErrorCode &status) const |
| Format an object to produce a string.More... | |
| U_I18N_API void | parseObject (constUnicodeString &source,Formattable &result,UErrorCode &status) const |
| Parses a string to produce an object.More... | |
| U_I18N_APILocale | getLocale (ULocDataLocaleType type,UErrorCode &status) const |
| Get the locale for this format object.More... | |
| U_I18N_API const char * | getLocaleID (ULocDataLocaleType type,UErrorCode &status) const |
| Get the locale for this format object.More... | |
Public Member Functions inherited fromicu::UObject | |
| virtual | ~UObject () |
| Destructor.More... | |
Static Public Member Functions | |
| staticU_I18N_APITimeZoneFormat * | createInstance (constLocale &locale,UErrorCode &status) |
Creates an instance ofTimeZoneFormat for the given locale.More... | |
| staticU_I18N_APIUClassID | getStaticClassID () |
| ICU "poor man's RTTI", returns a UClassID for this class.More... | |
Protected Member Functions | |
| U_I18N_API | TimeZoneFormat (constLocale &locale,UErrorCode &status) |
| Constructs aTimeZoneFormat object for the specified locale.More... | |
Protected Member Functions inherited fromicu::Format | |
| U_I18N_API void | setLocaleIDs (const char *valid, const char *actual) |
| U_I18N_API | Format () |
| Default constructor for subclass use only.More... | |
| U_I18N_API | Format (constFormat &) |
| U_I18N_APIFormat & | operator= (constFormat &) |
Additional Inherited Members | |
Static Protected Member Functions inherited fromicu::Format | |
| staticU_I18N_API void | syntaxError (constUnicodeString &pattern, int32_t pos,UParseError &parseError) |
| Simple function for initializing aUParseError from aUnicodeString.More... | |
TimeZoneFormat supports time zone display name formatting and parsing.
An instance ofTimeZoneFormat works as a subformatter ofSimpleDateFormat, but you can also directly get a new instance ofTimeZoneFormat and formatting/parsing time zone display names.
ICU implements the time zone display names defined byUTS#35 Unicode Locale Data Markup Language (LDML).TimeZoneNames represents the time zone display name data model and this class implements the algorithm for actual formatting and parsing.
| U_I18N_API icu::TimeZoneFormat::TimeZoneFormat | ( | constTimeZoneFormat & | other | ) |
Copy constructor.
| virtual |
Destructor.
| protected |
Constructs aTimeZoneFormat object for the specified locale.
| locale | the locale |
| status | receives the status. |
| U_I18N_API void icu::TimeZoneFormat::adoptTimeZoneNames | ( | TimeZoneNames * | tznames | ) |
Sets the time zone display name data to this format instance.
The caller should not delete the TimeZoenNames object after it is adopted by this call.
| tznames | TimeZoneNames object to be adopted. |
| overridevirtual |
Clone this object polymorphically.
The caller is responsible for deleting the result when done.
Implementsicu::Format.
| static |
Creates an instance ofTimeZoneFormat for the given locale.
| locale | The locale. |
| status | Receives the status. |
TimeZoneFormat for the given locale, owned by the caller.
| overridevirtual |
Format an object to produce a time zone display string using localized GMT offset format.
This method handlesFormattable objects with aTimeZone. If a theFormattable object type is not aTimeZone, then it returns a failing UErrorCode.
| obj | The object to format. Must be aTimeZone. |
| appendTo | Output parameter to receive result. Result is appended to existing contents. |
| pos | On input: an alignment field, if desired. On output: the offsets of the alignment field. |
| status | Output param filled with success/failure status. |
Implementsicu::Format.
| virtualU_I18N_APIUnicodeString& icu::Format::format |
Format an object to produce a string.
This is a pure virtual method which subclasses must implement. This method allows polymorphic formatting ofFormattable objects. If a subclass ofFormat receives aFormattable object type it doesn't handle (e.g., if a numericFormattable is passed to aDateFormat object) then it returns a failing UErrorCode.
| obj | The object to format. |
| appendTo | Output parameter to receive result. Result is appended to existing contents. |
| pos | On input: an alignment field, if desired. On output: the offsets of the alignment field. |
| status | Output param filled with success/failure status. |
| virtualU_I18N_APIUnicodeString& icu::Format::format |
Format an object to produce a string.
Subclasses should override this method. This method allows polymorphic formatting ofFormattable objects. If a subclass ofFormat receives aFormattable object type it doesn't handle (e.g., if a numericFormattable is passed to aDateFormat object) then it returns a failing UErrorCode.
| obj | The object to format. |
| appendTo | Output parameter to receive result. Result is appended to existing contents. |
| posIter | On return, can be used to iterate over positions of fields generated by this format call. |
| status | Output param filled with success/failure status. |
| U_I18N_APIUnicodeString& icu::Format::format |
Formats an object to produce a string.
| obj | The object to format. |
| appendTo | Output parameter to receive result. Result is appended to existing contents. |
| status | Output parameter filled in with success or failure status. |
| virtual |
Returns the display name of the time zone at the given date for the style.
| style | The style (e.g.UTZFMT_STYLE_GENERIC_LONG,UTZFMT_STYLE_LOCALIZED_GMT...) |
| tz | The time zone. |
| date | The date. |
| name | Receives the display name. |
| timeType | the output argument for receiving the time type (standard/daylight/unknown) used for the display name, or nullptr if the information is not necessary. |
| U_I18N_APIUnicodeString& icu::TimeZoneFormat::formatOffsetISO8601Basic | ( | int32_t | offset, |
| UBool | useUtcIndicator, | ||
| UBool | isShort, | ||
| UBool | ignoreSeconds, | ||
| UnicodeString & | result, | ||
| UErrorCode & | status | ||
| ) | const |
Returns the ISO 8601 basic time zone string for the given offset.
For example, "-08", "-0830" and "Z"
| offset | the offset from GMT(UTC) in milliseconds. |
| useUtcIndicator | true if ISO 8601 UTC indicator "Z" is used when the offset is 0. |
| isShort | true if shortest form is used. |
| ignoreSeconds | true if non-zero offset seconds is appended. |
| result | Receives the ISO format string. |
| status | Receives the status |
| U_I18N_APIUnicodeString& icu::TimeZoneFormat::formatOffsetISO8601Extended | ( | int32_t | offset, |
| UBool | useUtcIndicator, | ||
| UBool | isShort, | ||
| UBool | ignoreSeconds, | ||
| UnicodeString & | result, | ||
| UErrorCode & | status | ||
| ) | const |
Returns the ISO 8601 extended time zone string for the given offset.
For example, "-08:00", "-08:30" and "Z"
| offset | the offset from GMT(UTC) in milliseconds. |
| useUtcIndicator | true if ISO 8601 UTC indicator "Z" is used when the offset is 0. |
| isShort | true if shortest form is used. |
| ignoreSeconds | true if non-zero offset seconds is appended. |
| result | Receives the ISO format string. |
| status | Receives the status |
| U_I18N_APIUnicodeString& icu::TimeZoneFormat::formatOffsetLocalizedGMT | ( | int32_t | offset, |
| UnicodeString & | result, | ||
| UErrorCode & | status | ||
| ) | const |
Returns the localized GMT(UTC) offset format for the given offset.
The localized GMT offset is defined by;
This format always uses 2 digit hours and minutes. When the given offset has non-zero seconds, 2 digit seconds field will be appended. For example, GMT+05:00 and GMT+05:28:06.
| offset | the offset from GMT(UTC) in milliseconds. |
| status | Receives the status |
| result | Receives the localized GMT format string. |
| U_I18N_APIUnicodeString& icu::TimeZoneFormat::formatOffsetShortLocalizedGMT | ( | int32_t | offset, |
| UnicodeString & | result, | ||
| UErrorCode & | status | ||
| ) | const |
Returns the short localized GMT(UTC) offset format for the given offset.
The short localized GMT offset is defined by;
This format uses the shortest representation of offset. The hours field does not have leading zero and lower fields with zero will be truncated. For example, GMT+5 and GMT+530.
| offset | the offset from GMT(UTC) in milliseconds. |
| status | Receives the status |
| result | Receives the short localized GMT format string. |
| U_I18N_API uint32_t icu::TimeZoneFormat::getDefaultParseOptions | ( | ) | const |
Returns the bitwise flags of UTimeZoneFormatParseOption representing the default parse options used by this object.
| overridevirtual |
ICU "poor man's RTTI", returns a UClassID for the actual class.
Reimplemented fromicu::UObject.
| U_I18N_APIUnicodeString& icu::TimeZoneFormat::getGMTOffsetDigits | ( | UnicodeString & | digits | ) | const |
Returns the decimal digit characters used for localized GMT format.
The return string contains exactly 10 code points (may include Unicode supplementary character) representing digit 0 to digit 9 in the ascending order.
| digits | Receives the decimal digits used for localized GMT format. |
| U_I18N_APIUnicodeString& icu::TimeZoneFormat::getGMTOffsetPattern | ( | UTimeZoneFormatGMTOffsetPatternType | type, |
| UnicodeString & | pattern | ||
| ) | const |
Returns the offset pattern used for localized GMT format.
| type | The offset pattern type enum. |
| pattern | Receives the offset pattern. |
| U_I18N_APIUnicodeString& icu::TimeZoneFormat::getGMTPattern | ( | UnicodeString & | pattern | ) | const |
Returns the localized GMT format pattern.
| pattern | Receives the localized GMT format pattern. |
| U_I18N_APIUnicodeString& icu::TimeZoneFormat::getGMTZeroFormat | ( | UnicodeString & | gmtZeroFormat | ) | const |
Returns the localized GMT format string for GMT(UTC) itself (GMT offset is 0).
| gmtZeroFormat | Receives the localized GMT string string for GMT(UTC) itself. |
| static |
ICU "poor man's RTTI", returns a UClassID for this class.
| U_I18N_API constTimeZoneNames* icu::TimeZoneFormat::getTimeZoneNames | ( | ) | const |
Returns the time zone display name data used by this instance.
| U_I18N_APITimeZoneFormat& icu::TimeZoneFormat::operator= | ( | constTimeZoneFormat & | other | ) |
Assignment operator.
| overridevirtual |
Return true if the givenFormat objects are semantically equal.
Objects of different subclasses are considered unequal.
| other | The object to be compared with. |
Implementsicu::Format.
| virtual |
Returns aTimeZone by parsing the time zone string according to the given parse position, the specified format style and parse options.
| text | The text contains a time zone string at the position. |
| style | The format style |
| pos | The position. |
| parseOptions | The parse options represented by bitwise flags of UTimeZoneFormatParseOption. |
| timeType | The output argument for receiving the time type (standard/daylight/unknown), or nullptr if the information is not necessary. |
TimeZone, or null if the input could not be parsed.| U_I18N_APITimeZone* icu::TimeZoneFormat::parse | ( | UTimeZoneFormatStyle | style, |
| constUnicodeString & | text, | ||
| ParsePosition & | pos, | ||
| UTimeZoneFormatTimeType * | timeType =nullptr | ||
| ) | const |
Returns aTimeZone by parsing the time zone string according to the given parse position, the specified format style and the default parse options.
| text | The text contains a time zone string at the position. |
| style | The format style |
| pos | The position. |
| timeType | The output argument for receiving the time type (standard/daylight/unknown), or nullptr if the information is not necessary. |
TimeZone, or null if the input could not be parsed.
| overridevirtual |
Parse a string to produce an object.
This methods handles parsing of time zone display strings intoFormattable objects withTimeZone.
| source | The string to be parsed into an object. |
| result | Formattable to be set to the parse result. If parse fails, return contents are undefined. |
| parse_pos | The position to start parsing at. Upon return this param is set to the position after the last character successfully parsed. If the source is not parsed successfully, this param will remain unchanged. |
Implementsicu::Format.
| U_I18N_API int32_t icu::TimeZoneFormat::parseOffsetISO8601 | ( | constUnicodeString & | text, |
| ParsePosition & | pos | ||
| ) | const |
Returns offset from GMT(UTC) in milliseconds for the given ISO 8601 style time zone string.
When the given string is not an ISO 8601 time zone string, this method sets the current position as the error index toParsePosition pos and returns 0.
| text | The text contains ISO8601 style time zone string (e.g. "-08:00", "Z") at the position. |
| pos | TheParsePosition object. |
| U_I18N_API int32_t icu::TimeZoneFormat::parseOffsetLocalizedGMT | ( | constUnicodeString & | text, |
| ParsePosition & | pos | ||
| ) | const |
Returns offset from GMT(UTC) in milliseconds for the given localized GMT offset format string.
When the given string cannot be parsed, this method sets the current position as the error index toParsePosition pos and returns 0.
| text | The text contains a localized GMT offset string at the position. |
| pos | TheParsePosition object. |
| U_I18N_API int32_t icu::TimeZoneFormat::parseOffsetShortLocalizedGMT | ( | constUnicodeString & | text, |
| ParsePosition & | pos | ||
| ) | const |
Returns offset from GMT(UTC) in milliseconds for the given short localized GMT offset format string.
When the given string cannot be parsed, this method sets the current position as the error index toParsePosition pos and returns 0.
| text | The text contains a short localized GMT offset string at the position. |
| pos | TheParsePosition object. |
| U_I18N_API void icu::TimeZoneFormat::setDefaultParseOptions | ( | uint32_t | flags | ) |
Sets the default parse options.
Note: By default, an instance ofTimeZoneFormat created bycreateInstance has no parse options set (UTZFMT_PARSE_OPTION_NONE). To specify multiple options, use bitwise flags of UTimeZoneFormatParseOption.
| U_I18N_API void icu::TimeZoneFormat::setGMTOffsetDigits | ( | constUnicodeString & | digits, |
| UErrorCode & | status | ||
| ) |
Sets the decimal digit characters used for localized GMT format.
The inputdigits must contain exactly 10 code points (Unicode supplementary characters are also allowed) representing digit 0 to digit 9 in the ascending order. When the inputdigits does not satisfy the condition,U_ILLEGAL_ARGUMENT_ERROR will be set to the return status.
| digits | The decimal digits used for localized GMT format. |
| status | Receives the status. |
| U_I18N_API void icu::TimeZoneFormat::setGMTOffsetPattern | ( | UTimeZoneFormatGMTOffsetPatternType | type, |
| constUnicodeString & | pattern, | ||
| UErrorCode & | status | ||
| ) |
Sets the offset pattern for the given offset type.
| type | The offset pattern type enum. |
| pattern | The offset pattern used for localized GMT format for the type. |
| status | Receives the status. |
| U_I18N_API void icu::TimeZoneFormat::setGMTPattern | ( | constUnicodeString & | pattern, |
| UErrorCode & | status | ||
| ) |
Sets the localized GMT format pattern.
The pattern must contain a single argument {0}, for example "GMT {0}".
| pattern | The localized GMT format pattern to be used by this object. |
| status | Receives the status. |
| U_I18N_API void icu::TimeZoneFormat::setGMTZeroFormat | ( | constUnicodeString & | gmtZeroFormat, |
| UErrorCode & | status | ||
| ) |
Sets the localized GMT format string for GMT(UTC) itself (GMT offset is 0).
| gmtZeroFormat | The localized GMT format string for GMT(UTC). |
| status | Receives the status. |
| U_I18N_API void icu::TimeZoneFormat::setTimeZoneNames | ( | constTimeZoneNames & | tznames | ) |
Sets the time zone display name data to this format instance.
| tznames | TimeZoneNames object to be set. |