Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/unicode/udat.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // © 2016 and later: Unicode, Inc. and others.
0002 // License & terms of use: http://www.unicode.org/copyright.html
0003 /*
0004  *******************************************************************************
0005  * Copyright (C) 1996-2016, International Business Machines
0006  * Corporation and others. All Rights Reserved.
0007  *******************************************************************************
0008 */
0009 
0010 #ifndef UDAT_H
0011 #define UDAT_H
0012 
0013 #include "unicode/utypes.h"
0014 
0015 #if !UCONFIG_NO_FORMATTING
0016 
0017 #include "unicode/ucal.h"
0018 #include "unicode/unum.h"
0019 #include "unicode/udisplaycontext.h"
0020 #include "unicode/ufieldpositer.h"
0021 
0022 #if U_SHOW_CPLUSPLUS_API
0023 #include "unicode/localpointer.h"
0024 #endif   // U_SHOW_CPLUSPLUS_API
0025 
0026 /**
0027  * \file
0028  * \brief C API: DateFormat
0029  *
0030  * <h2> Date Format C API</h2>
0031  *
0032  * Date Format C API  consists of functions that convert dates and
0033  * times from their internal representations to textual form and back again in a
0034  * language-independent manner. Converting from the internal representation (milliseconds
0035  * since midnight, January 1, 1970) to text is known as "formatting," and converting
0036  * from text to millis is known as "parsing."  We currently define only one concrete
0037  * structure UDateFormat, which can handle pretty much all normal
0038  * date formatting and parsing actions.
0039  * <P>
0040  * Date Format helps you to format and parse dates for any locale. Your code can
0041  * be completely independent of the locale conventions for months, days of the
0042  * week, or even the calendar format: lunar vs. solar.
0043  * <P>
0044  * To format a date for the current Locale with default time and date style,
0045  * use one of the static factory methods:
0046  * <pre>
0047  * \code
0048  *  UErrorCode status = U_ZERO_ERROR;
0049  *  UChar *myString;
0050  *  int32_t myStrlen = 0;
0051  *  UDateFormat* dfmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, -1, &status);
0052  *  myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, NULL, &status);
0053  *  if (status==U_BUFFER_OVERFLOW_ERROR){
0054  *      status=U_ZERO_ERROR;
0055  *      myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
0056  *      udat_format(dfmt, myDate, myString, myStrlen+1, NULL, &status);
0057  *  }
0058  * \endcode
0059  * </pre>
0060  * If you are formatting multiple numbers, it is more efficient to get the
0061  * format and use it multiple times so that the system doesn't have to fetch the
0062  * information about the local language and country conventions multiple times.
0063  * <pre>
0064  * \code
0065  *  UErrorCode status = U_ZERO_ERROR;
0066  *  int32_t i, myStrlen = 0;
0067  *  UChar* myString;
0068  *  char buffer[1024];
0069  *  UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
0070  *  UDateFormat* df = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, 0, &status);
0071  *  for (i = 0; i < 3; i++) {
0072  *      myStrlen = udat_format(df, myDateArr[i], NULL, myStrlen, NULL, &status);
0073  *      if(status == U_BUFFER_OVERFLOW_ERROR){
0074  *          status = U_ZERO_ERROR;
0075  *          myString = (UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
0076  *          udat_format(df, myDateArr[i], myString, myStrlen+1, NULL, &status);
0077  *          printf("%s\n", u_austrcpy(buffer, myString) );
0078  *          free(myString);
0079  *      }
0080  *  }
0081  * \endcode
0082  * </pre>
0083  * To get specific fields of a date, you can use UFieldPosition to
0084  * get specific fields.
0085  * <pre>
0086  * \code
0087  *  UErrorCode status = U_ZERO_ERROR;
0088  *  UFieldPosition pos;
0089  *  UChar *myString;
0090  *  int32_t myStrlen = 0;
0091  *  char buffer[1024];
0092  *
0093  *  pos.field = 1;  // Same as the DateFormat::EField enum
0094  *  UDateFormat* dfmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, -1, NULL, 0, &status);
0095  *  myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, &pos, &status);
0096  *  if (status==U_BUFFER_OVERFLOW_ERROR){
0097  *      status=U_ZERO_ERROR;
0098  *      myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
0099  *      udat_format(dfmt, myDate, myString, myStrlen+1, &pos, &status);
0100  *  }
0101  *  printf("date format: %s\n", u_austrcpy(buffer, myString));
0102  *  buffer[pos.endIndex] = 0;   // NULL terminate the string.
0103  *  printf("UFieldPosition position equals %s\n", &buffer[pos.beginIndex]);
0104  * \endcode
0105  * </pre>
0106  * To format a date for a different Locale, specify it in the call to
0107  * udat_open()
0108  * <pre>
0109  * \code
0110  *        UDateFormat* df = udat_open(UDAT_SHORT, UDAT_SHORT, "fr_FR", NULL, -1, NULL, 0, &status);
0111  * \endcode
0112  * </pre>
0113  * You can use a DateFormat API udat_parse() to parse.
0114  * <pre>
0115  * \code
0116  *  UErrorCode status = U_ZERO_ERROR;
0117  *  int32_t parsepos=0;
0118  *  UDate myDate = udat_parse(df, myString, u_strlen(myString), &parsepos, &status);
0119  * \endcode
0120  * </pre>
0121  *  You can pass in different options for the arguments for date and time style
0122  *  to control the length of the result; from SHORT to MEDIUM to LONG to FULL.
0123  *  The exact result depends on the locale, but generally:
0124  *  see UDateFormatStyle for more details
0125  * <ul type=round>
0126  *   <li>   UDAT_SHORT is completely numeric, such as 12/13/52 or 3:30pm
0127  *   <li>   UDAT_MEDIUM is longer, such as Jan 12, 1952
0128  *   <li>   UDAT_LONG is longer, such as January 12, 1952 or 3:30:32pm
0129  *   <li>   UDAT_FULL is pretty completely specified, such as
0130  *          Tuesday, April 12, 1952 AD or 3:30:42pm PST.
0131  * </ul>
0132  * You can also set the time zone on the format if you wish.
0133  * <P>
0134  * You can also use forms of the parse and format methods with Parse Position and
0135  * UFieldPosition to allow you to
0136  * <ul type=round>
0137  *   <li>   Progressively parse through pieces of a string.
0138  *   <li>   Align any particular field, or find out where it is for selection
0139  *          on the screen.
0140  * </ul>
0141  * <p><strong>Date and Time Patterns:</strong></p>
0142  *
0143  * <p>Date and time formats are specified by <em>date and time pattern</em> strings.
0144  * Within date and time pattern strings, all unquoted ASCII letters [A-Za-z] are reserved
0145  * as pattern letters representing calendar fields. <code>UDateFormat</code> supports
0146  * the date and time formatting algorithm and pattern letters defined by
0147  * <a href="http://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table">UTS#35
0148  * Unicode Locale Data Markup Language (LDML)</a> and further documented for ICU in the
0149  * <a href="https://unicode-org.github.io/icu/userguide/format_parse/datetime#date-field-symbol-table">ICU
0150  * User Guide</a>.</p>
0151  */
0152 
0153 /** A date formatter.
0154  *  For usage in C programs.
0155  *  @stable ICU 2.6
0156  */
0157 typedef void* UDateFormat;
0158 
0159 /** The possible date/time format styles
0160  *  @stable ICU 2.6
0161  */
0162 typedef enum UDateFormatStyle {
0163     /** Full style */
0164     UDAT_FULL,
0165     /** Long style */
0166     UDAT_LONG,
0167     /** Medium style */
0168     UDAT_MEDIUM,
0169     /** Short style */
0170     UDAT_SHORT,
0171     /** Default style */
0172     UDAT_DEFAULT = UDAT_MEDIUM,
0173 
0174     /** Bitfield for relative date */
0175     UDAT_RELATIVE = (1 << 7),
0176 
0177     UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE,
0178 
0179     UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE,
0180 
0181     UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE,
0182 
0183     UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE,
0184 
0185 
0186     /** No style */
0187     UDAT_NONE = -1,
0188 
0189     /**
0190      * Use the pattern given in the parameter to udat_open
0191      * @see udat_open
0192      * @stable ICU 50
0193      */
0194     UDAT_PATTERN = -2,
0195 
0196 #ifndef U_HIDE_INTERNAL_API
0197     /** @internal alias to UDAT_PATTERN */
0198     UDAT_IGNORE = UDAT_PATTERN
0199 #endif /* U_HIDE_INTERNAL_API */
0200 } UDateFormatStyle;
0201 
0202 /* Skeletons for dates. */
0203 
0204 /**
0205  * Constant for date skeleton with year.
0206  * @stable ICU 4.0
0207  */
0208 #define UDAT_YEAR                       "y"
0209 /**
0210  * Constant for date skeleton with quarter.
0211  * @stable ICU 51
0212  */
0213 #define UDAT_QUARTER                    "QQQQ"
0214 /**
0215  * Constant for date skeleton with abbreviated quarter.
0216  * @stable ICU 51
0217  */
0218 #define UDAT_ABBR_QUARTER               "QQQ"
0219 /**
0220  * Constant for date skeleton with year and quarter.
0221  * @stable ICU 4.0
0222  */
0223 #define UDAT_YEAR_QUARTER               "yQQQQ"
0224 /**
0225  * Constant for date skeleton with year and abbreviated quarter.
0226  * @stable ICU 4.0
0227  */
0228 #define UDAT_YEAR_ABBR_QUARTER          "yQQQ"
0229 /**
0230  * Constant for date skeleton with month.
0231  * @stable ICU 4.0
0232  */
0233 #define UDAT_MONTH                      "MMMM"
0234 /**
0235  * Constant for date skeleton with abbreviated month.
0236  * @stable ICU 4.0
0237  */
0238 #define UDAT_ABBR_MONTH                 "MMM"
0239 /**
0240  * Constant for date skeleton with numeric month.
0241  * @stable ICU 4.0
0242  */
0243 #define UDAT_NUM_MONTH                  "M"
0244 /**
0245  * Constant for date skeleton with year and month.
0246  * @stable ICU 4.0
0247  */
0248 #define UDAT_YEAR_MONTH                 "yMMMM"
0249 /**
0250  * Constant for date skeleton with year and abbreviated month.
0251  * @stable ICU 4.0
0252  */
0253 #define UDAT_YEAR_ABBR_MONTH            "yMMM"
0254 /**
0255  * Constant for date skeleton with year and numeric month.
0256  * @stable ICU 4.0
0257  */
0258 #define UDAT_YEAR_NUM_MONTH             "yM"
0259 /**
0260  * Constant for date skeleton with day.
0261  * @stable ICU 4.0
0262  */
0263 #define UDAT_DAY                        "d"
0264 /**
0265  * Constant for date skeleton with year, month, and day.
0266  * Used in combinations date + time, date + time + zone, or time + zone.
0267  * @stable ICU 4.0
0268  */
0269 #define UDAT_YEAR_MONTH_DAY             "yMMMMd"
0270 /**
0271  * Constant for date skeleton with year, abbreviated month, and day.
0272  * Used in combinations date + time, date + time + zone, or time + zone.
0273  * @stable ICU 4.0
0274  */
0275 #define UDAT_YEAR_ABBR_MONTH_DAY        "yMMMd"
0276 /**
0277  * Constant for date skeleton with year, numeric month, and day.
0278  * Used in combinations date + time, date + time + zone, or time + zone.
0279  * @stable ICU 4.0
0280  */
0281 #define UDAT_YEAR_NUM_MONTH_DAY         "yMd"
0282 /**
0283  * Constant for date skeleton with weekday.
0284  * @stable ICU 51
0285  */
0286 #define UDAT_WEEKDAY                    "EEEE"
0287 /**
0288  * Constant for date skeleton with abbreviated weekday.
0289  * @stable ICU 51
0290  */
0291 #define UDAT_ABBR_WEEKDAY               "E"
0292 /**
0293  * Constant for date skeleton with year, month, weekday, and day.
0294  * Used in combinations date + time, date + time + zone, or time + zone.
0295  * @stable ICU 4.0
0296  */
0297 #define UDAT_YEAR_MONTH_WEEKDAY_DAY     "yMMMMEEEEd"
0298 /**
0299  * Constant for date skeleton with year, abbreviated month, weekday, and day.
0300  * Used in combinations date + time, date + time + zone, or time + zone.
0301  * @stable ICU 4.0
0302  */
0303 #define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd"
0304 /**
0305  * Constant for date skeleton with year, numeric month, weekday, and day.
0306  * Used in combinations date + time, date + time + zone, or time + zone.
0307  * @stable ICU 4.0
0308  */
0309 #define UDAT_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd"
0310 /**
0311  * Constant for date skeleton with long month and day.
0312  * Used in combinations date + time, date + time + zone, or time + zone.
0313  * @stable ICU 4.0
0314  */
0315 #define UDAT_MONTH_DAY                  "MMMMd"
0316 /**
0317  * Constant for date skeleton with abbreviated month and day.
0318  * Used in combinations date + time, date + time + zone, or time + zone.
0319  * @stable ICU 4.0
0320  */
0321 #define UDAT_ABBR_MONTH_DAY             "MMMd"
0322 /**
0323  * Constant for date skeleton with numeric month and day.
0324  * Used in combinations date + time, date + time + zone, or time + zone.
0325  * @stable ICU 4.0
0326  */
0327 #define UDAT_NUM_MONTH_DAY              "Md"
0328 /**
0329  * Constant for date skeleton with month, weekday, and day.
0330  * Used in combinations date + time, date + time + zone, or time + zone.
0331  * @stable ICU 4.0
0332  */
0333 #define UDAT_MONTH_WEEKDAY_DAY          "MMMMEEEEd"
0334 /**
0335  * Constant for date skeleton with abbreviated month, weekday, and day.
0336  * Used in combinations date + time, date + time + zone, or time + zone.
0337  * @stable ICU 4.0
0338  */
0339 #define UDAT_ABBR_MONTH_WEEKDAY_DAY     "MMMEd"
0340 /**
0341  * Constant for date skeleton with numeric month, weekday, and day.
0342  * Used in combinations date + time, date + time + zone, or time + zone.
0343  * @stable ICU 4.0
0344  */
0345 #define UDAT_NUM_MONTH_WEEKDAY_DAY      "MEd"
0346 
0347 /* Skeletons for times. */
0348 
0349 /**
0350  * Constant for date skeleton with hour, with the locale's preferred hour format (12 or 24).
0351  * @stable ICU 4.0
0352  */
0353 #define UDAT_HOUR                       "j"
0354 /**
0355  * Constant for date skeleton with hour in 24-hour presentation.
0356  * @stable ICU 51
0357  */
0358 #define UDAT_HOUR24                     "H"
0359 /**
0360  * Constant for date skeleton with minute.
0361  * @stable ICU 51
0362  */
0363 #define UDAT_MINUTE                     "m"
0364 /**
0365  * Constant for date skeleton with hour and minute, with the locale's preferred hour format (12 or 24).
0366  * Used in combinations date + time, date + time + zone, or time + zone.
0367  * @stable ICU 4.0
0368  */
0369 #define UDAT_HOUR_MINUTE                "jm"
0370 /**
0371  * Constant for date skeleton with hour and minute in 24-hour presentation.
0372  * Used in combinations date + time, date + time + zone, or time + zone.
0373  * @stable ICU 4.0
0374  */
0375 #define UDAT_HOUR24_MINUTE              "Hm"
0376 /**
0377  * Constant for date skeleton with second.
0378  * @stable ICU 51
0379  */
0380 #define UDAT_SECOND                     "s"
0381 /**
0382  * Constant for date skeleton with hour, minute, and second,
0383  * with the locale's preferred hour format (12 or 24).
0384  * Used in combinations date + time, date + time + zone, or time + zone.
0385  * @stable ICU 4.0
0386  */
0387 #define UDAT_HOUR_MINUTE_SECOND         "jms"
0388 /**
0389  * Constant for date skeleton with hour, minute, and second in
0390  * 24-hour presentation.
0391  * Used in combinations date + time, date + time + zone, or time + zone.
0392  * @stable ICU 4.0
0393  */
0394 #define UDAT_HOUR24_MINUTE_SECOND       "Hms"
0395 /**
0396  * Constant for date skeleton with minute and second.
0397  * Used in combinations date + time, date + time + zone, or time + zone.
0398  * @stable ICU 4.0
0399  */
0400 #define UDAT_MINUTE_SECOND              "ms"
0401 
0402 /* Skeletons for time zones. */
0403 
0404 /**
0405  * Constant for <i>generic location format</i>, such as Los Angeles Time;
0406  * used in combinations date + time + zone, or time + zone.
0407  * @see <a href="http://unicode.org/reports/tr35/#Date_Format_Patterns">LDML Date Format Patterns</a>
0408  * @see <a href="http://unicode.org/reports/tr35/#Time_Zone_Fallback">LDML Time Zone Fallback</a>
0409  * @stable ICU 51
0410  */
0411 #define UDAT_LOCATION_TZ "VVVV"
0412 /**
0413  * Constant for <i>generic non-location format</i>, such as Pacific Time;
0414  * used in combinations date + time + zone, or time + zone.
0415  * @see <a href="http://unicode.org/reports/tr35/#Date_Format_Patterns">LDML Date Format Patterns</a>
0416  * @see <a href="http://unicode.org/reports/tr35/#Time_Zone_Fallback">LDML Time Zone Fallback</a>
0417  * @stable ICU 51
0418  */
0419 #define UDAT_GENERIC_TZ "vvvv"
0420 /**
0421  * Constant for <i>generic non-location format</i>, abbreviated if possible, such as PT;
0422  * used in combinations date + time + zone, or time + zone.
0423  * @see <a href="http://unicode.org/reports/tr35/#Date_Format_Patterns">LDML Date Format Patterns</a>
0424  * @see <a href="http://unicode.org/reports/tr35/#Time_Zone_Fallback">LDML Time Zone Fallback</a>
0425  * @stable ICU 51
0426  */
0427 #define UDAT_ABBR_GENERIC_TZ "v"
0428 /**
0429  * Constant for <i>specific non-location format</i>, such as Pacific Daylight Time;
0430  * used in combinations date + time + zone, or time + zone.
0431  * @see <a href="http://unicode.org/reports/tr35/#Date_Format_Patterns">LDML Date Format Patterns</a>
0432  * @see <a href="http://unicode.org/reports/tr35/#Time_Zone_Fallback">LDML Time Zone Fallback</a>
0433  * @stable ICU 51
0434  */
0435 #define UDAT_SPECIFIC_TZ "zzzz"
0436 /**
0437  * Constant for <i>specific non-location format</i>, abbreviated if possible, such as PDT;
0438  * used in combinations date + time + zone, or time + zone.
0439  * @see <a href="http://unicode.org/reports/tr35/#Date_Format_Patterns">LDML Date Format Patterns</a>
0440  * @see <a href="http://unicode.org/reports/tr35/#Time_Zone_Fallback">LDML Time Zone Fallback</a>
0441  * @stable ICU 51
0442  */
0443 #define UDAT_ABBR_SPECIFIC_TZ "z"
0444 /**
0445  * Constant for <i>localized GMT/UTC format</i>, such as GMT+8:00 or HPG-8:00;
0446  * used in combinations date + time + zone, or time + zone.
0447  * @see <a href="http://unicode.org/reports/tr35/#Date_Format_Patterns">LDML Date Format Patterns</a>
0448  * @see <a href="http://unicode.org/reports/tr35/#Time_Zone_Fallback">LDML Time Zone Fallback</a>
0449  * @stable ICU 51
0450  */
0451 #define UDAT_ABBR_UTC_TZ "ZZZZ"
0452 
0453 /* deprecated skeleton constants */
0454 
0455 #ifndef U_HIDE_DEPRECATED_API
0456 /**
0457  * Constant for date skeleton with standalone month.
0458  * @deprecated ICU 50 Use UDAT_MONTH instead.
0459  */
0460 #define UDAT_STANDALONE_MONTH           "LLLL"
0461 /**
0462  * Constant for date skeleton with standalone abbreviated month.
0463  * @deprecated ICU 50 Use UDAT_ABBR_MONTH instead.
0464  */
0465 #define UDAT_ABBR_STANDALONE_MONTH      "LLL"
0466 
0467 /**
0468  * Constant for date skeleton with hour, minute, and generic timezone.
0469  * @deprecated ICU 50 Use instead UDAT_HOUR_MINUTE UDAT_ABBR_GENERIC_TZ or some other timezone presentation.
0470  */
0471 #define UDAT_HOUR_MINUTE_GENERIC_TZ     "jmv"
0472 /**
0473  * Constant for date skeleton with hour, minute, and timezone.
0474  * @deprecated ICU 50 Use instead UDAT_HOUR_MINUTE UDAT_ABBR_SPECIFIC_TZ or some other timezone presentation.
0475  */
0476 #define UDAT_HOUR_MINUTE_TZ             "jmz"
0477 /**
0478  * Constant for date skeleton with hour and generic timezone.
0479  * @deprecated ICU 50 Use instead UDAT_HOUR UDAT_ABBR_GENERIC_TZ or some other timezone presentation.
0480  */
0481 #define UDAT_HOUR_GENERIC_TZ            "jv"
0482 /**
0483  * Constant for date skeleton with hour and timezone.
0484  * @deprecated ICU 50 Use instead UDAT_HOUR UDAT_ABBR_SPECIFIC_TZ or some other timezone presentation.
0485  */
0486 #define UDAT_HOUR_TZ                    "jz"
0487 #endif  /* U_HIDE_DEPRECATED_API */
0488 
0489 #ifndef U_HIDE_INTERNAL_API
0490 /**
0491  * Constant for Unicode string name of new (in 2019) Japanese calendar era,
0492  * root/English abbreviated version (ASCII-range characters).
0493  * @internal
0494  */
0495 #define JP_ERA_2019_ROOT                "Reiwa"
0496 /**
0497  * Constant for Unicode string name of new (in 2019) Japanese calendar era,
0498  * Japanese abbreviated version (Han, or fullwidth Latin for testing).
0499  * @internal
0500  */
0501 #define JP_ERA_2019_JA                  "\\u4EE4\\u548C"
0502 /**
0503  * Constant for Unicode string name of new (in 2019) Japanese calendar era,
0504  * root and Japanese narrow version (ASCII-range characters).
0505  * @internal
0506  */
0507 #define JP_ERA_2019_NARROW              "R"
0508 #endif  // U_HIDE_INTERNAL_API
0509 
0510 /**
0511  * FieldPosition and UFieldPosition selectors for format fields
0512  * defined by DateFormat and UDateFormat.
0513  * @stable ICU 3.0
0514  */
0515 typedef enum UDateFormatField {
0516     /**
0517      * FieldPosition and UFieldPosition selector for 'G' field alignment,
0518      * corresponding to the UCAL_ERA field.
0519      * @stable ICU 3.0
0520      */
0521     UDAT_ERA_FIELD = 0,
0522 
0523     /**
0524      * FieldPosition and UFieldPosition selector for 'y' field alignment,
0525      * corresponding to the UCAL_YEAR field.
0526      * @stable ICU 3.0
0527      */
0528     UDAT_YEAR_FIELD = 1,
0529 
0530     /**
0531      * FieldPosition and UFieldPosition selector for 'M' field alignment,
0532      * corresponding to the UCAL_MONTH field.
0533      * @stable ICU 3.0
0534      */
0535     UDAT_MONTH_FIELD = 2,
0536 
0537     /**
0538      * FieldPosition and UFieldPosition selector for 'd' field alignment,
0539      * corresponding to the UCAL_DATE field.
0540      * @stable ICU 3.0
0541      */
0542     UDAT_DATE_FIELD = 3,
0543 
0544     /**
0545      * FieldPosition and UFieldPosition selector for 'k' field alignment,
0546      * corresponding to the UCAL_HOUR_OF_DAY field.
0547      * UDAT_HOUR_OF_DAY1_FIELD is used for the one-based 24-hour clock.
0548      * For example, 23:59 + 01:00 results in 24:59.
0549      * @stable ICU 3.0
0550      */
0551     UDAT_HOUR_OF_DAY1_FIELD = 4,
0552 
0553     /**
0554      * FieldPosition and UFieldPosition selector for 'H' field alignment,
0555      * corresponding to the UCAL_HOUR_OF_DAY field.
0556      * UDAT_HOUR_OF_DAY0_FIELD is used for the zero-based 24-hour clock.
0557      * For example, 23:59 + 01:00 results in 00:59.
0558      * @stable ICU 3.0
0559      */
0560     UDAT_HOUR_OF_DAY0_FIELD = 5,
0561 
0562     /**
0563      * FieldPosition and UFieldPosition selector for 'm' field alignment,
0564      * corresponding to the UCAL_MINUTE field.
0565      * @stable ICU 3.0
0566      */
0567     UDAT_MINUTE_FIELD = 6,
0568 
0569     /**
0570      * FieldPosition and UFieldPosition selector for 's' field alignment,
0571      * corresponding to the UCAL_SECOND field.
0572      * @stable ICU 3.0
0573      */
0574     UDAT_SECOND_FIELD = 7,
0575 
0576     /**
0577      * FieldPosition and UFieldPosition selector for 'S' field alignment,
0578      * corresponding to the UCAL_MILLISECOND field.
0579      *
0580      * Note: Time formats that use 'S' can display a maximum of three
0581      * significant digits for fractional seconds, corresponding to millisecond
0582      * resolution and a fractional seconds sub-pattern of SSS. If the
0583      * sub-pattern is S or SS, the fractional seconds value will be truncated
0584      * (not rounded) to the number of display places specified. If the
0585      * fractional seconds sub-pattern is longer than SSS, the additional
0586      * display places will be filled with zeros.
0587      * @stable ICU 3.0
0588      */
0589     UDAT_FRACTIONAL_SECOND_FIELD = 8,
0590 
0591     /**
0592      * FieldPosition and UFieldPosition selector for 'E' field alignment,
0593      * corresponding to the UCAL_DAY_OF_WEEK field.
0594      * @stable ICU 3.0
0595      */
0596     UDAT_DAY_OF_WEEK_FIELD = 9,
0597 
0598     /**
0599      * FieldPosition and UFieldPosition selector for 'D' field alignment,
0600      * corresponding to the UCAL_DAY_OF_YEAR field.
0601      * @stable ICU 3.0
0602      */
0603     UDAT_DAY_OF_YEAR_FIELD = 10,
0604 
0605     /**
0606      * FieldPosition and UFieldPosition selector for 'F' field alignment,
0607      * corresponding to the UCAL_DAY_OF_WEEK_IN_MONTH field.
0608      * @stable ICU 3.0
0609      */
0610     UDAT_DAY_OF_WEEK_IN_MONTH_FIELD = 11,
0611 
0612     /**
0613      * FieldPosition and UFieldPosition selector for 'w' field alignment,
0614      * corresponding to the UCAL_WEEK_OF_YEAR field.
0615      * @stable ICU 3.0
0616      */
0617     UDAT_WEEK_OF_YEAR_FIELD = 12,
0618 
0619     /**
0620      * FieldPosition and UFieldPosition selector for 'W' field alignment,
0621      * corresponding to the UCAL_WEEK_OF_MONTH field.
0622      * @stable ICU 3.0
0623      */
0624     UDAT_WEEK_OF_MONTH_FIELD = 13,
0625 
0626     /**
0627      * FieldPosition and UFieldPosition selector for 'a' field alignment,
0628      * corresponding to the UCAL_AM_PM field.
0629      * @stable ICU 3.0
0630      */
0631     UDAT_AM_PM_FIELD = 14,
0632 
0633     /**
0634      * FieldPosition and UFieldPosition selector for 'h' field alignment,
0635      * corresponding to the UCAL_HOUR field.
0636      * UDAT_HOUR1_FIELD is used for the one-based 12-hour clock.
0637      * For example, 11:30 PM + 1 hour results in 12:30 AM.
0638      * @stable ICU 3.0
0639      */
0640     UDAT_HOUR1_FIELD = 15,
0641 
0642     /**
0643      * FieldPosition and UFieldPosition selector for 'K' field alignment,
0644      * corresponding to the UCAL_HOUR field.
0645      * UDAT_HOUR0_FIELD is used for the zero-based 12-hour clock.
0646      * For example, 11:30 PM + 1 hour results in 00:30 AM.
0647      * @stable ICU 3.0
0648      */
0649     UDAT_HOUR0_FIELD = 16,
0650 
0651     /**
0652      * FieldPosition and UFieldPosition selector for 'z' field alignment,
0653      * corresponding to the UCAL_ZONE_OFFSET and
0654      * UCAL_DST_OFFSET fields.
0655      * @stable ICU 3.0
0656      */
0657     UDAT_TIMEZONE_FIELD = 17,
0658 
0659     /**
0660      * FieldPosition and UFieldPosition selector for 'Y' field alignment,
0661      * corresponding to the UCAL_YEAR_WOY field.
0662      * @stable ICU 3.0
0663      */
0664     UDAT_YEAR_WOY_FIELD = 18,
0665 
0666     /**
0667      * FieldPosition and UFieldPosition selector for 'e' field alignment,
0668      * corresponding to the UCAL_DOW_LOCAL field.
0669      * @stable ICU 3.0
0670      */
0671     UDAT_DOW_LOCAL_FIELD = 19,
0672 
0673     /**
0674      * FieldPosition and UFieldPosition selector for 'u' field alignment,
0675      * corresponding to the UCAL_EXTENDED_YEAR field.
0676      * @stable ICU 3.0
0677      */
0678     UDAT_EXTENDED_YEAR_FIELD = 20,
0679 
0680     /**
0681      * FieldPosition and UFieldPosition selector for 'g' field alignment,
0682      * corresponding to the UCAL_JULIAN_DAY field.
0683      * @stable ICU 3.0
0684      */
0685     UDAT_JULIAN_DAY_FIELD = 21,
0686 
0687     /**
0688      * FieldPosition and UFieldPosition selector for 'A' field alignment,
0689      * corresponding to the UCAL_MILLISECONDS_IN_DAY field.
0690      * @stable ICU 3.0
0691      */
0692     UDAT_MILLISECONDS_IN_DAY_FIELD = 22,
0693 
0694     /**
0695      * FieldPosition and UFieldPosition selector for 'Z' field alignment,
0696      * corresponding to the UCAL_ZONE_OFFSET and
0697      * UCAL_DST_OFFSET fields.
0698      * @stable ICU 3.0
0699      */
0700     UDAT_TIMEZONE_RFC_FIELD = 23,
0701 
0702     /**
0703      * FieldPosition and UFieldPosition selector for 'v' field alignment,
0704      * corresponding to the UCAL_ZONE_OFFSET field.
0705      * @stable ICU 3.4
0706      */
0707     UDAT_TIMEZONE_GENERIC_FIELD = 24,
0708     /**
0709      * FieldPosition selector for 'c' field alignment,
0710      * corresponding to the {@link #UCAL_DOW_LOCAL} field.
0711      * This displays the stand alone day name, if available.
0712      * @stable ICU 3.4
0713      */
0714     UDAT_STANDALONE_DAY_FIELD = 25,
0715 
0716     /**
0717      * FieldPosition selector for 'L' field alignment,
0718      * corresponding to the {@link #UCAL_MONTH} field.
0719      * This displays the stand alone month name, if available.
0720      * @stable ICU 3.4
0721      */
0722     UDAT_STANDALONE_MONTH_FIELD = 26,
0723 
0724     /**
0725      * FieldPosition selector for "Q" field alignment,
0726      * corresponding to quarters. This is implemented
0727      * using the {@link #UCAL_MONTH} field. This
0728      * displays the quarter.
0729      * @stable ICU 3.6
0730      */
0731     UDAT_QUARTER_FIELD = 27,
0732 
0733     /**
0734      * FieldPosition selector for the "q" field alignment,
0735      * corresponding to stand-alone quarters. This is
0736      * implemented using the {@link #UCAL_MONTH} field.
0737      * This displays the stand-alone quarter.
0738      * @stable ICU 3.6
0739      */
0740     UDAT_STANDALONE_QUARTER_FIELD = 28,
0741 
0742     /**
0743      * FieldPosition and UFieldPosition selector for 'V' field alignment,
0744      * corresponding to the UCAL_ZONE_OFFSET field.
0745      * @stable ICU 3.8
0746      */
0747     UDAT_TIMEZONE_SPECIAL_FIELD = 29,
0748 
0749     /**
0750      * FieldPosition selector for "U" field alignment,
0751      * corresponding to cyclic year names. This is implemented
0752      * using the {@link #UCAL_YEAR} field. This displays
0753      * the cyclic year name, if available.
0754      * @stable ICU 49
0755      */
0756     UDAT_YEAR_NAME_FIELD = 30,
0757 
0758     /**
0759      * FieldPosition selector for 'O' field alignment,
0760      * corresponding to the UCAL_ZONE_OFFSET and UCAL_DST_OFFSETfields.
0761      * This displays the localized GMT format.
0762      * @stable ICU 51
0763      */
0764     UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD = 31,
0765 
0766     /**
0767      * FieldPosition selector for 'X' field alignment,
0768      * corresponding to the UCAL_ZONE_OFFSET and UCAL_DST_OFFSETfields.
0769      * This displays the ISO 8601 local time offset format or UTC indicator ("Z").
0770      * @stable ICU 51
0771      */
0772     UDAT_TIMEZONE_ISO_FIELD = 32,
0773 
0774     /**
0775      * FieldPosition selector for 'x' field alignment,
0776      * corresponding to the UCAL_ZONE_OFFSET and UCAL_DST_OFFSET fields.
0777      * This displays the ISO 8601 local time offset format.
0778      * @stable ICU 51
0779      */
0780     UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33,
0781 
0782 #ifndef U_HIDE_INTERNAL_API
0783     /**
0784      * FieldPosition and UFieldPosition selector for 'r' field alignment,
0785      * no directly corresponding UCAL_ field.
0786      * @internal ICU 53
0787      */
0788     UDAT_RELATED_YEAR_FIELD = 34,
0789 #endif  /* U_HIDE_INTERNAL_API */
0790 
0791     /**
0792      * FieldPosition selector for 'b' field alignment.
0793      * Displays midnight and noon for 12am and 12pm, respectively, if available;
0794      * otherwise fall back to AM / PM.
0795      * @stable ICU 57
0796      */
0797     UDAT_AM_PM_MIDNIGHT_NOON_FIELD = 35,
0798 
0799     /* FieldPosition selector for 'B' field alignment.
0800      * Displays flexible day periods, such as "in the morning", if available.
0801      * @stable ICU 57
0802      */
0803     UDAT_FLEXIBLE_DAY_PERIOD_FIELD = 36,
0804 
0805 #ifndef U_HIDE_INTERNAL_API
0806     /**
0807      * FieldPosition and UFieldPosition selector for time separator,
0808      * no corresponding UCAL_ field. No pattern character is currently
0809      * defined for this.
0810      * @internal
0811      */
0812     UDAT_TIME_SEPARATOR_FIELD = 37,
0813 #endif  /* U_HIDE_INTERNAL_API */
0814 
0815 #ifndef U_HIDE_DEPRECATED_API
0816     /**
0817      * Number of FieldPosition and UFieldPosition selectors for
0818      * DateFormat and UDateFormat.
0819      * Valid selectors range from 0 to UDAT_FIELD_COUNT-1.
0820      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
0821      */
0822     UDAT_FIELD_COUNT = 38
0823 #endif  /* U_HIDE_DEPRECATED_API */
0824 } UDateFormatField;
0825 
0826 
0827 #ifndef U_HIDE_INTERNAL_API
0828 /**
0829  * Is a pattern character defined for UDAT_TIME_SEPARATOR_FIELD?
0830  * In ICU 55 it was COLON, but that was withdrawn in ICU 56.
0831  * @internal ICU 56
0832  */
0833 #define UDAT_HAS_PATTERN_CHAR_FOR_TIME_SEPARATOR 0
0834 #endif /* U_HIDE_INTERNAL_API */
0835 
0836 
0837 /**
0838  * Maps from a UDateFormatField to the corresponding UCalendarDateFields.
0839  *
0840  * Note 1: Since the mapping is many-to-one, there is no inverse mapping.
0841  *
0842  * Note 2: There is no UErrorCode parameter, so in case of error (UDateFormatField is
0843  * unknown or has no corresponding UCalendarDateFields value), the function returns the
0844  * current value of UCAL_FIELD_COUNT. However, that value may change from release to
0845  * release and is consequently deprecated. For a future-proof runtime way of checking
0846  * for errors:
0847  * a) First save the value returned by the function when it is passed an invalid value
0848  *    such as "(UDateFormatField)-1".
0849  * b) Then, to test for errors when passing some other UDateFormatField value, check
0850  *     whether the function returns that saved value.
0851  *
0852  * @param field the UDateFormatField.
0853  * @return the UCalendarDateField. In case of error (UDateFormatField is unknown or has
0854  *   no corresponding UCalendarDateFields value) this will be the current value of
0855  *   UCAL_FIELD_COUNT, but that value may change from release to release.
0856  *   See Note 2 above.
0857  * @stable ICU 4.4
0858  */
0859 U_CAPI UCalendarDateFields U_EXPORT2
0860 udat_toCalendarDateField(UDateFormatField field);
0861 
0862 
0863 /**
0864  * Open a new UDateFormat for formatting and parsing dates and times.
0865  * A UDateFormat may be used to format dates in calls to {@link #udat_format },
0866  * and to parse dates in calls to {@link #udat_parse }.
0867  * @param timeStyle The style used to format times; one of UDAT_FULL, UDAT_LONG,
0868  * UDAT_MEDIUM, UDAT_SHORT, UDAT_DEFAULT, or UDAT_NONE (relative time styles
0869  * are not currently supported).
0870  * When the pattern parameter is used, pass in UDAT_PATTERN for both timeStyle and dateStyle.
0871  * @param dateStyle The style used to format dates; one of UDAT_FULL, UDAT_LONG,
0872  * UDAT_MEDIUM, UDAT_SHORT, UDAT_DEFAULT, UDAT_FULL_RELATIVE, UDAT_LONG_RELATIVE,
0873  * UDAT_MEDIUM_RELATIVE, UDAT_SHORT_RELATIVE, or UDAT_NONE.
0874  * When the pattern parameter is used, pass in UDAT_PATTERN for both timeStyle and dateStyle.
0875  * As currently implemented,
0876  * relative date formatting only affects a limited range of calendar days before or
0877  * after the current date, based on the CLDR &lt;field type="day"&gt;/&lt;relative&gt; data: For
0878  * example, in English, "Yesterday", "Today", and "Tomorrow". Outside of this range,
0879  * dates are formatted using the corresponding non-relative style.
0880  * @param locale The locale specifying the formatting conventions
0881  * @param tzID A timezone ID specifying the timezone to use.  If 0, use
0882  * the default timezone.
0883  * @param tzIDLength The length of tzID, or -1 if null-terminated.
0884  * @param pattern A pattern specifying the format to use.
0885  * @param patternLength The number of characters in the pattern, or -1 if null-terminated.
0886  * @param status A pointer to an UErrorCode to receive any errors
0887  * @return A pointer to a UDateFormat to use for formatting dates and times, or 0 if
0888  * an error occurred.
0889  * @stable ICU 2.0
0890  */
0891 U_CAPI UDateFormat* U_EXPORT2
0892 udat_open(UDateFormatStyle  timeStyle,
0893           UDateFormatStyle  dateStyle,
0894           const char        *locale,
0895           const UChar       *tzID,
0896           int32_t           tzIDLength,
0897           const UChar       *pattern,
0898           int32_t           patternLength,
0899           UErrorCode        *status);
0900 
0901 
0902 /**
0903 * Close a UDateFormat.
0904 * Once closed, a UDateFormat may no longer be used.
0905 * @param format The formatter to close.
0906 * @stable ICU 2.0
0907 */
0908 U_CAPI void U_EXPORT2
0909 udat_close(UDateFormat* format);
0910 
0911 
0912 /**
0913  * DateFormat boolean attributes
0914  *
0915  * @stable ICU 53
0916  */
0917 typedef enum UDateFormatBooleanAttribute {
0918    /**
0919      * indicates whether whitespace is allowed. Includes trailing dot tolerance.
0920      * @stable ICU 53
0921      */
0922     UDAT_PARSE_ALLOW_WHITESPACE = 0,
0923     /**
0924      * indicates tolerance of numeric data when String data may be assumed. eg: UDAT_YEAR_NAME_FIELD,
0925      * UDAT_STANDALONE_MONTH_FIELD, UDAT_DAY_OF_WEEK_FIELD
0926      * @stable ICU 53
0927      */
0928     UDAT_PARSE_ALLOW_NUMERIC = 1,
0929     /**
0930      * indicates tolerance of a partial literal match
0931      * e.g. accepting "--mon-02-march-2011" for a pattern of "'--: 'EEE-WW-MMMM-yyyy"
0932      * @stable ICU 56
0933      */
0934     UDAT_PARSE_PARTIAL_LITERAL_MATCH = 2,
0935     /**
0936      * indicates tolerance of pattern mismatch between input data and specified format pattern.
0937      * e.g. accepting "September" for a month pattern of MMM ("Sep")
0938      * @stable ICU 56
0939      */
0940     UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH = 3,
0941 
0942     /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
0943      * it is needed for layout of DateFormat object. */
0944 #ifndef U_FORCE_HIDE_DEPRECATED_API
0945     /**
0946      * One more than the highest normal UDateFormatBooleanAttribute value.
0947      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
0948      */
0949     UDAT_BOOLEAN_ATTRIBUTE_COUNT = 4
0950 #endif  // U_FORCE_HIDE_DEPRECATED_API
0951 } UDateFormatBooleanAttribute;
0952 
0953 /**
0954  * Get a boolean attribute associated with a UDateFormat.
0955  * An example would be a true value for a key of UDAT_PARSE_ALLOW_WHITESPACE indicating allowing whitespace leniency.
0956  * If the formatter does not understand the attribute, -1 is returned.
0957  * @param fmt The formatter to query.
0958  * @param attr The attribute to query; e.g. UDAT_PARSE_ALLOW_WHITESPACE.
0959  * @param status A pointer to an UErrorCode to receive any errors
0960  * @return The value of attr.
0961  * @stable ICU 53
0962  */
0963 U_CAPI UBool U_EXPORT2
0964 udat_getBooleanAttribute(const UDateFormat* fmt, UDateFormatBooleanAttribute attr, UErrorCode* status);
0965 
0966 /**
0967  * Set a boolean attribute associated with a UDateFormat.
0968  * An example of a boolean attribute is parse leniency control.  If the formatter does not understand
0969  * the attribute, the call is ignored.
0970  * @param fmt The formatter to set.
0971  * @param attr The attribute to set; one of UDAT_PARSE_ALLOW_WHITESPACE or UDAT_PARSE_ALLOW_NUMERIC
0972  * @param newValue The new value of attr.
0973  * @param status A pointer to an UErrorCode to receive any errors
0974  * @stable ICU 53
0975  */
0976 U_CAPI void U_EXPORT2
0977 udat_setBooleanAttribute(UDateFormat *fmt, UDateFormatBooleanAttribute attr, UBool newValue, UErrorCode* status);
0978 
0979 /**
0980  * Hour Cycle.
0981  * @stable ICU 67
0982  */
0983 typedef enum UDateFormatHourCycle {
0984     /**
0985      * Hour in am/pm (0~11)
0986      * @stable ICU 67
0987      */
0988     UDAT_HOUR_CYCLE_11,
0989 
0990     /**
0991      * Hour in am/pm (1~12)
0992      * @stable ICU 67
0993      */
0994     UDAT_HOUR_CYCLE_12,
0995 
0996     /**
0997      * Hour in day (0~23)
0998      * @stable ICU 67
0999      */
1000     UDAT_HOUR_CYCLE_23,
1001 
1002     /**
1003      * Hour in day (1~24)
1004      * @stable ICU 67
1005      */
1006     UDAT_HOUR_CYCLE_24
1007 } UDateFormatHourCycle;
1008 
1009 #if U_SHOW_CPLUSPLUS_API
1010 
1011 U_NAMESPACE_BEGIN
1012 
1013 /**
1014  * \class LocalUDateFormatPointer
1015  * "Smart pointer" class, closes a UDateFormat via udat_close().
1016  * For most methods see the LocalPointerBase base class.
1017  *
1018  * @see LocalPointerBase
1019  * @see LocalPointer
1020  * @stable ICU 4.4
1021  */
1022 U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateFormatPointer, UDateFormat, udat_close);
1023 
1024 U_NAMESPACE_END
1025 
1026 #endif
1027 
1028 /**
1029  * Open a copy of a UDateFormat.
1030  * This function performs a deep copy.
1031  * @param fmt The format to copy
1032  * @param status A pointer to an UErrorCode to receive any errors.
1033  * @return A pointer to a UDateFormat identical to fmt.
1034  * @stable ICU 2.0
1035  */
1036 U_CAPI UDateFormat* U_EXPORT2
1037 udat_clone(const UDateFormat *fmt,
1038        UErrorCode *status);
1039 
1040 /**
1041 * Format a date using a UDateFormat.
1042 * The date will be formatted using the conventions specified in {@link #udat_open }
1043 * @param format The formatter to use
1044 * @param dateToFormat The date to format
1045 * @param result A pointer to a buffer to receive the formatted number.
1046 * @param resultLength The maximum size of result.
1047 * @param position A pointer to a UFieldPosition.  On input, position->field
1048 * is read.  On output, position->beginIndex and position->endIndex indicate
1049 * the beginning and ending indices of field number position->field, if such
1050 * a field exists.  This parameter may be NULL, in which case no field
1051 * position data is returned.
1052 * @param status A pointer to an UErrorCode to receive any errors
1053 * @return The total buffer size needed; if greater than resultLength, the output was truncated.
1054 * @see udat_parse
1055 * @see UFieldPosition
1056 * @stable ICU 2.0
1057 */
1058 U_CAPI int32_t U_EXPORT2
1059 udat_format(    const    UDateFormat*    format,
1060                         UDate           dateToFormat,
1061                         UChar*          result,
1062                         int32_t         resultLength,
1063                         UFieldPosition* position,
1064                         UErrorCode*     status);
1065 
1066 /**
1067 * Format a date using an UDateFormat.
1068 * The date will be formatted using the conventions specified in {@link #udat_open }
1069 * @param format The formatter to use
1070 * @param calendar The calendar to format. The calendar instance might be
1071 *                 mutated if fields are not yet fully calculated, though
1072 *                 the function won't change the logical date and time held
1073 *                 by the instance.
1074 * @param result A pointer to a buffer to receive the formatted number.
1075 * @param capacity The maximum size of result.
1076 * @param position A pointer to a UFieldPosition.  On input, position->field
1077 * is read.  On output, position->beginIndex and position->endIndex indicate
1078 * the beginning and ending indices of field number position->field, if such
1079 * a field exists.  This parameter may be NULL, in which case no field
1080 * position data is returned.
1081 * @param status A pointer to an UErrorCode to receive any errors
1082 * @return The total buffer size needed; if greater than resultLength, the output was truncated.
1083 * @see udat_format
1084 * @see udat_parseCalendar
1085 * @see UFieldPosition
1086 * @stable ICU 55
1087 */
1088 U_CAPI int32_t U_EXPORT2
1089 udat_formatCalendar(    const UDateFormat*  format,
1090                         UCalendar*      calendar,
1091                         UChar*          result,
1092                         int32_t         capacity,
1093                         UFieldPosition* position,
1094                         UErrorCode*     status);
1095 
1096 /**
1097 * Format a date using a UDateFormat.
1098 * The date will be formatted using the conventions specified in {@link #udat_open}
1099 * @param format
1100 *          The formatter to use
1101 * @param dateToFormat
1102 *          The date to format
1103 * @param result
1104 *          A pointer to a buffer to receive the formatted number.
1105 * @param resultLength
1106 *          The maximum size of result.
1107 * @param fpositer
1108 *          A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open}
1109 *          (may be NULL if field position information is not needed). Any
1110 *          iteration information already present in the UFieldPositionIterator
1111 *          will be deleted, and the iterator will be reset to apply to the
1112 *          fields in the formatted string created by this function call; the
1113 *          field values provided by {@link #ufieldpositer_next} will be from the
1114 *          UDateFormatField enum.
1115 * @param status
1116 *          A pointer to a UErrorCode to receive any errors
1117 * @return
1118 *          The total buffer size needed; if greater than resultLength, the output was truncated.
1119 * @see udat_parse
1120 * @see UFieldPositionIterator
1121 * @stable ICU 55
1122 */
1123 U_CAPI int32_t U_EXPORT2
1124 udat_formatForFields(   const UDateFormat* format,
1125                         UDate           dateToFormat,
1126                         UChar*          result,
1127                         int32_t         resultLength,
1128                         UFieldPositionIterator* fpositer,
1129                         UErrorCode*     status);
1130 
1131 /**
1132 * Format a date using a UDateFormat.
1133 * The date will be formatted using the conventions specified in {@link #udat_open }
1134 * @param format
1135 *          The formatter to use
1136 * @param calendar
1137 *          The calendar to format. The calendar instance might be mutated if fields
1138 *          are not yet fully calculated, though the function won't change the logical
1139 *          date and time held by the instance.
1140 * @param result
1141 *          A pointer to a buffer to receive the formatted number.
1142 * @param capacity
1143 *          The maximum size of result.
1144 * @param fpositer
1145 *          A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open}
1146 *          (may be NULL if field position information is not needed). Any
1147 *          iteration information already present in the UFieldPositionIterator
1148 *          will be deleted, and the iterator will be reset to apply to the
1149 *          fields in the formatted string created by this function call; the
1150 *          field values provided by {@link #ufieldpositer_next} will be from the
1151 *          UDateFormatField enum.
1152 * @param status
1153 *          A pointer to a UErrorCode to receive any errors
1154 * @return
1155 *          The total buffer size needed; if greater than resultLength, the output was truncated.
1156 * @see udat_format
1157 * @see udat_parseCalendar
1158 * @see UFieldPositionIterator
1159 * @stable ICU 55
1160 */
1161 U_CAPI int32_t U_EXPORT2
1162 udat_formatCalendarForFields( const UDateFormat* format,
1163                         UCalendar*      calendar,
1164                         UChar*          result,
1165                         int32_t         capacity,
1166                         UFieldPositionIterator* fpositer,
1167                         UErrorCode*     status);
1168 
1169 
1170 /**
1171 * Parse a string into an date/time using a UDateFormat.
1172 * The date will be parsed using the conventions specified in {@link #udat_open }.
1173 * <P>
1174 * Note that the normal date formats associated with some calendars - such
1175 * as the Chinese lunar calendar - do not specify enough fields to enable
1176 * dates to be parsed unambiguously. In the case of the Chinese lunar
1177 * calendar, while the year within the current 60-year cycle is specified,
1178 * the number of such cycles since the start date of the calendar (in the
1179 * UCAL_ERA field of the UCalendar object) is not normally part of the format,
1180 * and parsing may assume the wrong era. For cases such as this it is
1181 * recommended that clients parse using udat_parseCalendar with the UCalendar
1182 * passed in set to the current date, or to a date within the era/cycle that
1183 * should be assumed if absent in the format.
1184 *
1185 * @param format The formatter to use.
1186 * @param text The text to parse.
1187 * @param textLength The length of text, or -1 if null-terminated.
1188 * @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
1189 * to begin parsing.  If not 0, on output the offset at which parsing ended.
1190 * @param status A pointer to an UErrorCode to receive any errors
1191 * @return The value of the parsed date/time
1192 * @see udat_format
1193 * @stable ICU 2.0
1194 */
1195 U_CAPI UDate U_EXPORT2
1196 udat_parse(const    UDateFormat*    format,
1197            const    UChar*          text,
1198                     int32_t         textLength,
1199                     int32_t         *parsePos,
1200                     UErrorCode      *status);
1201 
1202 /**
1203 * Parse a string into an date/time using a UDateFormat.
1204 * The date will be parsed using the conventions specified in {@link #udat_open }.
1205 * @param format The formatter to use.
1206 * @param calendar A calendar set on input to the date and time to be used for
1207 *                 missing values in the date/time string being parsed, and set
1208 *                 on output to the parsed date/time. When the calendar type is
1209 *                 different from the internal calendar held by the UDateFormat
1210 *                 instance, the internal calendar will be cloned to a work
1211 *                 calendar set to the same milliseconds and time zone as this
1212 *                 calendar parameter, field values will be parsed based on the
1213 *                 work calendar, then the result (milliseconds and time zone)
1214 *                 will be set in this calendar.
1215 * @param text The text to parse.
1216 * @param textLength The length of text, or -1 if null-terminated.
1217 * @param parsePos If not 0, on input a pointer to an integer specifying the offset at which
1218 * to begin parsing.  If not 0, on output the offset at which parsing ended.
1219 * @param status A pointer to an UErrorCode to receive any errors
1220 * @see udat_format
1221 * @stable ICU 2.0
1222 */
1223 U_CAPI void U_EXPORT2
1224 udat_parseCalendar(const    UDateFormat*    format,
1225                             UCalendar*      calendar,
1226                    const    UChar*          text,
1227                             int32_t         textLength,
1228                             int32_t         *parsePos,
1229                             UErrorCode      *status);
1230 
1231 /**
1232 * Determine if an UDateFormat will perform lenient parsing.
1233 * With lenient parsing, the parser may use heuristics to interpret inputs that do not
1234 * precisely match the pattern. With strict parsing, inputs must match the pattern.
1235 * @param fmt The formatter to query
1236 * @return true if fmt is set to perform lenient parsing, false otherwise.
1237 * @see udat_setLenient
1238 * @stable ICU 2.0
1239 */
1240 U_CAPI UBool U_EXPORT2
1241 udat_isLenient(const UDateFormat* fmt);
1242 
1243 /**
1244 * Specify whether an UDateFormat will perform lenient parsing.
1245 * With lenient parsing, the parser may use heuristics to interpret inputs that do not
1246 * precisely match the pattern. With strict parsing, inputs must match the pattern.
1247 * @param fmt The formatter to set
1248 * @param isLenient true if fmt should perform lenient parsing, false otherwise.
1249 * @see dat_isLenient
1250 * @stable ICU 2.0
1251 */
1252 U_CAPI void U_EXPORT2
1253 udat_setLenient(    UDateFormat*    fmt,
1254                     UBool          isLenient);
1255 
1256 /**
1257 * Get the UCalendar associated with an UDateFormat.
1258 * A UDateFormat uses a UCalendar to convert a raw value to, for example,
1259 * the day of the week.
1260 * @param fmt The formatter to query.
1261 * @return A pointer to the UCalendar used by fmt.
1262 * @see udat_setCalendar
1263 * @stable ICU 2.0
1264 */
1265 U_CAPI const UCalendar* U_EXPORT2
1266 udat_getCalendar(const UDateFormat* fmt);
1267 
1268 /**
1269 * Set the UCalendar associated with an UDateFormat.
1270 * A UDateFormat uses a UCalendar to convert a raw value to, for example,
1271 * the day of the week.
1272 * @param fmt The formatter to set.
1273 * @param calendarToSet A pointer to an UCalendar to be used by fmt.
1274 * @see udat_setCalendar
1275 * @stable ICU 2.0
1276 */
1277 U_CAPI void U_EXPORT2
1278 udat_setCalendar(            UDateFormat*    fmt,
1279                     const   UCalendar*      calendarToSet);
1280 
1281 /**
1282 * Get the UNumberFormat associated with an UDateFormat.
1283 * A UDateFormat uses a UNumberFormat to format numbers within a date,
1284 * for example the day number.
1285 * @param fmt The formatter to query.
1286 * @return A pointer to the UNumberFormat used by fmt to format numbers.
1287 * @see udat_setNumberFormat
1288 * @stable ICU 2.0
1289 */
1290 U_CAPI const UNumberFormat* U_EXPORT2
1291 udat_getNumberFormat(const UDateFormat* fmt);
1292 
1293 /**
1294 * Get the UNumberFormat for specific field associated with an UDateFormat.
1295 * For example: 'y' for year and 'M' for month
1296 * @param fmt The formatter to query.
1297 * @param field the field to query
1298 * @return A pointer to the UNumberFormat used by fmt to format field numbers.
1299 * @see udat_setNumberFormatForField
1300 * @stable ICU 54
1301 */
1302 U_CAPI const UNumberFormat* U_EXPORT2
1303 udat_getNumberFormatForField(const UDateFormat* fmt, UChar field);
1304 
1305 /**
1306 * Set the UNumberFormat for specific field associated with an UDateFormat.
1307 * It can be a single field like: "y"(year) or "M"(month)
1308 * It can be several field combined together: "yM"(year and month)
1309 * Note:
1310 * 1 symbol field is enough for multiple symbol field (so "y" will override "yy", "yyy")
1311 * If the field is not numeric, then override has no effect (like "MMM" will use abbreviation, not numerical field)
1312 *
1313 * @param fields the fields to set
1314 * @param fmt The formatter to set.
1315 * @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to format numbers.
1316 * @param status error code passed around (memory allocation or invalid fields)
1317 * @see udat_getNumberFormatForField
1318 * @stable ICU 54
1319 */
1320 U_CAPI void U_EXPORT2
1321 udat_adoptNumberFormatForFields(  UDateFormat* fmt,
1322                             const UChar* fields,
1323                                   UNumberFormat*  numberFormatToSet,
1324                                   UErrorCode* status);
1325 /**
1326 * Set the UNumberFormat associated with an UDateFormat.
1327 * A UDateFormat uses a UNumberFormat to format numbers within a date,
1328 * for example the day number.
1329 * This method also clears per field NumberFormat instances previously
1330 * set by {@see udat_setNumberFormatForField}
1331 * @param fmt The formatter to set.
1332 * @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to format numbers.
1333 * @see udat_getNumberFormat
1334 * @see udat_setNumberFormatForField
1335 * @stable ICU 2.0
1336 */
1337 U_CAPI void U_EXPORT2
1338 udat_setNumberFormat(            UDateFormat*    fmt,
1339                         const   UNumberFormat*  numberFormatToSet);
1340 /**
1341 * Adopt the UNumberFormat associated with an UDateFormat.
1342 * A UDateFormat uses a UNumberFormat to format numbers within a date,
1343 * for example the day number.
1344 * @param fmt The formatter to set.
1345 * @param numberFormatToAdopt A pointer to the UNumberFormat to be used by fmt to format numbers.
1346 * @see udat_getNumberFormat
1347 * @stable ICU 54
1348 */
1349 U_CAPI void U_EXPORT2
1350 udat_adoptNumberFormat(            UDateFormat*    fmt,
1351                                    UNumberFormat*  numberFormatToAdopt);
1352 /**
1353 * Get a locale for which date/time formatting patterns are available.
1354 * A UDateFormat in a locale returned by this function will perform the correct
1355 * formatting and parsing for the locale.
1356 * @param localeIndex The index of the desired locale.
1357 * @return A locale for which date/time formatting patterns are available, or 0 if none.
1358 * @see udat_countAvailable
1359 * @stable ICU 2.0
1360 */
1361 U_CAPI const char* U_EXPORT2
1362 udat_getAvailable(int32_t localeIndex);
1363 
1364 /**
1365 * Determine how many locales have date/time  formatting patterns available.
1366 * This function is most useful as determining the loop ending condition for
1367 * calls to {@link #udat_getAvailable }.
1368 * @return The number of locales for which date/time formatting patterns are available.
1369 * @see udat_getAvailable
1370 * @stable ICU 2.0
1371 */
1372 U_CAPI int32_t U_EXPORT2
1373 udat_countAvailable(void);
1374 
1375 /**
1376 * Get the year relative to which all 2-digit years are interpreted.
1377 * For example, if the 2-digit start year is 2100, the year 99 will be
1378 * interpreted as 2199.
1379 * @param fmt The formatter to query.
1380 * @param status A pointer to an UErrorCode to receive any errors
1381 * @return The year relative to which all 2-digit years are interpreted.
1382 * @see udat_Set2DigitYearStart
1383 * @stable ICU 2.0
1384 */
1385 U_CAPI UDate U_EXPORT2
1386 udat_get2DigitYearStart(    const   UDateFormat     *fmt,
1387                                     UErrorCode      *status);
1388 
1389 /**
1390 * Set the year relative to which all 2-digit years will be interpreted.
1391 * For example, if the 2-digit start year is 2100, the year 99 will be
1392 * interpreted as 2199.
1393 * @param fmt The formatter to set.
1394 * @param d The year relative to which all 2-digit years will be interpreted.
1395 * @param status A pointer to an UErrorCode to receive any errors
1396 * @see udat_Set2DigitYearStart
1397 * @stable ICU 2.0
1398 */
1399 U_CAPI void U_EXPORT2
1400 udat_set2DigitYearStart(    UDateFormat     *fmt,
1401                             UDate           d,
1402                             UErrorCode      *status);
1403 
1404 /**
1405 * Extract the pattern from a UDateFormat.
1406 * The pattern will follow the pattern syntax rules.
1407 * @param fmt The formatter to query.
1408 * @param localized true if the pattern should be localized, false otherwise.
1409 * @param result A pointer to a buffer to receive the pattern.
1410 * @param resultLength The maximum size of result.
1411 * @param status A pointer to an UErrorCode to receive any errors
1412 * @return The total buffer size needed; if greater than resultLength, the output was truncated.
1413 * @see udat_applyPattern
1414 * @stable ICU 2.0
1415 */
1416 U_CAPI int32_t U_EXPORT2
1417 udat_toPattern(    const   UDateFormat     *fmt,
1418                         UBool          localized,
1419                         UChar           *result,
1420                         int32_t         resultLength,
1421                         UErrorCode      *status);
1422 
1423 /**
1424 * Set the pattern used by an UDateFormat.
1425 * The pattern should follow the pattern syntax rules.
1426 * @param format The formatter to set.
1427 * @param localized true if the pattern is localized, false otherwise.
1428 * @param pattern The new pattern
1429 * @param patternLength The length of pattern, or -1 if null-terminated.
1430 * @see udat_toPattern
1431 * @stable ICU 2.0
1432 */
1433 U_CAPI void U_EXPORT2
1434 udat_applyPattern(            UDateFormat     *format,
1435                             UBool          localized,
1436                     const   UChar           *pattern,
1437                             int32_t         patternLength);
1438 
1439 /**
1440  * The possible types of date format symbols
1441  * @stable ICU 2.6
1442  */
1443 typedef enum UDateFormatSymbolType {
1444     /** The era names, for example AD */
1445     UDAT_ERAS,
1446     /** The month names, for example February */
1447     UDAT_MONTHS,
1448     /** The short month names, for example Feb. */
1449     UDAT_SHORT_MONTHS,
1450     /** The CLDR-style format "wide" weekday names, for example Monday */
1451     UDAT_WEEKDAYS,
1452     /**
1453      * The CLDR-style format "abbreviated" (not "short") weekday names, for example "Mon."
1454      * For the CLDR-style format "short" weekday names, use UDAT_SHORTER_WEEKDAYS.
1455      */
1456     UDAT_SHORT_WEEKDAYS,
1457     /** The AM/PM names, for example AM */
1458     UDAT_AM_PMS,
1459     /** The localized characters */
1460     UDAT_LOCALIZED_CHARS,
1461     /** The long era names, for example Anno Domini */
1462     UDAT_ERA_NAMES,
1463     /** The narrow month names, for example F */
1464     UDAT_NARROW_MONTHS,
1465     /** The CLDR-style format "narrow" weekday names, for example "M" */
1466     UDAT_NARROW_WEEKDAYS,
1467     /** Standalone context versions of months */
1468     UDAT_STANDALONE_MONTHS,
1469     UDAT_STANDALONE_SHORT_MONTHS,
1470     UDAT_STANDALONE_NARROW_MONTHS,
1471     /** The CLDR-style stand-alone "wide" weekday names */
1472     UDAT_STANDALONE_WEEKDAYS,
1473     /**
1474      * The CLDR-style stand-alone "abbreviated" (not "short") weekday names.
1475      * For the CLDR-style stand-alone "short" weekday names, use UDAT_STANDALONE_SHORTER_WEEKDAYS.
1476      */
1477     UDAT_STANDALONE_SHORT_WEEKDAYS,
1478     /** The CLDR-style stand-alone "narrow" weekday names */
1479     UDAT_STANDALONE_NARROW_WEEKDAYS,
1480     /** The quarters, for example 1st Quarter */
1481     UDAT_QUARTERS,
1482     /** The short quarter names, for example Q1 */
1483     UDAT_SHORT_QUARTERS,
1484     /** Standalone context versions of quarters */
1485     UDAT_STANDALONE_QUARTERS,
1486     UDAT_STANDALONE_SHORT_QUARTERS,
1487     /**
1488      * The CLDR-style short weekday names, e.g. "Su", Mo", etc.
1489      * These are named "SHORTER" to contrast with the constants using _SHORT_
1490      * above, which actually get the CLDR-style *abbreviated* versions of the
1491      * corresponding names.
1492      * @stable ICU 51
1493      */
1494     UDAT_SHORTER_WEEKDAYS,
1495     /**
1496      * Standalone version of UDAT_SHORTER_WEEKDAYS.
1497      * @stable ICU 51
1498      */
1499     UDAT_STANDALONE_SHORTER_WEEKDAYS,
1500     /**
1501      * Cyclic year names (only supported for some calendars, and only for FORMAT usage;
1502      * udat_setSymbols not supported for UDAT_CYCLIC_YEARS_WIDE)
1503      * @stable ICU 54
1504      */
1505     UDAT_CYCLIC_YEARS_WIDE,
1506     /**
1507      * Cyclic year names (only supported for some calendars, and only for FORMAT usage)
1508      * @stable ICU 54
1509      */
1510     UDAT_CYCLIC_YEARS_ABBREVIATED,
1511     /**
1512      * Cyclic year names (only supported for some calendars, and only for FORMAT usage;
1513      * udat_setSymbols not supported for UDAT_CYCLIC_YEARS_NARROW)
1514      * @stable ICU 54
1515      */
1516     UDAT_CYCLIC_YEARS_NARROW,
1517     /**
1518      * Calendar zodiac  names (only supported for some calendars, and only for FORMAT usage;
1519      * udat_setSymbols not supported for UDAT_ZODIAC_NAMES_WIDE)
1520      * @stable ICU 54
1521      */
1522     UDAT_ZODIAC_NAMES_WIDE,
1523     /**
1524      * Calendar zodiac  names (only supported for some calendars, and only for FORMAT usage)
1525      * @stable ICU 54
1526      */
1527     UDAT_ZODIAC_NAMES_ABBREVIATED,
1528     /**
1529      * Calendar zodiac  names (only supported for some calendars, and only for FORMAT usage;
1530      * udat_setSymbols not supported for UDAT_ZODIAC_NAMES_NARROW)
1531      * @stable ICU 54
1532      */
1533     UDAT_ZODIAC_NAMES_NARROW,
1534     
1535     /**
1536      * The narrow quarter names, for example 1
1537      * @stable ICU 70
1538      */
1539     UDAT_NARROW_QUARTERS,
1540     
1541     /**
1542      * The narrow standalone quarter names, for example 1
1543      * @stable ICU 70
1544      */
1545     UDAT_STANDALONE_NARROW_QUARTERS
1546 } UDateFormatSymbolType;
1547 
1548 struct UDateFormatSymbols;
1549 /** Date format symbols.
1550  *  For usage in C programs.
1551  *  @stable ICU 2.6
1552  */
1553 typedef struct UDateFormatSymbols UDateFormatSymbols;
1554 
1555 /**
1556 * Get the symbols associated with an UDateFormat.
1557 * The symbols are what a UDateFormat uses to represent locale-specific data,
1558 * for example month or day names.
1559 * @param fmt The formatter to query.
1560 * @param type The type of symbols to get.  One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS,
1561 * UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS
1562 * @param symbolIndex The desired symbol of type type.
1563 * @param result A pointer to a buffer to receive the pattern.
1564 * @param resultLength The maximum size of result.
1565 * @param status A pointer to an UErrorCode to receive any errors
1566 * @return The total buffer size needed; if greater than resultLength, the output was truncated.
1567 * @see udat_countSymbols
1568 * @see udat_setSymbols
1569 * @stable ICU 2.0
1570 */
1571 U_CAPI int32_t U_EXPORT2
1572 udat_getSymbols(const   UDateFormat             *fmt,
1573                         UDateFormatSymbolType   type,
1574                         int32_t                 symbolIndex,
1575                         UChar                   *result,
1576                         int32_t                 resultLength,
1577                         UErrorCode              *status);
1578 
1579 /**
1580 * Count the number of particular symbols for an UDateFormat.
1581 * This function is most useful as for determining the loop termination condition
1582 * for calls to {@link #udat_getSymbols }.
1583 * @param fmt The formatter to query.
1584 * @param type The type of symbols to count.  One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS,
1585 * UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS
1586 * @return The number of symbols of type type.
1587 * @see udat_getSymbols
1588 * @see udat_setSymbols
1589 * @stable ICU 2.0
1590 */
1591 U_CAPI int32_t U_EXPORT2
1592 udat_countSymbols(    const    UDateFormat                *fmt,
1593                             UDateFormatSymbolType    type);
1594 
1595 /**
1596 * Set the symbols associated with an UDateFormat.
1597 * The symbols are what a UDateFormat uses to represent locale-specific data,
1598 * for example month or day names.
1599 * @param format The formatter to set
1600 * @param type The type of symbols to set.  One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS,
1601 * UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS
1602 * @param symbolIndex The index of the symbol to set of type type.
1603 * @param value The new value
1604 * @param valueLength The length of value, or -1 if null-terminated
1605 * @param status A pointer to an UErrorCode to receive any errors
1606 * @see udat_getSymbols
1607 * @see udat_countSymbols
1608 * @stable ICU 2.0
1609 */
1610 U_CAPI void U_EXPORT2
1611 udat_setSymbols(    UDateFormat             *format,
1612                     UDateFormatSymbolType   type,
1613                     int32_t                 symbolIndex,
1614                     UChar                   *value,
1615                     int32_t                 valueLength,
1616                     UErrorCode              *status);
1617 
1618 /**
1619  * Get the locale for this date format object.
1620  * You can choose between valid and actual locale.
1621  * @param fmt The formatter to get the locale from
1622  * @param type type of the locale we're looking for (valid or actual)
1623  * @param status error code for the operation
1624  * @return the locale name
1625  * @stable ICU 2.8
1626  */
1627 U_CAPI const char* U_EXPORT2
1628 udat_getLocaleByType(const UDateFormat *fmt,
1629                      ULocDataLocaleType type,
1630                      UErrorCode* status);
1631 
1632 /**
1633  * Set a particular UDisplayContext value in the formatter, such as
1634  * UDISPCTX_CAPITALIZATION_FOR_STANDALONE.
1635  * @param fmt The formatter for which to set a UDisplayContext value.
1636  * @param value The UDisplayContext value to set.
1637  * @param status A pointer to an UErrorCode to receive any errors
1638  * @stable ICU 51
1639  */
1640 U_CAPI void U_EXPORT2
1641 udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status);
1642 
1643 /**
1644  * Get the formatter's UDisplayContext value for the specified UDisplayContextType,
1645  * such as UDISPCTX_TYPE_CAPITALIZATION.
1646  * @param fmt The formatter to query.
1647  * @param type The UDisplayContextType whose value to return
1648  * @param status A pointer to an UErrorCode to receive any errors
1649  * @return The UDisplayContextValue for the specified type.
1650  * @stable ICU 53
1651  */
1652 U_CAPI UDisplayContext U_EXPORT2
1653 udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* status);
1654 
1655 #ifndef U_HIDE_INTERNAL_API
1656 /**
1657 * Extract the date pattern from a UDateFormat set for relative date formatting.
1658 * The pattern will follow the pattern syntax rules.
1659 * @param fmt The formatter to query.
1660 * @param result A pointer to a buffer to receive the pattern.
1661 * @param resultLength The maximum size of result.
1662 * @param status A pointer to a UErrorCode to receive any errors
1663 * @return The total buffer size needed; if greater than resultLength, the output was truncated.
1664 * @see udat_applyPatternRelative
1665 * @internal ICU 4.2 technology preview
1666 */
1667 U_CAPI int32_t U_EXPORT2
1668 udat_toPatternRelativeDate(const UDateFormat *fmt,
1669                            UChar             *result,
1670                            int32_t           resultLength,
1671                            UErrorCode        *status);
1672 
1673 /**
1674 * Extract the time pattern from a UDateFormat set for relative date formatting.
1675 * The pattern will follow the pattern syntax rules.
1676 * @param fmt The formatter to query.
1677 * @param result A pointer to a buffer to receive the pattern.
1678 * @param resultLength The maximum size of result.
1679 * @param status A pointer to a UErrorCode to receive any errors
1680 * @return The total buffer size needed; if greater than resultLength, the output was truncated.
1681 * @see udat_applyPatternRelative
1682 * @internal ICU 4.2 technology preview
1683 */
1684 U_CAPI int32_t U_EXPORT2
1685 udat_toPatternRelativeTime(const UDateFormat *fmt,
1686                            UChar             *result,
1687                            int32_t           resultLength,
1688                            UErrorCode        *status);
1689 
1690 /**
1691 * Set the date & time patterns used by a UDateFormat set for relative date formatting.
1692 * The patterns should follow the pattern syntax rules.
1693 * @param format The formatter to set.
1694 * @param datePattern The new date pattern
1695 * @param datePatternLength The length of datePattern, or -1 if null-terminated.
1696 * @param timePattern The new time pattern
1697 * @param timePatternLength The length of timePattern, or -1 if null-terminated.
1698 * @param status A pointer to a UErrorCode to receive any errors
1699 * @see udat_toPatternRelativeDate, udat_toPatternRelativeTime
1700 * @internal ICU 4.2 technology preview
1701 */
1702 U_CAPI void U_EXPORT2
1703 udat_applyPatternRelative(UDateFormat *format,
1704                           const UChar *datePattern,
1705                           int32_t     datePatternLength,
1706                           const UChar *timePattern,
1707                           int32_t     timePatternLength,
1708                           UErrorCode  *status);
1709 
1710 /**
1711  * @internal
1712  * @see udat_open
1713  */
1714 typedef UDateFormat* (U_EXPORT2 *UDateFormatOpener) (UDateFormatStyle  timeStyle,
1715                                                     UDateFormatStyle  dateStyle,
1716                                                     const char        *locale,
1717                                                     const UChar       *tzID,
1718                                                     int32_t           tzIDLength,
1719                                                     const UChar       *pattern,
1720                                                     int32_t           patternLength,
1721                                                     UErrorCode        *status);
1722 
1723 /**
1724  * Register a provider factory
1725  * @internal ICU 49
1726  */
1727 U_CAPI void U_EXPORT2
1728 udat_registerOpener(UDateFormatOpener opener, UErrorCode *status);
1729 
1730 /**
1731  * Un-Register a provider factory
1732  * @internal ICU 49
1733  */
1734 U_CAPI UDateFormatOpener U_EXPORT2
1735 udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status);
1736 #endif  /* U_HIDE_INTERNAL_API */
1737 
1738 
1739 #endif /* #if !UCONFIG_NO_FORMATTING */
1740 
1741 #endif