1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/unicode/tzfmt.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,1085 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* Copyright (C) 2011-2013, International Business Machines Corporation and * 1.7 +* others. All Rights Reserved. * 1.8 +******************************************************************************* 1.9 +*/ 1.10 +#ifndef __TZFMT_H 1.11 +#define __TZFMT_H 1.12 + 1.13 +/** 1.14 + * \file 1.15 + * \brief C++ API: TimeZoneFormat 1.16 + */ 1.17 + 1.18 +#include "unicode/utypes.h" 1.19 + 1.20 +#if !UCONFIG_NO_FORMATTING 1.21 + 1.22 +#include "unicode/format.h" 1.23 +#include "unicode/timezone.h" 1.24 +#include "unicode/tznames.h" 1.25 + 1.26 +U_CDECL_BEGIN 1.27 +/** 1.28 + * Constants for time zone display format style used by format/parse APIs 1.29 + * in TimeZoneFormat. 1.30 + * @stable ICU 50 1.31 + */ 1.32 +typedef enum UTimeZoneFormatStyle { 1.33 + /** 1.34 + * Generic location format, such as "United States Time (New York)", "Italy Time" 1.35 + * @stable ICU 50 1.36 + */ 1.37 + UTZFMT_STYLE_GENERIC_LOCATION, 1.38 + /** 1.39 + * Generic long non-location format, such as "Eastern Time". 1.40 + * @stable ICU 50 1.41 + */ 1.42 + UTZFMT_STYLE_GENERIC_LONG, 1.43 + /** 1.44 + * Generic short non-location format, such as "ET". 1.45 + * @stable ICU 50 1.46 + */ 1.47 + UTZFMT_STYLE_GENERIC_SHORT, 1.48 + /** 1.49 + * Specific long format, such as "Eastern Standard Time". 1.50 + * @stable ICU 50 1.51 + */ 1.52 + UTZFMT_STYLE_SPECIFIC_LONG, 1.53 + /** 1.54 + * Specific short format, such as "EST", "PDT". 1.55 + * @stable ICU 50 1.56 + */ 1.57 + UTZFMT_STYLE_SPECIFIC_SHORT, 1.58 + /** 1.59 + * Localized GMT offset format, such as "GMT-05:00", "UTC+0100" 1.60 + * @stable ICU 50 1.61 + */ 1.62 + UTZFMT_STYLE_LOCALIZED_GMT, 1.63 +#ifndef U_HIDE_DRAFT_API 1.64 + /** 1.65 + * Short localized GMT offset format, such as "GMT-5", "UTC+1:30" 1.66 + * This style is equivalent to the LDML date format pattern "O". 1.67 + * @draft ICU 51 1.68 + */ 1.69 + UTZFMT_STYLE_LOCALIZED_GMT_SHORT, 1.70 + /** 1.71 + * Short ISO 8601 local time difference (basic format) or the UTC indicator. 1.72 + * For example, "-05", "+0530", and "Z"(UTC). 1.73 + * This style is equivalent to the LDML date format pattern "X". 1.74 + * @draft ICU 51 1.75 + */ 1.76 + UTZFMT_STYLE_ISO_BASIC_SHORT, 1.77 + /** 1.78 + * Short ISO 8601 locale time difference (basic format). 1.79 + * For example, "-05" and "+0530". 1.80 + * This style is equivalent to the LDML date format pattern "x". 1.81 + * @draft ICU 51 1.82 + */ 1.83 + UTZFMT_STYLE_ISO_BASIC_LOCAL_SHORT, 1.84 + /** 1.85 + * Fixed width ISO 8601 local time difference (basic format) or the UTC indicator. 1.86 + * For example, "-0500", "+0530", and "Z"(UTC). 1.87 + * This style is equivalent to the LDML date format pattern "XX". 1.88 + * @draft ICU 51 1.89 + */ 1.90 + UTZFMT_STYLE_ISO_BASIC_FIXED, 1.91 + /** 1.92 + * Fixed width ISO 8601 local time difference (basic format). 1.93 + * For example, "-0500" and "+0530". 1.94 + * This style is equivalent to the LDML date format pattern "xx". 1.95 + * @draft ICU 51 1.96 + */ 1.97 + UTZFMT_STYLE_ISO_BASIC_LOCAL_FIXED, 1.98 + /** 1.99 + * ISO 8601 local time difference (basic format) with optional seconds field, or the UTC indicator. 1.100 + * For example, "-0500", "+052538", and "Z"(UTC). 1.101 + * This style is equivalent to the LDML date format pattern "XXXX". 1.102 + * @draft ICU 51 1.103 + */ 1.104 + UTZFMT_STYLE_ISO_BASIC_FULL, 1.105 + /** 1.106 + * ISO 8601 local time difference (basic format) with optional seconds field. 1.107 + * For example, "-0500" and "+052538". 1.108 + * This style is equivalent to the LDML date format pattern "xxxx". 1.109 + * @draft ICU 51 1.110 + */ 1.111 + UTZFMT_STYLE_ISO_BASIC_LOCAL_FULL, 1.112 + /** 1.113 + * Fixed width ISO 8601 local time difference (extended format) or the UTC indicator. 1.114 + * For example, "-05:00", "+05:30", and "Z"(UTC). 1.115 + * This style is equivalent to the LDML date format pattern "XXX". 1.116 + * @draft ICU 51 1.117 + */ 1.118 + UTZFMT_STYLE_ISO_EXTENDED_FIXED, 1.119 + /** 1.120 + * Fixed width ISO 8601 local time difference (extended format). 1.121 + * For example, "-05:00" and "+05:30". 1.122 + * This style is equivalent to the LDML date format pattern "xxx" and "ZZZZZ". 1.123 + * @draft ICU 51 1.124 + */ 1.125 + UTZFMT_STYLE_ISO_EXTENDED_LOCAL_FIXED, 1.126 + /** 1.127 + * ISO 8601 local time difference (extended format) with optional seconds field, or the UTC indicator. 1.128 + * For example, "-05:00", "+05:25:38", and "Z"(UTC). 1.129 + * This style is equivalent to the LDML date format pattern "XXXXX". 1.130 + * @draft ICU 51 1.131 + */ 1.132 + UTZFMT_STYLE_ISO_EXTENDED_FULL, 1.133 + /** 1.134 + * ISO 8601 local time difference (extended format) with optional seconds field. 1.135 + * For example, "-05:00" and "+05:25:38". 1.136 + * This style is equivalent to the LDML date format pattern "xxxxx". 1.137 + * @draft ICU 51 1.138 + */ 1.139 + UTZFMT_STYLE_ISO_EXTENDED_LOCAL_FULL, 1.140 + /** 1.141 + * Time Zone ID, such as "America/Los_Angeles". 1.142 + * @draft ICU 51 1.143 + */ 1.144 + UTZFMT_STYLE_ZONE_ID, 1.145 + /** 1.146 + * Short Time Zone ID (BCP 47 Unicode location extension, time zone type value), such as "uslax". 1.147 + * @draft ICU 51 1.148 + */ 1.149 + UTZFMT_STYLE_ZONE_ID_SHORT, 1.150 + /** 1.151 + * Exemplar location, such as "Los Angeles" and "Paris". 1.152 + * @draft ICU 51 1.153 + */ 1.154 + UTZFMT_STYLE_EXEMPLAR_LOCATION 1.155 +#endif /* U_HIDE_DRAFT_API */ 1.156 +} UTimeZoneFormatStyle; 1.157 + 1.158 +/** 1.159 + * Constants for GMT offset pattern types. 1.160 + * @stable ICU 50 1.161 + */ 1.162 +typedef enum UTimeZoneFormatGMTOffsetPatternType { 1.163 + /** 1.164 + * Positive offset with hours and minutes fields 1.165 + * @stable ICU 50 1.166 + */ 1.167 + UTZFMT_PAT_POSITIVE_HM, 1.168 + /** 1.169 + * Positive offset with hours, minutes and seconds fields 1.170 + * @stable ICU 50 1.171 + */ 1.172 + UTZFMT_PAT_POSITIVE_HMS, 1.173 + /** 1.174 + * Negative offset with hours and minutes fields 1.175 + * @stable ICU 50 1.176 + */ 1.177 + UTZFMT_PAT_NEGATIVE_HM, 1.178 + /** 1.179 + * Negative offset with hours, minutes and seconds fields 1.180 + * @stable ICU 50 1.181 + */ 1.182 + UTZFMT_PAT_NEGATIVE_HMS, 1.183 +#ifndef U_HIDE_DRAFT_API 1.184 + /** 1.185 + * Positive offset with hours field 1.186 + * @draft ICU 51 1.187 + */ 1.188 + UTZFMT_PAT_POSITIVE_H, 1.189 + /** 1.190 + * Negative offset with hours field 1.191 + * @draft ICU 51 1.192 + */ 1.193 + UTZFMT_PAT_NEGATIVE_H, 1.194 +#endif /* U_HIDE_DRAFT_API */ 1.195 + 1.196 + /** 1.197 + * Number of UTimeZoneFormatGMTOffsetPatternType types. 1.198 + * @internal 1.199 + */ 1.200 + UTZFMT_PAT_COUNT = 6 1.201 +} UTimeZoneFormatGMTOffsetPatternType; 1.202 + 1.203 +/** 1.204 + * Constants for time types used by TimeZoneFormat APIs for 1.205 + * receiving time type (standard time, daylight time or unknown). 1.206 + * @stable ICU 50 1.207 + */ 1.208 +typedef enum UTimeZoneFormatTimeType { 1.209 + /** 1.210 + * Unknown 1.211 + * @stable ICU 50 1.212 + */ 1.213 + UTZFMT_TIME_TYPE_UNKNOWN, 1.214 + /** 1.215 + * Standard time 1.216 + * @stable ICU 50 1.217 + */ 1.218 + UTZFMT_TIME_TYPE_STANDARD, 1.219 + /** 1.220 + * Daylight saving time 1.221 + * @stable ICU 50 1.222 + */ 1.223 + UTZFMT_TIME_TYPE_DAYLIGHT 1.224 +} UTimeZoneFormatTimeType; 1.225 + 1.226 +/** 1.227 + * Constants for parse option flags, used for specifying optional parse behavior. 1.228 + * @stable ICU 50 1.229 + */ 1.230 +typedef enum UTimeZoneFormatParseOption { 1.231 + /** 1.232 + * No option. 1.233 + * @stable ICU 50 1.234 + */ 1.235 + UTZFMT_PARSE_OPTION_NONE = 0x00, 1.236 + /** 1.237 + * When a time zone display name is not found within a set of display names 1.238 + * used for the specified style, look for the name from display names used 1.239 + * by other styles. 1.240 + * @stable ICU 50 1.241 + */ 1.242 + UTZFMT_PARSE_OPTION_ALL_STYLES = 0x01 1.243 +} UTimeZoneFormatParseOption; 1.244 + 1.245 +U_CDECL_END 1.246 + 1.247 +U_NAMESPACE_BEGIN 1.248 + 1.249 +class TimeZoneGenericNames; 1.250 +class UVector; 1.251 + 1.252 +/** 1.253 + * <code>TimeZoneFormat</code> supports time zone display name formatting and parsing. 1.254 + * An instance of TimeZoneFormat works as a subformatter of {@link SimpleDateFormat}, 1.255 + * but you can also directly get a new instance of <code>TimeZoneFormat</code> and 1.256 + * formatting/parsing time zone display names. 1.257 + * <p> 1.258 + * ICU implements the time zone display names defined by <a href="http://www.unicode.org/reports/tr35/">UTS#35 1.259 + * Unicode Locale Data Markup Language (LDML)</a>. {@link TimeZoneNames} represents the 1.260 + * time zone display name data model and this class implements the algorithm for actual 1.261 + * formatting and parsing. 1.262 + * 1.263 + * @see SimpleDateFormat 1.264 + * @see TimeZoneNames 1.265 + * @stable ICU 50 1.266 + */ 1.267 +class U_I18N_API TimeZoneFormat : public Format { 1.268 +public: 1.269 + /** 1.270 + * Copy constructor. 1.271 + * @stable ICU 50 1.272 + */ 1.273 + TimeZoneFormat(const TimeZoneFormat& other); 1.274 + 1.275 + /** 1.276 + * Destructor. 1.277 + * @stable ICU 50 1.278 + */ 1.279 + virtual ~TimeZoneFormat(); 1.280 + 1.281 + /** 1.282 + * Assignment operator. 1.283 + * @stable ICU 50 1.284 + */ 1.285 + TimeZoneFormat& operator=(const TimeZoneFormat& other); 1.286 + 1.287 + /** 1.288 + * Return true if the given Format objects are semantically equal. 1.289 + * Objects of different subclasses are considered unequal. 1.290 + * @param other The object to be compared with. 1.291 + * @return Return TRUE if the given Format objects are semantically equal. 1.292 + * Objects of different subclasses are considered unequal. 1.293 + * @stable ICU 50 1.294 + */ 1.295 + virtual UBool operator==(const Format& other) const; 1.296 + 1.297 + /** 1.298 + * Clone this object polymorphically. The caller is responsible 1.299 + * for deleting the result when done. 1.300 + * @return A copy of the object 1.301 + * @stable ICU 50 1.302 + */ 1.303 + virtual Format* clone() const; 1.304 + 1.305 + /** 1.306 + * Creates an instance of <code>TimeZoneFormat</code> for the given locale. 1.307 + * @param locale The locale. 1.308 + * @param status Recevies the status. 1.309 + * @return An instance of <code>TimeZoneFormat</code> for the given locale, 1.310 + * owned by the caller. 1.311 + * @stable ICU 50 1.312 + */ 1.313 + static TimeZoneFormat* U_EXPORT2 createInstance(const Locale& locale, UErrorCode& status); 1.314 + 1.315 + /** 1.316 + * Returns the time zone display name data used by this instance. 1.317 + * @return The time zone display name data. 1.318 + * @stable ICU 50 1.319 + */ 1.320 + const TimeZoneNames* getTimeZoneNames() const; 1.321 + 1.322 + /** 1.323 + * Sets the time zone display name data to this format instnace. 1.324 + * The caller should not delete the TimeZoenNames object after it is adopted 1.325 + * by this call. 1.326 + * @param tznames TimeZoneNames object to be adopted. 1.327 + * @stable ICU 50 1.328 + */ 1.329 + void adoptTimeZoneNames(TimeZoneNames *tznames); 1.330 + 1.331 + /** 1.332 + * Sets the time zone display name data to this format instnace. 1.333 + * @param tznames TimeZoneNames object to be set. 1.334 + * @stable ICU 50 1.335 + */ 1.336 + void setTimeZoneNames(const TimeZoneNames &tznames); 1.337 + 1.338 + /** 1.339 + * Returns the localized GMT format pattern. 1.340 + * @param pattern Receives the localized GMT format pattern. 1.341 + * @return A reference to the result pattern. 1.342 + * @see #setGMTPattern 1.343 + * @stable ICU 50 1.344 + */ 1.345 + UnicodeString& getGMTPattern(UnicodeString& pattern) const; 1.346 + 1.347 + /** 1.348 + * Sets the localized GMT format pattern. The pattern must contain 1.349 + * a single argument {0}, for example "GMT {0}". 1.350 + * @param pattern The localized GMT format pattern to be used by this object. 1.351 + * @param status Recieves the status. 1.352 + * @see #getGMTPattern 1.353 + * @stable ICU 50 1.354 + */ 1.355 + void setGMTPattern(const UnicodeString& pattern, UErrorCode& status); 1.356 + 1.357 + /** 1.358 + * Returns the offset pattern used for localized GMT format. 1.359 + * @param type The offset pattern type enum. 1.360 + * @param pattern Receives the offset pattern. 1.361 + * @return A reference to the result pattern. 1.362 + * @see #setGMTOffsetPattern 1.363 + * @stable ICU 50 1.364 + */ 1.365 + UnicodeString& getGMTOffsetPattern(UTimeZoneFormatGMTOffsetPatternType type, UnicodeString& pattern) const; 1.366 + 1.367 + /** 1.368 + * Sets the offset pattern for the given offset type. 1.369 + * @param type The offset pattern type enum. 1.370 + * @param pattern The offset pattern used for localized GMT format for the type. 1.371 + * @param status Receives the status. 1.372 + * @see #getGMTOffsetPattern 1.373 + * @stable ICU 50 1.374 + */ 1.375 + void setGMTOffsetPattern(UTimeZoneFormatGMTOffsetPatternType type, const UnicodeString& pattern, UErrorCode& status); 1.376 + 1.377 + /** 1.378 + * Returns the decimal digit characters used for localized GMT format. 1.379 + * The return string contains exactly 10 code points (may include Unicode 1.380 + * supplementary character) representing digit 0 to digit 9 in the ascending 1.381 + * order. 1.382 + * @param digits Receives the decimal digits used for localized GMT format. 1.383 + * @see #setGMTOffsetDigits 1.384 + * @stable ICU 50 1.385 + */ 1.386 + UnicodeString& getGMTOffsetDigits(UnicodeString& digits) const; 1.387 + 1.388 + /** 1.389 + * Sets the decimal digit characters used for localized GMT format. 1.390 + * The input <code>digits</code> must contain exactly 10 code points 1.391 + * (Unicode supplementary characters are also allowed) representing 1.392 + * digit 0 to digit 9 in the ascending order. When the input <code>digits</code> 1.393 + * does not satisfy the condition, <code>U_ILLEGAL_ARGUMENT_ERROR</code> 1.394 + * will be set to the return status. 1.395 + * @param digits The decimal digits used for localized GMT format. 1.396 + * @param status Receives the status. 1.397 + * @see #getGMTOffsetDigits 1.398 + * @stable ICU 50 1.399 + */ 1.400 + void setGMTOffsetDigits(const UnicodeString& digits, UErrorCode& status); 1.401 + 1.402 + /** 1.403 + * Returns the localized GMT format string for GMT(UTC) itself (GMT offset is 0). 1.404 + * @param gmtZeroFormat Receives the localized GMT string string for GMT(UTC) itself. 1.405 + * @return A reference to the result GMT string. 1.406 + * @see #setGMTZeroFormat 1.407 + * @stable ICU 50 1.408 + */ 1.409 + UnicodeString& getGMTZeroFormat(UnicodeString& gmtZeroFormat) const; 1.410 + 1.411 + /** 1.412 + * Sets the localized GMT format string for GMT(UTC) itself (GMT offset is 0). 1.413 + * @param gmtZeroFormat The localized GMT format string for GMT(UTC). 1.414 + * @param status Receives the status. 1.415 + * @see #getGMTZeroFormat 1.416 + * @stable ICU 50 1.417 + */ 1.418 + void setGMTZeroFormat(const UnicodeString& gmtZeroFormat, UErrorCode& status); 1.419 + 1.420 + /** 1.421 + * Returns the bitwise flags of UTimeZoneFormatParseOption representing the default parse 1.422 + * options used by this object. 1.423 + * @return the default parse options. 1.424 + * @see ParseOption 1.425 + * @stable ICU 50 1.426 + */ 1.427 + uint32_t getDefaultParseOptions(void) const; 1.428 + 1.429 + /** 1.430 + * Sets the default parse options. 1.431 + * <p><b>Note</b>: By default, an instance of <code>TimeZoneFormat</code> 1.432 + * created by {@link #createInstance} has no parse options set (UTZFMT_PARSE_OPTION_NONE). 1.433 + * To specify multipe options, use bitwise flags of UTimeZoneFormatParseOption. 1.434 + * @see #UTimeZoneFormatParseOption 1.435 + * @stable ICU 50 1.436 + */ 1.437 + void setDefaultParseOptions(uint32_t flags); 1.438 + 1.439 +#ifndef U_HIDE_DRAFT_API 1.440 + /** 1.441 + * Returns the ISO 8601 basic time zone string for the given offset. 1.442 + * For example, "-08", "-0830" and "Z" 1.443 + * 1.444 + * @param offset the offset from GMT(UTC) in milliseconds. 1.445 + * @param useUtcIndicator true if ISO 8601 UTC indicator "Z" is used when the offset is 0. 1.446 + * @param isShort true if shortest form is used. 1.447 + * @param ignoreSeconds true if non-zero offset seconds is appended. 1.448 + * @param result Receives the ISO format string. 1.449 + * @param status Receives the status 1.450 + * @return the ISO 8601 basic format. 1.451 + * @see #formatOffsetISO8601Extended 1.452 + * @see #parseOffsetISO8601 1.453 + * @draft ICU 51 1.454 + */ 1.455 + UnicodeString& formatOffsetISO8601Basic(int32_t offset, UBool useUtcIndicator, UBool isShort, UBool ignoreSeconds, 1.456 + UnicodeString& result, UErrorCode& status) const; 1.457 + 1.458 + /** 1.459 + * Returns the ISO 8601 extended time zone string for the given offset. 1.460 + * For example, "-08:00", "-08:30" and "Z" 1.461 + * 1.462 + * @param offset the offset from GMT(UTC) in milliseconds. 1.463 + * @param useUtcIndicator true if ISO 8601 UTC indicator "Z" is used when the offset is 0. 1.464 + * @param isShort true if shortest form is used. 1.465 + * @param ignoreSeconds true if non-zero offset seconds is appended. 1.466 + * @param result Receives the ISO format string. 1.467 + * @param status Receives the status 1.468 + * @return the ISO 8601 basic format. 1.469 + * @see #formatOffsetISO8601Extended 1.470 + * @see #parseOffsetISO8601 1.471 + * @draft ICU 51 1.472 + */ 1.473 + UnicodeString& formatOffsetISO8601Extended(int32_t offset, UBool useUtcIndicator, UBool isShort, UBool ignoreSeconds, 1.474 + UnicodeString& result, UErrorCode& status) const; 1.475 +#endif /* U_HIDE_DRAFT_API */ 1.476 + 1.477 + /** 1.478 + * Returns the localized GMT(UTC) offset format for the given offset. 1.479 + * The localized GMT offset is defined by; 1.480 + * <ul> 1.481 + * <li>GMT format pattern (e.g. "GMT {0}" - see {@link #getGMTPattern}) 1.482 + * <li>Offset time pattern (e.g. "+HH:mm" - see {@link #getGMTOffsetPattern}) 1.483 + * <li>Offset digits (e.g. "0123456789" - see {@link #getGMTOffsetDigits}) 1.484 + * <li>GMT zero format (e.g. "GMT" - see {@link #getGMTZeroFormat}) 1.485 + * </ul> 1.486 + * This format always uses 2 digit hours and minutes. When the given offset has non-zero 1.487 + * seconds, 2 digit seconds field will be appended. For example, 1.488 + * GMT+05:00 and GMT+05:28:06. 1.489 + * @param offset the offset from GMT(UTC) in milliseconds. 1.490 + * @param status Receives the status 1.491 + * @param result Receives the localized GMT format string. 1.492 + * @return A reference to the result. 1.493 + * @see #parseOffsetLocalizedGMT 1.494 + * @stable ICU 50 1.495 + */ 1.496 + UnicodeString& formatOffsetLocalizedGMT(int32_t offset, UnicodeString& result, UErrorCode& status) const; 1.497 + 1.498 +#ifndef U_HIDE_DRAFT_API 1.499 + /** 1.500 + * Returns the short localized GMT(UTC) offset format for the given offset. 1.501 + * The short localized GMT offset is defined by; 1.502 + * <ul> 1.503 + * <li>GMT format pattern (e.g. "GMT {0}" - see {@link #getGMTPattern}) 1.504 + * <li>Offset time pattern (e.g. "+HH:mm" - see {@link #getGMTOffsetPattern}) 1.505 + * <li>Offset digits (e.g. "0123456789" - see {@link #getGMTOffsetDigits}) 1.506 + * <li>GMT zero format (e.g. "GMT" - see {@link #getGMTZeroFormat}) 1.507 + * </ul> 1.508 + * This format uses the shortest representation of offset. The hours field does not 1.509 + * have leading zero and lower fields with zero will be truncated. For example, 1.510 + * GMT+5 and GMT+530. 1.511 + * @param offset the offset from GMT(UTC) in milliseconds. 1.512 + * @param status Receives the status 1.513 + * @param result Receives the short localized GMT format string. 1.514 + * @return A reference to the result. 1.515 + * @see #parseOffsetShortLocalizedGMT 1.516 + * @draft ICU 51 1.517 + */ 1.518 + UnicodeString& formatOffsetShortLocalizedGMT(int32_t offset, UnicodeString& result, UErrorCode& status) const; 1.519 +#endif /* U_HIDE_DRAFT_API */ 1.520 + 1.521 + using Format::format; 1.522 + 1.523 + /** 1.524 + * Returns the display name of the time zone at the given date for the style. 1.525 + * @param style The style (e.g. <code>UTZFMT_STYLE_GENERIC_LONG</code>, <code>UTZFMT_STYLE_LOCALIZED_GMT</code>...) 1.526 + * @param tz The time zone. 1.527 + * @param date The date. 1.528 + * @param name Receives the display name. 1.529 + * @param timeType the output argument for receiving the time type (standard/daylight/unknown) 1.530 + * used for the display name, or NULL if the information is not necessary. 1.531 + * @return A reference to the result 1.532 + * @see #UTimeZoneFormatStyle 1.533 + * @see #UTimeZoneFormatTimeType 1.534 + * @stable ICU 50 1.535 + */ 1.536 + virtual UnicodeString& format(UTimeZoneFormatStyle style, const TimeZone& tz, UDate date, 1.537 + UnicodeString& name, UTimeZoneFormatTimeType* timeType = NULL) const; 1.538 + 1.539 + /** 1.540 + * Returns offset from GMT(UTC) in milliseconds for the given ISO 8601 1.541 + * style time zone string. When the given string is not an ISO 8601 time zone 1.542 + * string, this method sets the current position as the error index 1.543 + * to <code>ParsePosition pos</code> and returns 0. 1.544 + * @param text The text contains ISO8601 style time zone string (e.g. "-08:00", "Z") 1.545 + * at the position. 1.546 + * @param pos The ParsePosition object. 1.547 + * @return The offset from GMT(UTC) in milliseconds for the given ISO 8601 style 1.548 + * time zone string. 1.549 + * @see #formatOffsetISO8601Basic 1.550 + * @see #formatOffsetISO8601Extended 1.551 + * @stable ICU 50 1.552 + */ 1.553 + int32_t parseOffsetISO8601(const UnicodeString& text, ParsePosition& pos) const; 1.554 + 1.555 + /** 1.556 + * Returns offset from GMT(UTC) in milliseconds for the given localized GMT 1.557 + * offset format string. When the given string cannot be parsed, this method 1.558 + * sets the current position as the error index to <code>ParsePosition pos</code> 1.559 + * and returns 0. 1.560 + * @param text The text contains a localized GMT offset string at the position. 1.561 + * @param pos The ParsePosition object. 1.562 + * @return The offset from GMT(UTC) in milliseconds for the given localized GMT 1.563 + * offset format string. 1.564 + * @see #formatOffsetLocalizedGMT 1.565 + * @stable ICU 50 1.566 + */ 1.567 + int32_t parseOffsetLocalizedGMT(const UnicodeString& text, ParsePosition& pos) const; 1.568 + 1.569 +#ifndef U_HIDE_DRAFT_API 1.570 + /** 1.571 + * Returns offset from GMT(UTC) in milliseconds for the given short localized GMT 1.572 + * offset format string. When the given string cannot be parsed, this method 1.573 + * sets the current position as the error index to <code>ParsePosition pos</code> 1.574 + * and returns 0. 1.575 + * @param text The text contains a short localized GMT offset string at the position. 1.576 + * @param pos The ParsePosition object. 1.577 + * @return The offset from GMT(UTC) in milliseconds for the given short localized GMT 1.578 + * offset format string. 1.579 + * @see #formatOffsetShortLocalizedGMT 1.580 + * @draft ICU 51 1.581 + */ 1.582 + int32_t parseOffsetShortLocalizedGMT(const UnicodeString& text, ParsePosition& pos) const; 1.583 +#endif /* U_HIDE_DRAFT_API */ 1.584 + 1.585 + /** 1.586 + * Returns a <code>TimeZone</code> by parsing the time zone string according to 1.587 + * the given parse position, the specified format style and parse options. 1.588 + * 1.589 + * @param text The text contains a time zone string at the position. 1.590 + * @param style The format style 1.591 + * @param pos The position. 1.592 + * @param parseOptions The parse options repesented by bitwise flags of UTimeZoneFormatParseOption. 1.593 + * @param timeType The output argument for receiving the time type (standard/daylight/unknown), 1.594 + * or NULL if the information is not necessary. 1.595 + * @return A <code>TimeZone</code>, or null if the input could not be parsed. 1.596 + * @see UTimeZoneFormatStyle 1.597 + * @see UTimeZoneFormatParseOption 1.598 + * @see UTimeZoneFormatTimeType 1.599 + * @stable ICU 50 1.600 + */ 1.601 + virtual TimeZone* parse(UTimeZoneFormatStyle style, const UnicodeString& text, ParsePosition& pos, 1.602 + int32_t parseOptions, UTimeZoneFormatTimeType* timeType = NULL) const; 1.603 + 1.604 + /** 1.605 + * Returns a <code>TimeZone</code> by parsing the time zone string according to 1.606 + * the given parse position, the specified format style and the default parse options. 1.607 + * 1.608 + * @param text The text contains a time zone string at the position. 1.609 + * @param style The format style 1.610 + * @param pos The position. 1.611 + * @param timeType The output argument for receiving the time type (standard/daylight/unknown), 1.612 + * or NULL if the information is not necessary. 1.613 + * @return A <code>TimeZone</code>, or null if the input could not be parsed. 1.614 + * @see UTimeZoneFormatStyle 1.615 + * @see UTimeZoneFormatParseOption 1.616 + * @see UTimeZoneFormatTimeType 1.617 + * @stable ICU 50 1.618 + */ 1.619 + TimeZone* parse(UTimeZoneFormatStyle style, const UnicodeString& text, ParsePosition& pos, 1.620 + UTimeZoneFormatTimeType* timeType = NULL) const; 1.621 + 1.622 + /* ---------------------------------------------- 1.623 + * Format APIs 1.624 + * ---------------------------------------------- */ 1.625 + 1.626 + /** 1.627 + * Format an object to produce a time zone display string using localized GMT offset format. 1.628 + * This method handles Formattable objects with a <code>TimeZone</code>. If a the Formattable 1.629 + * object type is not a <code>TimeZone</code>, then it returns a failing UErrorCode. 1.630 + * @param obj The object to format. Must be a <code>TimeZone</code>. 1.631 + * @param appendTo Output parameter to receive result. Result is appended to existing contents. 1.632 + * @param pos On input: an alignment field, if desired. On output: the offsets of the alignment field. 1.633 + * @param status Output param filled with success/failure status. 1.634 + * @return Reference to 'appendTo' parameter. 1.635 + * @stable ICU 50 1.636 + */ 1.637 + virtual UnicodeString& format(const Formattable& obj, UnicodeString& appendTo, 1.638 + FieldPosition& pos, UErrorCode& status) const; 1.639 + 1.640 + /** 1.641 + * Parse a string to produce an object. This methods handles parsing of 1.642 + * time zone display strings into Formattable objects with <code>TimeZone</code>. 1.643 + * @param source The string to be parsed into an object. 1.644 + * @param result Formattable to be set to the parse result. If parse fails, return contents are undefined. 1.645 + * @param parse_pos The position to start parsing at. Upon return this param is set to the position after the 1.646 + * last character successfully parsed. If the source is not parsed successfully, this param 1.647 + * will remain unchanged. 1.648 + * @return A newly created Formattable* object, or NULL on failure. The caller owns this and should 1.649 + * delete it when done. 1.650 + * @stable ICU 50 1.651 + */ 1.652 + virtual void parseObject(const UnicodeString& source, Formattable& result, ParsePosition& parse_pos) const; 1.653 + 1.654 + /** 1.655 + * ICU "poor man's RTTI", returns a UClassID for this class. 1.656 + * @stable ICU 50 1.657 + */ 1.658 + static UClassID U_EXPORT2 getStaticClassID(void); 1.659 + 1.660 + /** 1.661 + * ICU "poor man's RTTI", returns a UClassID for the actual class. 1.662 + * @stable ICU 50 1.663 + */ 1.664 + virtual UClassID getDynamicClassID() const; 1.665 + 1.666 +protected: 1.667 + /** 1.668 + * Constructs a TimeZoneFormat object for the specified locale. 1.669 + * @param locale the locale 1.670 + * @param status receives the status. 1.671 + * @stable ICU 50 1.672 + */ 1.673 + TimeZoneFormat(const Locale& locale, UErrorCode& status); 1.674 + 1.675 +private: 1.676 + /* Locale of this object */ 1.677 + Locale fLocale; 1.678 + 1.679 + /* Stores the region (could be implicit default) */ 1.680 + char fTargetRegion[ULOC_COUNTRY_CAPACITY]; 1.681 + 1.682 + /* TimeZoneNames object used by this formatter */ 1.683 + TimeZoneNames* fTimeZoneNames; 1.684 + 1.685 + /* TimeZoneGenericNames object used by this formatter - lazily instantiated */ 1.686 + TimeZoneGenericNames* fTimeZoneGenericNames; 1.687 + 1.688 + /* Localized GMT format pattern - e.g. "GMT{0}" */ 1.689 + UnicodeString fGMTPattern; 1.690 + 1.691 + /* Array of offset patterns used by Localized GMT format - e.g. "+HH:mm" */ 1.692 + UnicodeString fGMTOffsetPatterns[UTZFMT_PAT_COUNT]; 1.693 + 1.694 + /* Localized decimal digits used by Localized GMT format */ 1.695 + UChar32 fGMTOffsetDigits[10]; 1.696 + 1.697 + /* Localized GMT zero format - e.g. "GMT" */ 1.698 + UnicodeString fGMTZeroFormat; 1.699 + 1.700 + /* Bit flags representing parse options */ 1.701 + uint32_t fDefParseOptionFlags; 1.702 + 1.703 + /* Constant parts of GMT format pattern, populated from localized GMT format pattern*/ 1.704 + UnicodeString fGMTPatternPrefix; /* Substring before {0} */ 1.705 + UnicodeString fGMTPatternSuffix; /* Substring after {0} */ 1.706 + 1.707 + /* Compiled offset patterns generated from fGMTOffsetPatterns[] */ 1.708 + UVector* fGMTOffsetPatternItems[UTZFMT_PAT_COUNT]; 1.709 + 1.710 + UBool fAbuttingOffsetHoursAndMinutes; 1.711 + 1.712 + /** 1.713 + * Returns the time zone's specific format string. 1.714 + * @param tz the time zone 1.715 + * @param stdType the name type used for standard time 1.716 + * @param dstType the name type used for daylight time 1.717 + * @param date the date 1.718 + * @param name receives the time zone's specific format name string 1.719 + * @param timeType when null, actual time type is set 1.720 + * @return a reference to name. 1.721 + */ 1.722 + UnicodeString& formatSpecific(const TimeZone& tz, UTimeZoneNameType stdType, UTimeZoneNameType dstType, 1.723 + UDate date, UnicodeString& name, UTimeZoneFormatTimeType *timeType) const; 1.724 + 1.725 + /** 1.726 + * Returns the time zone's generic format string. 1.727 + * @param tz the time zone 1.728 + * @param genType the generic name type 1.729 + * @param date the date 1.730 + * @param name receives the time zone's generic format name string 1.731 + * @return a reference to name. 1.732 + */ 1.733 + UnicodeString& formatGeneric(const TimeZone& tz, int32_t genType, UDate date, UnicodeString& name) const; 1.734 + 1.735 + /** 1.736 + * Lazily create a TimeZoneGenericNames instance 1.737 + * @param status receives the status 1.738 + * @return the cached TimeZoneGenericNames. 1.739 + */ 1.740 + const TimeZoneGenericNames* getTimeZoneGenericNames(UErrorCode& status) const; 1.741 + 1.742 + /** 1.743 + * Private method returning the time zone's exemplar location string. 1.744 + * This method will never return empty. 1.745 + * @param tz the time zone 1.746 + * @param name receives the time zone's exemplar location name 1.747 + * @return a reference to name. 1.748 + */ 1.749 + UnicodeString& formatExemplarLocation(const TimeZone& tz, UnicodeString& name) const; 1.750 + 1.751 + /** 1.752 + * Private enum specifying a combination of offset fields 1.753 + */ 1.754 + enum OffsetFields { 1.755 + FIELDS_H, 1.756 + FIELDS_HM, 1.757 + FIELDS_HMS 1.758 + }; 1.759 + 1.760 + /** 1.761 + * Parses the localized GMT pattern string and initialize 1.762 + * localized gmt pattern fields. 1.763 + * @param gmtPattern the localized GMT pattern string such as "GMT {0}" 1.764 + * @param status U_ILLEGAL_ARGUMENT_ERROR is set when the specified pattern does not 1.765 + * contain an argument "{0}". 1.766 + */ 1.767 + void initGMTPattern(const UnicodeString& gmtPattern, UErrorCode& status); 1.768 + 1.769 + /** 1.770 + * Parse the GMT offset pattern into runtime optimized format. 1.771 + * @param pattern the offset pattern string 1.772 + * @param required the required set of fields, such as FIELDS_HM 1.773 + * @param status U_ILLEGAL_ARGUMENT is set when the specified pattern does not contain 1.774 + * pattern letters for the required fields. 1.775 + * @return A list of GMTOffsetField objects, or NULL on error. 1.776 + */ 1.777 + static UVector* parseOffsetPattern(const UnicodeString& pattern, OffsetFields required, UErrorCode& status); 1.778 + 1.779 + /** 1.780 + * Appends seconds field to the offset pattern with hour/minute 1.781 + * Note: This code will be obsoleted once we add hour-minute-second pattern data in CLDR. 1.782 + * @param offsetHM the offset pattern including hours and minutes fields 1.783 + * @param result the output offset pattern including hour, minute and seconds fields 1.784 + * @param status receives the status 1.785 + * @return a reference to result 1.786 + */ 1.787 + static UnicodeString& expandOffsetPattern(const UnicodeString& offsetHM, UnicodeString& result, UErrorCode& status); 1.788 + 1.789 + /** 1.790 + * Truncates minutes field to the offset pattern with hour/minute 1.791 + * Note: This code will be obsoleted once we add hour pattern data in CLDR. 1.792 + * @param offsetHM the offset pattern including hours and minutes fields 1.793 + * @param result the output offset pattern including only hours field 1.794 + * @param status receives the status 1.795 + * @return a reference to result 1.796 + */ 1.797 + static UnicodeString& truncateOffsetPattern(const UnicodeString& offsetHM, UnicodeString& result, UErrorCode& status); 1.798 + 1.799 + /** 1.800 + * Break input string into UChar32[]. Each array element represents 1.801 + * a code point. This method is used for parsing localized digit 1.802 + * characters and support characters in Unicode supplemental planes. 1.803 + * @param str the string 1.804 + * @param codeArray receives the result 1.805 + * @param capacity the capacity of codeArray 1.806 + * @return TRUE when the specified code array is fully filled with code points 1.807 + * (no under/overflow). 1.808 + */ 1.809 + static UBool toCodePoints(const UnicodeString& str, UChar32* codeArray, int32_t capacity); 1.810 + 1.811 + /** 1.812 + * Private method supprting all of ISO8601 formats 1.813 + * @param offset the offset from GMT(UTC) in milliseconds. 1.814 + * @param useUtcIndicator true if ISO 8601 UTC indicator "Z" is used when the offset is 0. 1.815 + * @param isShort true if shortest form is used. 1.816 + * @param ignoreSeconds true if non-zero offset seconds is appended. 1.817 + * @param result Receives the result 1.818 + * @param status Receives the status 1.819 + * @return the ISO 8601 basic format. 1.820 + */ 1.821 + UnicodeString& formatOffsetISO8601(int32_t offset, UBool isBasic, UBool useUtcIndicator, 1.822 + UBool isShort, UBool ignoreSeconds, UnicodeString& result, UErrorCode& status) const; 1.823 + 1.824 + /** 1.825 + * Private method used for localized GMT formatting. 1.826 + * @param offset the zone's UTC offset 1.827 + * @param isShort true if the short localized GMT format is desired. 1.828 + * @param result receives the localized GMT format string 1.829 + * @param status receives the status 1.830 + */ 1.831 + UnicodeString& formatOffsetLocalizedGMT(int32_t offset, UBool isShort, UnicodeString& result, UErrorCode& status) const; 1.832 + 1.833 + /** 1.834 + * Returns offset from GMT(UTC) in milliseconds for the given ISO 8601 style 1.835 + * (extended format) time zone string. When the given string is not an ISO 8601 time 1.836 + * zone string, this method sets the current position as the error index 1.837 + * to <code>ParsePosition pos</code> and returns 0. 1.838 + * @param text the text contains ISO 8601 style time zone string (e.g. "-08:00", "Z") 1.839 + * at the position. 1.840 + * @param pos the position, non-negative error index will be set on failure. 1.841 + * @param extendedOnly TRUE if parsing the text as ISO 8601 extended offset format (e.g. "-08:00"), 1.842 + * or FALSE to evaluate the text as basic format. 1.843 + * @param hasDigitOffset receiving if the parsed zone string contains offset digits. 1.844 + * @return the offset from GMT(UTC) in milliseconds for the given ISO 8601 style 1.845 + * time zone string. 1.846 + */ 1.847 + int32_t parseOffsetISO8601(const UnicodeString& text, ParsePosition& pos, UBool extendedOnly, 1.848 + UBool* hasDigitOffset = NULL) const; 1.849 + 1.850 + /** 1.851 + * Appends localized digits to the buffer. 1.852 + * This code assumes that the input number is 0 - 59 1.853 + * @param buf the target buffer 1.854 + * @param n the integer number 1.855 + * @param minDigits the minimum digits width 1.856 + */ 1.857 + void appendOffsetDigits(UnicodeString& buf, int32_t n, uint8_t minDigits) const; 1.858 + 1.859 + /** 1.860 + * Returns offset from GMT(UTC) in milliseconds for the given localized GMT 1.861 + * offset format string. When the given string cannot be parsed, this method 1.862 + * sets the current position as the error index to <code>ParsePosition pos</code> 1.863 + * and returns 0. 1.864 + * @param text the text contains a localized GMT offset string at the position. 1.865 + * @param pos the position, non-negative error index will be set on failure. 1.866 + * @param isShort true if this parser to try the short format first 1.867 + * @param hasDigitOffset receiving if the parsed zone string contains offset digits. 1.868 + * @return the offset from GMT(UTC) in milliseconds for the given localized GMT 1.869 + * offset format string. 1.870 + */ 1.871 + int32_t parseOffsetLocalizedGMT(const UnicodeString& text, ParsePosition& pos, 1.872 + UBool isShort, UBool* hasDigitOffset) const; 1.873 + 1.874 + /** 1.875 + * Parse localized GMT format generated by the patter used by this formatter, except 1.876 + * GMT Zero format. 1.877 + * @param text the input text 1.878 + * @param start the start index 1.879 + * @param isShort true if the short localized format is parsed. 1.880 + * @param parsedLen receives the parsed length 1.881 + * @return the parsed offset in milliseconds 1.882 + */ 1.883 + int32_t parseOffsetLocalizedGMTPattern(const UnicodeString& text, int32_t start, 1.884 + UBool isShort, int32_t& parsedLen) const; 1.885 + 1.886 + /** 1.887 + * Parses localized GMT offset fields into offset. 1.888 + * @param text the input text 1.889 + * @param start the start index 1.890 + * @param isShort true if this is a short format - currently not used 1.891 + * @param parsedLen the parsed length, or 0 on failure. 1.892 + * @return the parsed offset in milliseconds. 1.893 + */ 1.894 + int32_t parseOffsetFields(const UnicodeString& text, int32_t start, UBool isShort, int32_t& parsedLen) const; 1.895 + 1.896 + /** 1.897 + * Parse localized GMT offset fields with the given pattern. 1.898 + * @param text the input text 1.899 + * @param start the start index 1.900 + * @param pattenItems the pattern (already itemized) 1.901 + * @param forceSingleHourDigit true if hours field is parsed as a single digit 1.902 + * @param hour receives the hour offset field 1.903 + * @param min receives the minute offset field 1.904 + * @param sec receives the second offset field 1.905 + * @return the parsed length 1.906 + */ 1.907 + int32_t parseOffsetFieldsWithPattern(const UnicodeString& text, int32_t start, 1.908 + UVector* patternItems, UBool forceSingleHourDigit, int32_t& hour, int32_t& min, int32_t& sec) const; 1.909 + 1.910 + /** 1.911 + * Parses abutting localized GMT offset fields (such as 0800) into offset. 1.912 + * @param text the input text 1.913 + * @param start the start index 1.914 + * @param parsedLen the parsed length, or 0 on failure 1.915 + * @return the parsed offset in milliseconds. 1.916 + */ 1.917 + int32_t parseAbuttingOffsetFields(const UnicodeString& text, int32_t start, int32_t& parsedLen) const; 1.918 + 1.919 + /** 1.920 + * Parses the input text using the default format patterns (e.g. "UTC{0}"). 1.921 + * @param text the input text 1.922 + * @param start the start index 1.923 + * @param parsedLen the parsed length, or 0 on failure 1.924 + * @return the parsed offset in milliseconds. 1.925 + */ 1.926 + int32_t parseOffsetDefaultLocalizedGMT(const UnicodeString& text, int start, int32_t& parsedLen) const; 1.927 + 1.928 + /** 1.929 + * Parses the input GMT offset fields with the default offset pattern. 1.930 + * @param text the input text 1.931 + * @param start the start index 1.932 + * @param separator the separator character, e.g. ':' 1.933 + * @param parsedLen the parsed length, or 0 on failure. 1.934 + * @return the parsed offset in milliseconds. 1.935 + */ 1.936 + int32_t parseDefaultOffsetFields(const UnicodeString& text, int32_t start, UChar separator, 1.937 + int32_t& parsedLen) const; 1.938 + 1.939 + /** 1.940 + * Reads an offset field value. This method will stop parsing when 1.941 + * 1) number of digits reaches <code>maxDigits</code> 1.942 + * 2) just before already parsed number exceeds <code>maxVal</code> 1.943 + * 1.944 + * @param text the text 1.945 + * @param start the start offset 1.946 + * @param minDigits the minimum number of required digits 1.947 + * @param maxDigits the maximum number of digits 1.948 + * @param minVal the minimum value 1.949 + * @param maxVal the maximum value 1.950 + * @param parsedLen the actual parsed length. 1.951 + * @return the integer value parsed 1.952 + */ 1.953 + int32_t parseOffsetFieldWithLocalizedDigits(const UnicodeString& text, int32_t start, 1.954 + uint8_t minDigits, uint8_t maxDigits, uint16_t minVal, uint16_t maxVal, int32_t& parsedLen) const; 1.955 + 1.956 + /** 1.957 + * Reads a single decimal digit, either localized digits used by this object 1.958 + * or any Unicode numeric character. 1.959 + * @param text the text 1.960 + * @param start the start index 1.961 + * @param len the actual length read from the text 1.962 + * the start index is not a decimal number. 1.963 + * @return the integer value of the parsed digit, or -1 on failure. 1.964 + */ 1.965 + int32_t parseSingleLocalizedDigit(const UnicodeString& text, int32_t start, int32_t& len) const; 1.966 + 1.967 + /** 1.968 + * Formats offset using ASCII digits. The input offset range must be 1.969 + * within +/-24 hours (exclusive). 1.970 + * @param offset The offset 1.971 + * @param sep The field separator character or 0 if not required 1.972 + * @param minFields The minimum fields 1.973 + * @param maxFields The maximum fields 1.974 + * @return The offset string 1.975 + */ 1.976 + static UnicodeString& formatOffsetWithAsciiDigits(int32_t offset, UChar sep, 1.977 + OffsetFields minFields, OffsetFields maxFields, UnicodeString& result); 1.978 + 1.979 + /** 1.980 + * Parses offset represented by contiguous ASCII digits. 1.981 + * <p> 1.982 + * Note: This method expects the input position is already at the start of 1.983 + * ASCII digits and does not parse sign (+/-). 1.984 + * @param text The text contains a sequence of ASCII digits 1.985 + * @param pos The parse position 1.986 + * @param minFields The minimum Fields to be parsed 1.987 + * @param maxFields The maximum Fields to be parsed 1.988 + * @param fixedHourWidth true if hours field must be width of 2 1.989 + * @return Parsed offset, 0 or positive number. 1.990 + */ 1.991 + static int32_t parseAbuttingAsciiOffsetFields(const UnicodeString& text, ParsePosition& pos, 1.992 + OffsetFields minFields, OffsetFields maxFields, UBool fixedHourWidth); 1.993 + 1.994 + /** 1.995 + * Parses offset represented by ASCII digits and separators. 1.996 + * <p> 1.997 + * Note: This method expects the input position is already at the start of 1.998 + * ASCII digits and does not parse sign (+/-). 1.999 + * @param text The text 1.1000 + * @param pos The parse position 1.1001 + * @param sep The separator character 1.1002 + * @param minFields The minimum Fields to be parsed 1.1003 + * @param maxFields The maximum Fields to be parsed 1.1004 + * @return Parsed offset, 0 or positive number. 1.1005 + */ 1.1006 + static int32_t parseAsciiOffsetFields(const UnicodeString& text, ParsePosition& pos, UChar sep, 1.1007 + OffsetFields minFields, OffsetFields maxFields); 1.1008 + 1.1009 + /** 1.1010 + * Unquotes the message format style pattern. 1.1011 + * @param pattern the pattern 1.1012 + * @param result receive the unquoted pattern. 1.1013 + * @return A reference to result. 1.1014 + */ 1.1015 + static UnicodeString& unquote(const UnicodeString& pattern, UnicodeString& result); 1.1016 + 1.1017 + /** 1.1018 + * Initialize localized GMT format offset hour/min/sec patterns. 1.1019 + * This method parses patterns into optimized run-time format. 1.1020 + * @param status receives the status. 1.1021 + */ 1.1022 + void initGMTOffsetPatterns(UErrorCode& status); 1.1023 + 1.1024 + /** 1.1025 + * Check if there are any GMT format offset patterns without 1.1026 + * any separators between hours field and minutes field and update 1.1027 + * fAbuttingOffsetHoursAndMinutes field. This method must be called 1.1028 + * after all patterns are parsed into pattern items. 1.1029 + */ 1.1030 + void checkAbuttingHoursAndMinutes(); 1.1031 + 1.1032 + /** 1.1033 + * Creates an instance of TimeZone for the given offset 1.1034 + * @param offset the offset 1.1035 + * @return A TimeZone with the given offset 1.1036 + */ 1.1037 + TimeZone* createTimeZoneForOffset(int32_t offset) const; 1.1038 + 1.1039 + /** 1.1040 + * Returns the time type for the given name type 1.1041 + * @param nameType the name type 1.1042 + * @return the time type (unknown/standard/daylight) 1.1043 + */ 1.1044 + static UTimeZoneFormatTimeType getTimeType(UTimeZoneNameType nameType); 1.1045 + 1.1046 + /** 1.1047 + * Returns the time zone ID of a match at the specified index within 1.1048 + * the MatchInfoCollection. 1.1049 + * @param matches the collection of matches 1.1050 + * @param idx the index withing matches 1.1051 + * @param tzID receives the resolved time zone ID 1.1052 + * @return a reference to tzID. 1.1053 + */ 1.1054 + UnicodeString& getTimeZoneID(const TimeZoneNames::MatchInfoCollection* matches, int32_t idx, UnicodeString& tzID) const; 1.1055 + 1.1056 + 1.1057 + /** 1.1058 + * Parse a zone ID. 1.1059 + * @param text the text contains a time zone ID string at the position. 1.1060 + * @param pos the position 1.1061 + * @param tzID receives the zone ID 1.1062 + * @return a reference to tzID 1.1063 + */ 1.1064 + UnicodeString& parseZoneID(const UnicodeString& text, ParsePosition& pos, UnicodeString& tzID) const; 1.1065 + 1.1066 + /** 1.1067 + * Parse a short zone ID. 1.1068 + * @param text the text contains a short time zone ID string at the position. 1.1069 + * @param pos the position 1.1070 + * @param tzID receives the short zone ID 1.1071 + * @return a reference to tzID 1.1072 + */ 1.1073 + UnicodeString& parseShortZoneID(const UnicodeString& text, ParsePosition& pos, UnicodeString& tzID) const; 1.1074 + 1.1075 + /** 1.1076 + * Parse an exemplar location string. 1.1077 + * @param text the text contains an exemplar location string at the position. 1.1078 + * @param pos the position. 1.1079 + * @param tzID receives the time zone ID 1.1080 + * @return a reference to tzID 1.1081 + */ 1.1082 + UnicodeString& parseExemplarLocation(const UnicodeString& text, ParsePosition& pos, UnicodeString& tzID) const; 1.1083 +}; 1.1084 + 1.1085 +U_NAMESPACE_END 1.1086 + 1.1087 +#endif /* !UCONFIG_NO_FORMATTING */ 1.1088 +#endif