11cb0ef41Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others. 21cb0ef41Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 31cb0ef41Sopenharmony_ci/* 41cb0ef41Sopenharmony_ci******************************************************************************* 51cb0ef41Sopenharmony_ci* Copyright (C) 2007-2016, International Business Machines Corporation and 61cb0ef41Sopenharmony_ci* others. All Rights Reserved. 71cb0ef41Sopenharmony_ci******************************************************************************* 81cb0ef41Sopenharmony_ci* 91cb0ef41Sopenharmony_ci* File DTPTNGEN.H 101cb0ef41Sopenharmony_ci* 111cb0ef41Sopenharmony_ci******************************************************************************* 121cb0ef41Sopenharmony_ci*/ 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci#ifndef __DTPTNGEN_H__ 151cb0ef41Sopenharmony_ci#define __DTPTNGEN_H__ 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci#include "unicode/utypes.h" 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci#if U_SHOW_CPLUSPLUS_API 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci#include "unicode/datefmt.h" 221cb0ef41Sopenharmony_ci#include "unicode/locid.h" 231cb0ef41Sopenharmony_ci#include "unicode/udat.h" 241cb0ef41Sopenharmony_ci#include "unicode/udatpg.h" 251cb0ef41Sopenharmony_ci#include "unicode/unistr.h" 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ciU_NAMESPACE_BEGIN 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci/** 301cb0ef41Sopenharmony_ci * \file 311cb0ef41Sopenharmony_ci * \brief C++ API: Date/Time Pattern Generator 321cb0ef41Sopenharmony_ci */ 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ciclass CharString; 361cb0ef41Sopenharmony_ciclass Hashtable; 371cb0ef41Sopenharmony_ciclass FormatParser; 381cb0ef41Sopenharmony_ciclass DateTimeMatcher; 391cb0ef41Sopenharmony_ciclass DistanceInfo; 401cb0ef41Sopenharmony_ciclass PatternMap; 411cb0ef41Sopenharmony_ciclass PtnSkeleton; 421cb0ef41Sopenharmony_ciclass SharedDateTimePatternGenerator; 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci/** 451cb0ef41Sopenharmony_ci * This class provides flexible generation of date format patterns, like "yy-MM-dd". 461cb0ef41Sopenharmony_ci * The user can build up the generator by adding successive patterns. Once that 471cb0ef41Sopenharmony_ci * is done, a query can be made using a "skeleton", which is a pattern which just 481cb0ef41Sopenharmony_ci * includes the desired fields and lengths. The generator will return the "best fit" 491cb0ef41Sopenharmony_ci * pattern corresponding to that skeleton. 501cb0ef41Sopenharmony_ci * <p>The main method people will use is getBestPattern(String skeleton), 511cb0ef41Sopenharmony_ci * since normally this class is pre-built with data from a particular locale. 521cb0ef41Sopenharmony_ci * However, generators can be built directly from other data as well. 531cb0ef41Sopenharmony_ci * <p><i>Issue: may be useful to also have a function that returns the list of 541cb0ef41Sopenharmony_ci * fields in a pattern, in order, since we have that internally. 551cb0ef41Sopenharmony_ci * That would be useful for getting the UI order of field elements.</i> 561cb0ef41Sopenharmony_ci * @stable ICU 3.8 571cb0ef41Sopenharmony_ci**/ 581cb0ef41Sopenharmony_ciclass U_I18N_API DateTimePatternGenerator : public UObject { 591cb0ef41Sopenharmony_cipublic: 601cb0ef41Sopenharmony_ci /** 611cb0ef41Sopenharmony_ci * Construct a flexible generator according to default locale. 621cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 631cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 641cb0ef41Sopenharmony_ci * @stable ICU 3.8 651cb0ef41Sopenharmony_ci */ 661cb0ef41Sopenharmony_ci static DateTimePatternGenerator* U_EXPORT2 createInstance(UErrorCode& status); 671cb0ef41Sopenharmony_ci 681cb0ef41Sopenharmony_ci /** 691cb0ef41Sopenharmony_ci * Construct a flexible generator according to data for a given locale. 701cb0ef41Sopenharmony_ci * @param uLocale 711cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 721cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 731cb0ef41Sopenharmony_ci * @stable ICU 3.8 741cb0ef41Sopenharmony_ci */ 751cb0ef41Sopenharmony_ci static DateTimePatternGenerator* U_EXPORT2 createInstance(const Locale& uLocale, UErrorCode& status); 761cb0ef41Sopenharmony_ci 771cb0ef41Sopenharmony_ci#ifndef U_HIDE_INTERNAL_API 781cb0ef41Sopenharmony_ci 791cb0ef41Sopenharmony_ci /** 801cb0ef41Sopenharmony_ci * For ICU use only. Skips loading the standard date/time patterns (which is done via DateFormat). 811cb0ef41Sopenharmony_ci * 821cb0ef41Sopenharmony_ci * @internal 831cb0ef41Sopenharmony_ci */ 841cb0ef41Sopenharmony_ci static DateTimePatternGenerator* U_EXPORT2 createInstanceNoStdPat(const Locale& uLocale, UErrorCode& status); 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ci#endif /* U_HIDE_INTERNAL_API */ 871cb0ef41Sopenharmony_ci 881cb0ef41Sopenharmony_ci /** 891cb0ef41Sopenharmony_ci * Create an empty generator, to be constructed with addPattern(...) etc. 901cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 911cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 921cb0ef41Sopenharmony_ci * @stable ICU 3.8 931cb0ef41Sopenharmony_ci */ 941cb0ef41Sopenharmony_ci static DateTimePatternGenerator* U_EXPORT2 createEmptyInstance(UErrorCode& status); 951cb0ef41Sopenharmony_ci 961cb0ef41Sopenharmony_ci /** 971cb0ef41Sopenharmony_ci * Destructor. 981cb0ef41Sopenharmony_ci * @stable ICU 3.8 991cb0ef41Sopenharmony_ci */ 1001cb0ef41Sopenharmony_ci virtual ~DateTimePatternGenerator(); 1011cb0ef41Sopenharmony_ci 1021cb0ef41Sopenharmony_ci /** 1031cb0ef41Sopenharmony_ci * Clone DateTimePatternGenerator object. Clients are responsible for 1041cb0ef41Sopenharmony_ci * deleting the DateTimePatternGenerator object cloned. 1051cb0ef41Sopenharmony_ci * @stable ICU 3.8 1061cb0ef41Sopenharmony_ci */ 1071cb0ef41Sopenharmony_ci DateTimePatternGenerator* clone() const; 1081cb0ef41Sopenharmony_ci 1091cb0ef41Sopenharmony_ci /** 1101cb0ef41Sopenharmony_ci * Return true if another object is semantically equal to this one. 1111cb0ef41Sopenharmony_ci * 1121cb0ef41Sopenharmony_ci * @param other the DateTimePatternGenerator object to be compared with. 1131cb0ef41Sopenharmony_ci * @return true if other is semantically equal to this. 1141cb0ef41Sopenharmony_ci * @stable ICU 3.8 1151cb0ef41Sopenharmony_ci */ 1161cb0ef41Sopenharmony_ci bool operator==(const DateTimePatternGenerator& other) const; 1171cb0ef41Sopenharmony_ci 1181cb0ef41Sopenharmony_ci /** 1191cb0ef41Sopenharmony_ci * Return true if another object is semantically unequal to this one. 1201cb0ef41Sopenharmony_ci * 1211cb0ef41Sopenharmony_ci * @param other the DateTimePatternGenerator object to be compared with. 1221cb0ef41Sopenharmony_ci * @return true if other is semantically unequal to this. 1231cb0ef41Sopenharmony_ci * @stable ICU 3.8 1241cb0ef41Sopenharmony_ci */ 1251cb0ef41Sopenharmony_ci bool operator!=(const DateTimePatternGenerator& other) const; 1261cb0ef41Sopenharmony_ci 1271cb0ef41Sopenharmony_ci /** 1281cb0ef41Sopenharmony_ci * Utility to return a unique skeleton from a given pattern. For example, 1291cb0ef41Sopenharmony_ci * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". 1301cb0ef41Sopenharmony_ci * 1311cb0ef41Sopenharmony_ci * @param pattern Input pattern, such as "dd/MMM" 1321cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 1331cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 1341cb0ef41Sopenharmony_ci * @return skeleton such as "MMMdd" 1351cb0ef41Sopenharmony_ci * @stable ICU 56 1361cb0ef41Sopenharmony_ci */ 1371cb0ef41Sopenharmony_ci static UnicodeString staticGetSkeleton(const UnicodeString& pattern, UErrorCode& status); 1381cb0ef41Sopenharmony_ci 1391cb0ef41Sopenharmony_ci /** 1401cb0ef41Sopenharmony_ci * Utility to return a unique skeleton from a given pattern. For example, 1411cb0ef41Sopenharmony_ci * both "MMM-dd" and "dd/MMM" produce the skeleton "MMMdd". 1421cb0ef41Sopenharmony_ci * getSkeleton() works exactly like staticGetSkeleton(). 1431cb0ef41Sopenharmony_ci * Use staticGetSkeleton() instead of getSkeleton(). 1441cb0ef41Sopenharmony_ci * 1451cb0ef41Sopenharmony_ci * @param pattern Input pattern, such as "dd/MMM" 1461cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 1471cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 1481cb0ef41Sopenharmony_ci * @return skeleton such as "MMMdd" 1491cb0ef41Sopenharmony_ci * @stable ICU 3.8 1501cb0ef41Sopenharmony_ci */ 1511cb0ef41Sopenharmony_ci UnicodeString getSkeleton(const UnicodeString& pattern, UErrorCode& status); /* { 1521cb0ef41Sopenharmony_ci The function is commented out because it is a stable API calling a draft API. 1531cb0ef41Sopenharmony_ci After staticGetSkeleton becomes stable, staticGetSkeleton can be used and 1541cb0ef41Sopenharmony_ci these comments and the definition of getSkeleton in dtptngen.cpp should be removed. 1551cb0ef41Sopenharmony_ci return staticGetSkeleton(pattern, status); 1561cb0ef41Sopenharmony_ci }*/ 1571cb0ef41Sopenharmony_ci 1581cb0ef41Sopenharmony_ci /** 1591cb0ef41Sopenharmony_ci * Utility to return a unique base skeleton from a given pattern. This is 1601cb0ef41Sopenharmony_ci * the same as the skeleton, except that differences in length are minimized 1611cb0ef41Sopenharmony_ci * so as to only preserve the difference between string and numeric form. So 1621cb0ef41Sopenharmony_ci * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" 1631cb0ef41Sopenharmony_ci * (notice the single d). 1641cb0ef41Sopenharmony_ci * 1651cb0ef41Sopenharmony_ci * @param pattern Input pattern, such as "dd/MMM" 1661cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 1671cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 1681cb0ef41Sopenharmony_ci * @return base skeleton, such as "MMMd" 1691cb0ef41Sopenharmony_ci * @stable ICU 56 1701cb0ef41Sopenharmony_ci */ 1711cb0ef41Sopenharmony_ci static UnicodeString staticGetBaseSkeleton(const UnicodeString& pattern, UErrorCode& status); 1721cb0ef41Sopenharmony_ci 1731cb0ef41Sopenharmony_ci /** 1741cb0ef41Sopenharmony_ci * Utility to return a unique base skeleton from a given pattern. This is 1751cb0ef41Sopenharmony_ci * the same as the skeleton, except that differences in length are minimized 1761cb0ef41Sopenharmony_ci * so as to only preserve the difference between string and numeric form. So 1771cb0ef41Sopenharmony_ci * for example, both "MMM-dd" and "d/MMM" produce the skeleton "MMMd" 1781cb0ef41Sopenharmony_ci * (notice the single d). 1791cb0ef41Sopenharmony_ci * getBaseSkeleton() works exactly like staticGetBaseSkeleton(). 1801cb0ef41Sopenharmony_ci * Use staticGetBaseSkeleton() instead of getBaseSkeleton(). 1811cb0ef41Sopenharmony_ci * 1821cb0ef41Sopenharmony_ci * @param pattern Input pattern, such as "dd/MMM" 1831cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 1841cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 1851cb0ef41Sopenharmony_ci * @return base skeleton, such as "MMMd" 1861cb0ef41Sopenharmony_ci * @stable ICU 3.8 1871cb0ef41Sopenharmony_ci */ 1881cb0ef41Sopenharmony_ci UnicodeString getBaseSkeleton(const UnicodeString& pattern, UErrorCode& status); /* { 1891cb0ef41Sopenharmony_ci The function is commented out because it is a stable API calling a draft API. 1901cb0ef41Sopenharmony_ci After staticGetBaseSkeleton becomes stable, staticGetBaseSkeleton can be used and 1911cb0ef41Sopenharmony_ci these comments and the definition of getBaseSkeleton in dtptngen.cpp should be removed. 1921cb0ef41Sopenharmony_ci return staticGetBaseSkeleton(pattern, status); 1931cb0ef41Sopenharmony_ci }*/ 1941cb0ef41Sopenharmony_ci 1951cb0ef41Sopenharmony_ci /** 1961cb0ef41Sopenharmony_ci * Adds a pattern to the generator. If the pattern has the same skeleton as 1971cb0ef41Sopenharmony_ci * an existing pattern, and the override parameter is set, then the previous 1981cb0ef41Sopenharmony_ci * value is overridden. Otherwise, the previous value is retained. In either 1991cb0ef41Sopenharmony_ci * case, the conflicting status is set and previous vale is stored in 2001cb0ef41Sopenharmony_ci * conflicting pattern. 2011cb0ef41Sopenharmony_ci * <p> 2021cb0ef41Sopenharmony_ci * Note that single-field patterns (like "MMM") are automatically added, and 2031cb0ef41Sopenharmony_ci * don't need to be added explicitly! 2041cb0ef41Sopenharmony_ci * 2051cb0ef41Sopenharmony_ci * @param pattern Input pattern, such as "dd/MMM" 2061cb0ef41Sopenharmony_ci * @param override When existing values are to be overridden use true, 2071cb0ef41Sopenharmony_ci * otherwise use false. 2081cb0ef41Sopenharmony_ci * @param conflictingPattern Previous pattern with the same skeleton. 2091cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 2101cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 2111cb0ef41Sopenharmony_ci * @return conflicting status. The value could be UDATPG_NO_CONFLICT, 2121cb0ef41Sopenharmony_ci * UDATPG_BASE_CONFLICT or UDATPG_CONFLICT. 2131cb0ef41Sopenharmony_ci * @stable ICU 3.8 2141cb0ef41Sopenharmony_ci * <p> 2151cb0ef41Sopenharmony_ci * <h4>Sample code</h4> 2161cb0ef41Sopenharmony_ci * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1 2171cb0ef41Sopenharmony_ci * \snippet samples/dtptngsample/dtptngsample.cpp addPatternExample 2181cb0ef41Sopenharmony_ci * <p> 2191cb0ef41Sopenharmony_ci */ 2201cb0ef41Sopenharmony_ci UDateTimePatternConflict addPattern(const UnicodeString& pattern, 2211cb0ef41Sopenharmony_ci UBool override, 2221cb0ef41Sopenharmony_ci UnicodeString& conflictingPattern, 2231cb0ef41Sopenharmony_ci UErrorCode& status); 2241cb0ef41Sopenharmony_ci 2251cb0ef41Sopenharmony_ci /** 2261cb0ef41Sopenharmony_ci * An AppendItem format is a pattern used to append a field if there is no 2271cb0ef41Sopenharmony_ci * good match. For example, suppose that the input skeleton is "GyyyyMMMd", 2281cb0ef41Sopenharmony_ci * and there is no matching pattern internally, but there is a pattern 2291cb0ef41Sopenharmony_ci * matching "yyyyMMMd", say "d-MM-yyyy". Then that pattern is used, plus the 2301cb0ef41Sopenharmony_ci * G. The way these two are conjoined is by using the AppendItemFormat for G 2311cb0ef41Sopenharmony_ci * (era). So if that value is, say "{0}, {1}" then the final resulting 2321cb0ef41Sopenharmony_ci * pattern is "d-MM-yyyy, G". 2331cb0ef41Sopenharmony_ci * <p> 2341cb0ef41Sopenharmony_ci * There are actually three available variables: {0} is the pattern so far, 2351cb0ef41Sopenharmony_ci * {1} is the element we are adding, and {2} is the name of the element. 2361cb0ef41Sopenharmony_ci * <p> 2371cb0ef41Sopenharmony_ci * This reflects the way that the CLDR data is organized. 2381cb0ef41Sopenharmony_ci * 2391cb0ef41Sopenharmony_ci * @param field such as UDATPG_ERA_FIELD. 2401cb0ef41Sopenharmony_ci * @param value pattern, such as "{0}, {1}" 2411cb0ef41Sopenharmony_ci * @stable ICU 3.8 2421cb0ef41Sopenharmony_ci */ 2431cb0ef41Sopenharmony_ci void setAppendItemFormat(UDateTimePatternField field, const UnicodeString& value); 2441cb0ef41Sopenharmony_ci 2451cb0ef41Sopenharmony_ci /** 2461cb0ef41Sopenharmony_ci * Getter corresponding to setAppendItemFormat. Values below 0 or at or 2471cb0ef41Sopenharmony_ci * above UDATPG_FIELD_COUNT are illegal arguments. 2481cb0ef41Sopenharmony_ci * 2491cb0ef41Sopenharmony_ci * @param field such as UDATPG_ERA_FIELD. 2501cb0ef41Sopenharmony_ci * @return append pattern for field 2511cb0ef41Sopenharmony_ci * @stable ICU 3.8 2521cb0ef41Sopenharmony_ci */ 2531cb0ef41Sopenharmony_ci const UnicodeString& getAppendItemFormat(UDateTimePatternField field) const; 2541cb0ef41Sopenharmony_ci 2551cb0ef41Sopenharmony_ci /** 2561cb0ef41Sopenharmony_ci * Sets the names of field, eg "era" in English for ERA. These are only 2571cb0ef41Sopenharmony_ci * used if the corresponding AppendItemFormat is used, and if it contains a 2581cb0ef41Sopenharmony_ci * {2} variable. 2591cb0ef41Sopenharmony_ci * <p> 2601cb0ef41Sopenharmony_ci * This reflects the way that the CLDR data is organized. 2611cb0ef41Sopenharmony_ci * 2621cb0ef41Sopenharmony_ci * @param field such as UDATPG_ERA_FIELD. 2631cb0ef41Sopenharmony_ci * @param value name of the field 2641cb0ef41Sopenharmony_ci * @stable ICU 3.8 2651cb0ef41Sopenharmony_ci */ 2661cb0ef41Sopenharmony_ci void setAppendItemName(UDateTimePatternField field, const UnicodeString& value); 2671cb0ef41Sopenharmony_ci 2681cb0ef41Sopenharmony_ci /** 2691cb0ef41Sopenharmony_ci * Getter corresponding to setAppendItemNames. Values below 0 or at or above 2701cb0ef41Sopenharmony_ci * UDATPG_FIELD_COUNT are illegal arguments. Note: The more general method 2711cb0ef41Sopenharmony_ci * for getting date/time field display names is getFieldDisplayName. 2721cb0ef41Sopenharmony_ci * 2731cb0ef41Sopenharmony_ci * @param field such as UDATPG_ERA_FIELD. 2741cb0ef41Sopenharmony_ci * @return name for field 2751cb0ef41Sopenharmony_ci * @see getFieldDisplayName 2761cb0ef41Sopenharmony_ci * @stable ICU 3.8 2771cb0ef41Sopenharmony_ci */ 2781cb0ef41Sopenharmony_ci const UnicodeString& getAppendItemName(UDateTimePatternField field) const; 2791cb0ef41Sopenharmony_ci 2801cb0ef41Sopenharmony_ci /** 2811cb0ef41Sopenharmony_ci * The general interface to get a display name for a particular date/time field, 2821cb0ef41Sopenharmony_ci * in one of several possible display widths. 2831cb0ef41Sopenharmony_ci * 2841cb0ef41Sopenharmony_ci * @param field The desired UDateTimePatternField, such as UDATPG_ERA_FIELD. 2851cb0ef41Sopenharmony_ci * @param width The desired UDateTimePGDisplayWidth, such as UDATPG_ABBREVIATED. 2861cb0ef41Sopenharmony_ci * @return The display name for field 2871cb0ef41Sopenharmony_ci * @stable ICU 61 2881cb0ef41Sopenharmony_ci */ 2891cb0ef41Sopenharmony_ci UnicodeString getFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width) const; 2901cb0ef41Sopenharmony_ci 2911cb0ef41Sopenharmony_ci /** 2921cb0ef41Sopenharmony_ci * The DateTimeFormat is a message format pattern used to compose date and 2931cb0ef41Sopenharmony_ci * time patterns. The default pattern in the root locale is "{1} {0}", where 2941cb0ef41Sopenharmony_ci * {1} will be replaced by the date pattern and {0} will be replaced by the 2951cb0ef41Sopenharmony_ci * time pattern; however, other locales may specify patterns such as 2961cb0ef41Sopenharmony_ci * "{1}, {0}" or "{1} 'at' {0}", etc. 2971cb0ef41Sopenharmony_ci * <p> 2981cb0ef41Sopenharmony_ci * This is used when the input skeleton contains both date and time fields, 2991cb0ef41Sopenharmony_ci * but there is not a close match among the added patterns. For example, 3001cb0ef41Sopenharmony_ci * suppose that this object was created by adding "dd-MMM" and "hh:mm", and 3011cb0ef41Sopenharmony_ci * its datetimeFormat is the default "{1} {0}". Then if the input skeleton 3021cb0ef41Sopenharmony_ci * is "MMMdhmm", there is not an exact match, so the input skeleton is 3031cb0ef41Sopenharmony_ci * broken up into two components "MMMd" and "hmm". There are close matches 3041cb0ef41Sopenharmony_ci * for those two skeletons, so the result is put together with this pattern, 3051cb0ef41Sopenharmony_ci * resulting in "d-MMM h:mm". 3061cb0ef41Sopenharmony_ci * 3071cb0ef41Sopenharmony_ci * There are four DateTimeFormats in a DateTimePatternGenerator object, 3081cb0ef41Sopenharmony_ci * corresponding to date styles UDAT_FULL..UDAT_SHORT. This method sets 3091cb0ef41Sopenharmony_ci * all of them to the specified pattern. To set them individually, see 3101cb0ef41Sopenharmony_ci * setDateTimeFormat(UDateFormatStyle style, ...). 3111cb0ef41Sopenharmony_ci * 3121cb0ef41Sopenharmony_ci * @param dateTimeFormat 3131cb0ef41Sopenharmony_ci * message format pattern, here {1} will be replaced by the date 3141cb0ef41Sopenharmony_ci * pattern and {0} will be replaced by the time pattern. 3151cb0ef41Sopenharmony_ci * @stable ICU 3.8 3161cb0ef41Sopenharmony_ci */ 3171cb0ef41Sopenharmony_ci void setDateTimeFormat(const UnicodeString& dateTimeFormat); 3181cb0ef41Sopenharmony_ci 3191cb0ef41Sopenharmony_ci /** 3201cb0ef41Sopenharmony_ci * Getter corresponding to setDateTimeFormat. 3211cb0ef41Sopenharmony_ci * 3221cb0ef41Sopenharmony_ci * There are four DateTimeFormats in a DateTimePatternGenerator object, 3231cb0ef41Sopenharmony_ci * corresponding to date styles UDAT_FULL..UDAT_SHORT. This method gets 3241cb0ef41Sopenharmony_ci * the style for UDAT_MEDIUM (the default). To get them individually, see 3251cb0ef41Sopenharmony_ci * getDateTimeFormat(UDateFormatStyle style). 3261cb0ef41Sopenharmony_ci * 3271cb0ef41Sopenharmony_ci * @return DateTimeFormat. 3281cb0ef41Sopenharmony_ci * @stable ICU 3.8 3291cb0ef41Sopenharmony_ci */ 3301cb0ef41Sopenharmony_ci const UnicodeString& getDateTimeFormat() const; 3311cb0ef41Sopenharmony_ci 3321cb0ef41Sopenharmony_ci#if !UCONFIG_NO_FORMATTING 3331cb0ef41Sopenharmony_ci /** 3341cb0ef41Sopenharmony_ci * dateTimeFormats are message patterns used to compose combinations of date 3351cb0ef41Sopenharmony_ci * and time patterns. There are four length styles, corresponding to the 3361cb0ef41Sopenharmony_ci * inferred style of the date pattern; these are UDateFormatStyle values: 3371cb0ef41Sopenharmony_ci * - UDAT_FULL (for date pattern with weekday and long month), else 3381cb0ef41Sopenharmony_ci * - UDAT_LONG (for a date pattern with long month), else 3391cb0ef41Sopenharmony_ci * - UDAT_MEDIUM (for a date pattern with abbreviated month), else 3401cb0ef41Sopenharmony_ci * - UDAT_SHORT (for any other date pattern). 3411cb0ef41Sopenharmony_ci * For details on dateTimeFormats, see 3421cb0ef41Sopenharmony_ci * https://www.unicode.org/reports/tr35/tr35-dates.html#dateTimeFormats. 3431cb0ef41Sopenharmony_ci * The default pattern in the root locale for all styles is "{1} {0}". 3441cb0ef41Sopenharmony_ci * 3451cb0ef41Sopenharmony_ci * @param style 3461cb0ef41Sopenharmony_ci * one of DateFormat.FULL..DateFormat.SHORT. Error if out of range. 3471cb0ef41Sopenharmony_ci * @param dateTimeFormat 3481cb0ef41Sopenharmony_ci * the new dateTimeFormat to set for the the specified style 3491cb0ef41Sopenharmony_ci * @param status 3501cb0ef41Sopenharmony_ci * in/out parameter; if no failure status is already set, 3511cb0ef41Sopenharmony_ci * it will be set according to result of the function (e.g. 3521cb0ef41Sopenharmony_ci * U_ILLEGAL_ARGUMENT_ERROR for style out of range). 3531cb0ef41Sopenharmony_ci * @stable ICU 71 3541cb0ef41Sopenharmony_ci */ 3551cb0ef41Sopenharmony_ci void setDateTimeFormat(UDateFormatStyle style, const UnicodeString& dateTimeFormat, 3561cb0ef41Sopenharmony_ci UErrorCode& status); 3571cb0ef41Sopenharmony_ci 3581cb0ef41Sopenharmony_ci /** 3591cb0ef41Sopenharmony_ci * Getter corresponding to setDateTimeFormat. 3601cb0ef41Sopenharmony_ci * 3611cb0ef41Sopenharmony_ci * @param style 3621cb0ef41Sopenharmony_ci * one of UDAT_FULL..UDAT_SHORT. Error if out of range. 3631cb0ef41Sopenharmony_ci * @param status 3641cb0ef41Sopenharmony_ci * in/out parameter; if no failure status is already set, 3651cb0ef41Sopenharmony_ci * it will be set according to result of the function (e.g. 3661cb0ef41Sopenharmony_ci * U_ILLEGAL_ARGUMENT_ERROR for style out of range). 3671cb0ef41Sopenharmony_ci * @return 3681cb0ef41Sopenharmony_ci * the current dateTimeFormat for the the specified style, or 3691cb0ef41Sopenharmony_ci * empty string in case of error. The UnicodeString reference, 3701cb0ef41Sopenharmony_ci * or the contents of the string, may no longer be valid if 3711cb0ef41Sopenharmony_ci * setDateTimeFormat is called, or the DateTimePatternGenerator 3721cb0ef41Sopenharmony_ci * object is deleted. 3731cb0ef41Sopenharmony_ci * @stable ICU 71 3741cb0ef41Sopenharmony_ci */ 3751cb0ef41Sopenharmony_ci const UnicodeString& getDateTimeFormat(UDateFormatStyle style, 3761cb0ef41Sopenharmony_ci UErrorCode& status) const; 3771cb0ef41Sopenharmony_ci#endif /* #if !UCONFIG_NO_FORMATTING */ 3781cb0ef41Sopenharmony_ci 3791cb0ef41Sopenharmony_ci /** 3801cb0ef41Sopenharmony_ci * Return the best pattern matching the input skeleton. It is guaranteed to 3811cb0ef41Sopenharmony_ci * have all of the fields in the skeleton. 3821cb0ef41Sopenharmony_ci * 3831cb0ef41Sopenharmony_ci * @param skeleton 3841cb0ef41Sopenharmony_ci * The skeleton is a pattern containing only the variable fields. 3851cb0ef41Sopenharmony_ci * For example, "MMMdd" and "mmhh" are skeletons. 3861cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 3871cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 3881cb0ef41Sopenharmony_ci * @return bestPattern 3891cb0ef41Sopenharmony_ci * The best pattern found from the given skeleton. 3901cb0ef41Sopenharmony_ci * @stable ICU 3.8 3911cb0ef41Sopenharmony_ci * <p> 3921cb0ef41Sopenharmony_ci * <h4>Sample code</h4> 3931cb0ef41Sopenharmony_ci * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1 3941cb0ef41Sopenharmony_ci * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample 3951cb0ef41Sopenharmony_ci * <p> 3961cb0ef41Sopenharmony_ci */ 3971cb0ef41Sopenharmony_ci UnicodeString getBestPattern(const UnicodeString& skeleton, UErrorCode& status); 3981cb0ef41Sopenharmony_ci 3991cb0ef41Sopenharmony_ci 4001cb0ef41Sopenharmony_ci /** 4011cb0ef41Sopenharmony_ci * Return the best pattern matching the input skeleton. It is guaranteed to 4021cb0ef41Sopenharmony_ci * have all of the fields in the skeleton. 4031cb0ef41Sopenharmony_ci * 4041cb0ef41Sopenharmony_ci * @param skeleton 4051cb0ef41Sopenharmony_ci * The skeleton is a pattern containing only the variable fields. 4061cb0ef41Sopenharmony_ci * For example, "MMMdd" and "mmhh" are skeletons. 4071cb0ef41Sopenharmony_ci * @param options 4081cb0ef41Sopenharmony_ci * Options for forcing the length of specified fields in the 4091cb0ef41Sopenharmony_ci * returned pattern to match those in the skeleton (when this 4101cb0ef41Sopenharmony_ci * would not happen otherwise). For default behavior, use 4111cb0ef41Sopenharmony_ci * UDATPG_MATCH_NO_OPTIONS. 4121cb0ef41Sopenharmony_ci * @param status 4131cb0ef41Sopenharmony_ci * Output param set to success/failure code on exit, 4141cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 4151cb0ef41Sopenharmony_ci * @return bestPattern 4161cb0ef41Sopenharmony_ci * The best pattern found from the given skeleton. 4171cb0ef41Sopenharmony_ci * @stable ICU 4.4 4181cb0ef41Sopenharmony_ci */ 4191cb0ef41Sopenharmony_ci UnicodeString getBestPattern(const UnicodeString& skeleton, 4201cb0ef41Sopenharmony_ci UDateTimePatternMatchOptions options, 4211cb0ef41Sopenharmony_ci UErrorCode& status); 4221cb0ef41Sopenharmony_ci 4231cb0ef41Sopenharmony_ci 4241cb0ef41Sopenharmony_ci /** 4251cb0ef41Sopenharmony_ci * Adjusts the field types (width and subtype) of a pattern to match what is 4261cb0ef41Sopenharmony_ci * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a 4271cb0ef41Sopenharmony_ci * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be 4281cb0ef41Sopenharmony_ci * "dd-MMMM hh:mm". This is used internally to get the best match for the 4291cb0ef41Sopenharmony_ci * input skeleton, but can also be used externally. 4301cb0ef41Sopenharmony_ci * 4311cb0ef41Sopenharmony_ci * @param pattern Input pattern 4321cb0ef41Sopenharmony_ci * @param skeleton 4331cb0ef41Sopenharmony_ci * The skeleton is a pattern containing only the variable fields. 4341cb0ef41Sopenharmony_ci * For example, "MMMdd" and "mmhh" are skeletons. 4351cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 4361cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 4371cb0ef41Sopenharmony_ci * @return pattern adjusted to match the skeleton fields widths and subtypes. 4381cb0ef41Sopenharmony_ci * @stable ICU 3.8 4391cb0ef41Sopenharmony_ci * <p> 4401cb0ef41Sopenharmony_ci * <h4>Sample code</h4> 4411cb0ef41Sopenharmony_ci * \snippet samples/dtptngsample/dtptngsample.cpp getBestPatternExample1 4421cb0ef41Sopenharmony_ci * \snippet samples/dtptngsample/dtptngsample.cpp replaceFieldTypesExample 4431cb0ef41Sopenharmony_ci * <p> 4441cb0ef41Sopenharmony_ci */ 4451cb0ef41Sopenharmony_ci UnicodeString replaceFieldTypes(const UnicodeString& pattern, 4461cb0ef41Sopenharmony_ci const UnicodeString& skeleton, 4471cb0ef41Sopenharmony_ci UErrorCode& status); 4481cb0ef41Sopenharmony_ci 4491cb0ef41Sopenharmony_ci /** 4501cb0ef41Sopenharmony_ci * Adjusts the field types (width and subtype) of a pattern to match what is 4511cb0ef41Sopenharmony_ci * in a skeleton. That is, if you supply a pattern like "d-M H:m", and a 4521cb0ef41Sopenharmony_ci * skeleton of "MMMMddhhmm", then the input pattern is adjusted to be 4531cb0ef41Sopenharmony_ci * "dd-MMMM hh:mm". This is used internally to get the best match for the 4541cb0ef41Sopenharmony_ci * input skeleton, but can also be used externally. 4551cb0ef41Sopenharmony_ci * 4561cb0ef41Sopenharmony_ci * @param pattern Input pattern 4571cb0ef41Sopenharmony_ci * @param skeleton 4581cb0ef41Sopenharmony_ci * The skeleton is a pattern containing only the variable fields. 4591cb0ef41Sopenharmony_ci * For example, "MMMdd" and "mmhh" are skeletons. 4601cb0ef41Sopenharmony_ci * @param options 4611cb0ef41Sopenharmony_ci * Options controlling whether the length of specified fields in the 4621cb0ef41Sopenharmony_ci * pattern are adjusted to match those in the skeleton (when this 4631cb0ef41Sopenharmony_ci * would not happen otherwise). For default behavior, use 4641cb0ef41Sopenharmony_ci * UDATPG_MATCH_NO_OPTIONS. 4651cb0ef41Sopenharmony_ci * @param status 4661cb0ef41Sopenharmony_ci * Output param set to success/failure code on exit, 4671cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 4681cb0ef41Sopenharmony_ci * @return pattern adjusted to match the skeleton fields widths and subtypes. 4691cb0ef41Sopenharmony_ci * @stable ICU 4.4 4701cb0ef41Sopenharmony_ci */ 4711cb0ef41Sopenharmony_ci UnicodeString replaceFieldTypes(const UnicodeString& pattern, 4721cb0ef41Sopenharmony_ci const UnicodeString& skeleton, 4731cb0ef41Sopenharmony_ci UDateTimePatternMatchOptions options, 4741cb0ef41Sopenharmony_ci UErrorCode& status); 4751cb0ef41Sopenharmony_ci 4761cb0ef41Sopenharmony_ci /** 4771cb0ef41Sopenharmony_ci * Return a list of all the skeletons (in canonical form) from this class. 4781cb0ef41Sopenharmony_ci * 4791cb0ef41Sopenharmony_ci * Call getPatternForSkeleton() to get the corresponding pattern. 4801cb0ef41Sopenharmony_ci * 4811cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 4821cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 4831cb0ef41Sopenharmony_ci * @return StringEnumeration with the skeletons. 4841cb0ef41Sopenharmony_ci * The caller must delete the object. 4851cb0ef41Sopenharmony_ci * @stable ICU 3.8 4861cb0ef41Sopenharmony_ci */ 4871cb0ef41Sopenharmony_ci StringEnumeration* getSkeletons(UErrorCode& status) const; 4881cb0ef41Sopenharmony_ci 4891cb0ef41Sopenharmony_ci /** 4901cb0ef41Sopenharmony_ci * Get the pattern corresponding to a given skeleton. 4911cb0ef41Sopenharmony_ci * @param skeleton 4921cb0ef41Sopenharmony_ci * @return pattern corresponding to a given skeleton. 4931cb0ef41Sopenharmony_ci * @stable ICU 3.8 4941cb0ef41Sopenharmony_ci */ 4951cb0ef41Sopenharmony_ci const UnicodeString& getPatternForSkeleton(const UnicodeString& skeleton) const; 4961cb0ef41Sopenharmony_ci 4971cb0ef41Sopenharmony_ci /** 4981cb0ef41Sopenharmony_ci * Return a list of all the base skeletons (in canonical form) from this class. 4991cb0ef41Sopenharmony_ci * 5001cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 5011cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 5021cb0ef41Sopenharmony_ci * @return a StringEnumeration with the base skeletons. 5031cb0ef41Sopenharmony_ci * The caller must delete the object. 5041cb0ef41Sopenharmony_ci * @stable ICU 3.8 5051cb0ef41Sopenharmony_ci */ 5061cb0ef41Sopenharmony_ci StringEnumeration* getBaseSkeletons(UErrorCode& status) const; 5071cb0ef41Sopenharmony_ci 5081cb0ef41Sopenharmony_ci#ifndef U_HIDE_INTERNAL_API 5091cb0ef41Sopenharmony_ci /** 5101cb0ef41Sopenharmony_ci * Return a list of redundant patterns are those which if removed, make no 5111cb0ef41Sopenharmony_ci * difference in the resulting getBestPattern values. This method returns a 5121cb0ef41Sopenharmony_ci * list of them, to help check the consistency of the patterns used to build 5131cb0ef41Sopenharmony_ci * this generator. 5141cb0ef41Sopenharmony_ci * 5151cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, 5161cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 5171cb0ef41Sopenharmony_ci * @return a StringEnumeration with the redundant pattern. 5181cb0ef41Sopenharmony_ci * The caller must delete the object. 5191cb0ef41Sopenharmony_ci * @internal ICU 3.8 5201cb0ef41Sopenharmony_ci */ 5211cb0ef41Sopenharmony_ci StringEnumeration* getRedundants(UErrorCode& status); 5221cb0ef41Sopenharmony_ci#endif /* U_HIDE_INTERNAL_API */ 5231cb0ef41Sopenharmony_ci 5241cb0ef41Sopenharmony_ci /** 5251cb0ef41Sopenharmony_ci * The decimal value is used in formatting fractions of seconds. If the 5261cb0ef41Sopenharmony_ci * skeleton contains fractional seconds, then this is used with the 5271cb0ef41Sopenharmony_ci * fractional seconds. For example, suppose that the input pattern is 5281cb0ef41Sopenharmony_ci * "hhmmssSSSS", and the best matching pattern internally is "H:mm:ss", and 5291cb0ef41Sopenharmony_ci * the decimal string is ",". Then the resulting pattern is modified to be 5301cb0ef41Sopenharmony_ci * "H:mm:ss,SSSS" 5311cb0ef41Sopenharmony_ci * 5321cb0ef41Sopenharmony_ci * @param decimal 5331cb0ef41Sopenharmony_ci * @stable ICU 3.8 5341cb0ef41Sopenharmony_ci */ 5351cb0ef41Sopenharmony_ci void setDecimal(const UnicodeString& decimal); 5361cb0ef41Sopenharmony_ci 5371cb0ef41Sopenharmony_ci /** 5381cb0ef41Sopenharmony_ci * Getter corresponding to setDecimal. 5391cb0ef41Sopenharmony_ci * @return UnicodeString corresponding to the decimal point 5401cb0ef41Sopenharmony_ci * @stable ICU 3.8 5411cb0ef41Sopenharmony_ci */ 5421cb0ef41Sopenharmony_ci const UnicodeString& getDecimal() const; 5431cb0ef41Sopenharmony_ci 5441cb0ef41Sopenharmony_ci#if !UCONFIG_NO_FORMATTING 5451cb0ef41Sopenharmony_ci 5461cb0ef41Sopenharmony_ci /** 5471cb0ef41Sopenharmony_ci * Get the default hour cycle for a locale. Uses the locale that the 5481cb0ef41Sopenharmony_ci * DateTimePatternGenerator was initially created with. 5491cb0ef41Sopenharmony_ci * 5501cb0ef41Sopenharmony_ci * Cannot be used on an empty DateTimePatternGenerator instance. 5511cb0ef41Sopenharmony_ci * 5521cb0ef41Sopenharmony_ci * @param status Output param set to success/failure code on exit, which 5531cb0ef41Sopenharmony_ci * which must not indicate a failure before the function call. 5541cb0ef41Sopenharmony_ci * Set to U_UNSUPPORTED_ERROR if used on an empty instance. 5551cb0ef41Sopenharmony_ci * @return the default hour cycle. 5561cb0ef41Sopenharmony_ci * @stable ICU 67 5571cb0ef41Sopenharmony_ci */ 5581cb0ef41Sopenharmony_ci UDateFormatHourCycle getDefaultHourCycle(UErrorCode& status) const; 5591cb0ef41Sopenharmony_ci 5601cb0ef41Sopenharmony_ci#endif /* #if !UCONFIG_NO_FORMATTING */ 5611cb0ef41Sopenharmony_ci 5621cb0ef41Sopenharmony_ci /** 5631cb0ef41Sopenharmony_ci * ICU "poor man's RTTI", returns a UClassID for the actual class. 5641cb0ef41Sopenharmony_ci * 5651cb0ef41Sopenharmony_ci * @stable ICU 3.8 5661cb0ef41Sopenharmony_ci */ 5671cb0ef41Sopenharmony_ci virtual UClassID getDynamicClassID() const override; 5681cb0ef41Sopenharmony_ci 5691cb0ef41Sopenharmony_ci /** 5701cb0ef41Sopenharmony_ci * ICU "poor man's RTTI", returns a UClassID for this class. 5711cb0ef41Sopenharmony_ci * 5721cb0ef41Sopenharmony_ci * @stable ICU 3.8 5731cb0ef41Sopenharmony_ci */ 5741cb0ef41Sopenharmony_ci static UClassID U_EXPORT2 getStaticClassID(void); 5751cb0ef41Sopenharmony_ci 5761cb0ef41Sopenharmony_ciprivate: 5771cb0ef41Sopenharmony_ci /** 5781cb0ef41Sopenharmony_ci * Constructor. 5791cb0ef41Sopenharmony_ci */ 5801cb0ef41Sopenharmony_ci DateTimePatternGenerator(UErrorCode & status); 5811cb0ef41Sopenharmony_ci 5821cb0ef41Sopenharmony_ci /** 5831cb0ef41Sopenharmony_ci * Constructor. 5841cb0ef41Sopenharmony_ci */ 5851cb0ef41Sopenharmony_ci DateTimePatternGenerator(const Locale& locale, UErrorCode & status, UBool skipStdPatterns = false); 5861cb0ef41Sopenharmony_ci 5871cb0ef41Sopenharmony_ci /** 5881cb0ef41Sopenharmony_ci * Copy constructor. 5891cb0ef41Sopenharmony_ci * @param other DateTimePatternGenerator to copy 5901cb0ef41Sopenharmony_ci */ 5911cb0ef41Sopenharmony_ci DateTimePatternGenerator(const DateTimePatternGenerator& other); 5921cb0ef41Sopenharmony_ci 5931cb0ef41Sopenharmony_ci /** 5941cb0ef41Sopenharmony_ci * Default assignment operator. 5951cb0ef41Sopenharmony_ci * @param other DateTimePatternGenerator to copy 5961cb0ef41Sopenharmony_ci */ 5971cb0ef41Sopenharmony_ci DateTimePatternGenerator& operator=(const DateTimePatternGenerator& other); 5981cb0ef41Sopenharmony_ci 5991cb0ef41Sopenharmony_ci static const int32_t UDATPG_WIDTH_COUNT = UDATPG_NARROW + 1; 6001cb0ef41Sopenharmony_ci 6011cb0ef41Sopenharmony_ci Locale pLocale; // pattern locale 6021cb0ef41Sopenharmony_ci FormatParser *fp; 6031cb0ef41Sopenharmony_ci DateTimeMatcher* dtMatcher; 6041cb0ef41Sopenharmony_ci DistanceInfo *distanceInfo; 6051cb0ef41Sopenharmony_ci PatternMap *patternMap; 6061cb0ef41Sopenharmony_ci UnicodeString appendItemFormats[UDATPG_FIELD_COUNT]; 6071cb0ef41Sopenharmony_ci UnicodeString fieldDisplayNames[UDATPG_FIELD_COUNT][UDATPG_WIDTH_COUNT]; 6081cb0ef41Sopenharmony_ci UnicodeString dateTimeFormat[4]; 6091cb0ef41Sopenharmony_ci UnicodeString decimal; 6101cb0ef41Sopenharmony_ci DateTimeMatcher *skipMatcher; 6111cb0ef41Sopenharmony_ci Hashtable *fAvailableFormatKeyHash; 6121cb0ef41Sopenharmony_ci UnicodeString emptyString; 6131cb0ef41Sopenharmony_ci char16_t fDefaultHourFormatChar; 6141cb0ef41Sopenharmony_ci 6151cb0ef41Sopenharmony_ci int32_t fAllowedHourFormats[7]; // Actually an array of AllowedHourFormat enum type, ending with UNKNOWN. 6161cb0ef41Sopenharmony_ci 6171cb0ef41Sopenharmony_ci // Internal error code used for recording/reporting errors that occur during methods that do not 6181cb0ef41Sopenharmony_ci // have a UErrorCode parameter. For example: the Copy Constructor, or the ::clone() method. 6191cb0ef41Sopenharmony_ci // When this is set to an error the object is in an invalid state. 6201cb0ef41Sopenharmony_ci UErrorCode internalErrorCode; 6211cb0ef41Sopenharmony_ci 6221cb0ef41Sopenharmony_ci /* internal flags masks for adjustFieldTypes etc. */ 6231cb0ef41Sopenharmony_ci enum { 6241cb0ef41Sopenharmony_ci kDTPGNoFlags = 0, 6251cb0ef41Sopenharmony_ci kDTPGFixFractionalSeconds = 1, 6261cb0ef41Sopenharmony_ci kDTPGSkeletonUsesCapJ = 2 6271cb0ef41Sopenharmony_ci // with #13183, no longer need flags for b, B 6281cb0ef41Sopenharmony_ci }; 6291cb0ef41Sopenharmony_ci 6301cb0ef41Sopenharmony_ci void initData(const Locale &locale, UErrorCode &status, UBool skipStdPatterns = false); 6311cb0ef41Sopenharmony_ci void addCanonicalItems(UErrorCode &status); 6321cb0ef41Sopenharmony_ci void addICUPatterns(const Locale& locale, UErrorCode& status); 6331cb0ef41Sopenharmony_ci void hackTimes(const UnicodeString& hackPattern, UErrorCode& status); 6341cb0ef41Sopenharmony_ci void getCalendarTypeToUse(const Locale& locale, CharString& destination, UErrorCode& err); 6351cb0ef41Sopenharmony_ci void consumeShortTimePattern(const UnicodeString& shortTimePattern, UErrorCode& status); 6361cb0ef41Sopenharmony_ci void addCLDRData(const Locale& locale, UErrorCode& status); 6371cb0ef41Sopenharmony_ci UDateTimePatternConflict addPatternWithSkeleton(const UnicodeString& pattern, const UnicodeString * skeletonToUse, UBool override, UnicodeString& conflictingPattern, UErrorCode& status); 6381cb0ef41Sopenharmony_ci void initHashtable(UErrorCode& status); 6391cb0ef41Sopenharmony_ci void setDateTimeFromCalendar(const Locale& locale, UErrorCode& status); 6401cb0ef41Sopenharmony_ci void setDecimalSymbols(const Locale& locale, UErrorCode& status); 6411cb0ef41Sopenharmony_ci UDateTimePatternField getAppendFormatNumber(const char* field) const; 6421cb0ef41Sopenharmony_ci // Note for the next 3: UDateTimePGDisplayWidth is now stable ICU 61 6431cb0ef41Sopenharmony_ci UDateTimePatternField getFieldAndWidthIndices(const char* key, UDateTimePGDisplayWidth* widthP) const; 6441cb0ef41Sopenharmony_ci void setFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width, const UnicodeString& value); 6451cb0ef41Sopenharmony_ci UnicodeString& getMutableFieldDisplayName(UDateTimePatternField field, UDateTimePGDisplayWidth width); 6461cb0ef41Sopenharmony_ci void getAppendName(UDateTimePatternField field, UnicodeString& value); 6471cb0ef41Sopenharmony_ci UnicodeString mapSkeletonMetacharacters(const UnicodeString& patternForm, int32_t* flags, UErrorCode& status); 6481cb0ef41Sopenharmony_ci const UnicodeString* getBestRaw(DateTimeMatcher& source, int32_t includeMask, DistanceInfo* missingFields, UErrorCode& status, const PtnSkeleton** specifiedSkeletonPtr = 0); 6491cb0ef41Sopenharmony_ci UnicodeString adjustFieldTypes(const UnicodeString& pattern, const PtnSkeleton* specifiedSkeleton, int32_t flags, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); 6501cb0ef41Sopenharmony_ci UnicodeString getBestAppending(int32_t missingFields, int32_t flags, UErrorCode& status, UDateTimePatternMatchOptions options = UDATPG_MATCH_NO_OPTIONS); 6511cb0ef41Sopenharmony_ci int32_t getTopBitNumber(int32_t foundMask) const; 6521cb0ef41Sopenharmony_ci void setAvailableFormat(const UnicodeString &key, UErrorCode& status); 6531cb0ef41Sopenharmony_ci UBool isAvailableFormatSet(const UnicodeString &key) const; 6541cb0ef41Sopenharmony_ci void copyHashtable(Hashtable *other, UErrorCode &status); 6551cb0ef41Sopenharmony_ci UBool isCanonicalItem(const UnicodeString& item) const; 6561cb0ef41Sopenharmony_ci static void U_CALLCONV loadAllowedHourFormatsData(UErrorCode &status); 6571cb0ef41Sopenharmony_ci void getAllowedHourFormats(const Locale &locale, UErrorCode &status); 6581cb0ef41Sopenharmony_ci 6591cb0ef41Sopenharmony_ci struct U_HIDDEN AppendItemFormatsSink; 6601cb0ef41Sopenharmony_ci struct U_HIDDEN AppendItemNamesSink; 6611cb0ef41Sopenharmony_ci struct U_HIDDEN AvailableFormatsSink; 6621cb0ef41Sopenharmony_ci} ;// end class DateTimePatternGenerator 6631cb0ef41Sopenharmony_ci 6641cb0ef41Sopenharmony_ciU_NAMESPACE_END 6651cb0ef41Sopenharmony_ci 6661cb0ef41Sopenharmony_ci#endif /* U_SHOW_CPLUSPLUS_API */ 6671cb0ef41Sopenharmony_ci 6681cb0ef41Sopenharmony_ci#endif 669