jpayne@69: // © 2016 and later: Unicode, Inc. and others. jpayne@69: // License & terms of use: http://www.unicode.org/copyright.html jpayne@69: /* jpayne@69: ******************************************************************************* jpayne@69: * Copyright (C) 1996-2016, International Business Machines jpayne@69: * Corporation and others. All Rights Reserved. jpayne@69: ******************************************************************************* jpayne@69: */ jpayne@69: jpayne@69: #ifndef UDAT_H jpayne@69: #define UDAT_H jpayne@69: jpayne@69: #include "unicode/utypes.h" jpayne@69: jpayne@69: #if !UCONFIG_NO_FORMATTING jpayne@69: jpayne@69: #include "unicode/localpointer.h" jpayne@69: #include "unicode/ucal.h" jpayne@69: #include "unicode/unum.h" jpayne@69: #include "unicode/udisplaycontext.h" jpayne@69: #include "unicode/ufieldpositer.h" jpayne@69: /** jpayne@69: * \file jpayne@69: * \brief C API: DateFormat jpayne@69: * jpayne@69: *

Date Format C API

jpayne@69: * jpayne@69: * Date Format C API consists of functions that convert dates and jpayne@69: * times from their internal representations to textual form and back again in a jpayne@69: * language-independent manner. Converting from the internal representation (milliseconds jpayne@69: * since midnight, January 1, 1970) to text is known as "formatting," and converting jpayne@69: * from text to millis is known as "parsing." We currently define only one concrete jpayne@69: * structure UDateFormat, which can handle pretty much all normal jpayne@69: * date formatting and parsing actions. jpayne@69: *

jpayne@69: * Date Format helps you to format and parse dates for any locale. Your code can jpayne@69: * be completely independent of the locale conventions for months, days of the jpayne@69: * week, or even the calendar format: lunar vs. solar. jpayne@69: *

jpayne@69: * To format a date for the current Locale with default time and date style, jpayne@69: * use one of the static factory methods: jpayne@69: *

jpayne@69:  * \code
jpayne@69:  *  UErrorCode status = U_ZERO_ERROR;
jpayne@69:  *  UChar *myString;
jpayne@69:  *  int32_t myStrlen = 0;
jpayne@69:  *  UDateFormat* dfmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, -1, &status);
jpayne@69:  *  myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, NULL, &status);
jpayne@69:  *  if (status==U_BUFFER_OVERFLOW_ERROR){
jpayne@69:  *      status=U_ZERO_ERROR;
jpayne@69:  *      myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
jpayne@69:  *      udat_format(dfmt, myDate, myString, myStrlen+1, NULL, &status);
jpayne@69:  *  }
jpayne@69:  * \endcode
jpayne@69:  * 
jpayne@69: * If you are formatting multiple numbers, it is more efficient to get the jpayne@69: * format and use it multiple times so that the system doesn't have to fetch the jpayne@69: * information about the local language and country conventions multiple times. jpayne@69: *
jpayne@69:  * \code
jpayne@69:  *  UErrorCode status = U_ZERO_ERROR;
jpayne@69:  *  int32_t i, myStrlen = 0;
jpayne@69:  *  UChar* myString;
jpayne@69:  *  char buffer[1024];
jpayne@69:  *  UDate myDateArr[] = { 0.0, 100000000.0, 2000000000.0 }; // test values
jpayne@69:  *  UDateFormat* df = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, NULL, -1, NULL, 0, &status);
jpayne@69:  *  for (i = 0; i < 3; i++) {
jpayne@69:  *      myStrlen = udat_format(df, myDateArr[i], NULL, myStrlen, NULL, &status);
jpayne@69:  *      if(status == U_BUFFER_OVERFLOW_ERROR){
jpayne@69:  *          status = U_ZERO_ERROR;
jpayne@69:  *          myString = (UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
jpayne@69:  *          udat_format(df, myDateArr[i], myString, myStrlen+1, NULL, &status);
jpayne@69:  *          printf("%s\n", u_austrcpy(buffer, myString) );
jpayne@69:  *          free(myString);
jpayne@69:  *      }
jpayne@69:  *  }
jpayne@69:  * \endcode
jpayne@69:  * 
jpayne@69: * To get specific fields of a date, you can use UFieldPosition to jpayne@69: * get specific fields. jpayne@69: *
jpayne@69:  * \code
jpayne@69:  *  UErrorCode status = U_ZERO_ERROR;
jpayne@69:  *  UFieldPosition pos;
jpayne@69:  *  UChar *myString;
jpayne@69:  *  int32_t myStrlen = 0;
jpayne@69:  *  char buffer[1024];
jpayne@69:  *
jpayne@69:  *  pos.field = 1;  // Same as the DateFormat::EField enum
jpayne@69:  *  UDateFormat* dfmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, NULL, -1, NULL, 0, &status);
jpayne@69:  *  myStrlen = udat_format(dfmt, myDate, NULL, myStrlen, &pos, &status);
jpayne@69:  *  if (status==U_BUFFER_OVERFLOW_ERROR){
jpayne@69:  *      status=U_ZERO_ERROR;
jpayne@69:  *      myString=(UChar*)malloc(sizeof(UChar) * (myStrlen+1) );
jpayne@69:  *      udat_format(dfmt, myDate, myString, myStrlen+1, &pos, &status);
jpayne@69:  *  }
jpayne@69:  *  printf("date format: %s\n", u_austrcpy(buffer, myString));
jpayne@69:  *  buffer[pos.endIndex] = 0;   // NULL terminate the string.
jpayne@69:  *  printf("UFieldPosition position equals %s\n", &buffer[pos.beginIndex]);
jpayne@69:  * \endcode
jpayne@69:  * 
jpayne@69: * To format a date for a different Locale, specify it in the call to jpayne@69: * udat_open() jpayne@69: *
jpayne@69:  * \code
jpayne@69:  *        UDateFormat* df = udat_open(UDAT_SHORT, UDAT_SHORT, "fr_FR", NULL, -1, NULL, 0, &status);
jpayne@69:  * \endcode
jpayne@69:  * 
jpayne@69: * You can use a DateFormat API udat_parse() to parse. jpayne@69: *
jpayne@69:  * \code
jpayne@69:  *  UErrorCode status = U_ZERO_ERROR;
jpayne@69:  *  int32_t parsepos=0;
jpayne@69:  *  UDate myDate = udat_parse(df, myString, u_strlen(myString), &parsepos, &status);
jpayne@69:  * \endcode
jpayne@69:  * 
jpayne@69: * You can pass in different options for the arguments for date and time style jpayne@69: * to control the length of the result; from SHORT to MEDIUM to LONG to FULL. jpayne@69: * The exact result depends on the locale, but generally: jpayne@69: * see UDateFormatStyle for more details jpayne@69: * jpayne@69: * You can also set the time zone on the format if you wish. jpayne@69: *

jpayne@69: * You can also use forms of the parse and format methods with Parse Position and jpayne@69: * UFieldPosition to allow you to jpayne@69: *

jpayne@69: *

Date and Time Patterns:

jpayne@69: * jpayne@69: *

Date and time formats are specified by date and time pattern strings. jpayne@69: * Within date and time pattern strings, all unquoted ASCII letters [A-Za-z] are reserved jpayne@69: * as pattern letters representing calendar fields. UDateFormat supports jpayne@69: * the date and time formatting algorithm and pattern letters defined by jpayne@69: * UTS#35 jpayne@69: * Unicode Locale Data Markup Language (LDML) and further documented for ICU in the jpayne@69: * ICU jpayne@69: * User Guide.

jpayne@69: */ jpayne@69: jpayne@69: /** A date formatter. jpayne@69: * For usage in C programs. jpayne@69: * @stable ICU 2.6 jpayne@69: */ jpayne@69: typedef void* UDateFormat; jpayne@69: jpayne@69: /** The possible date/time format styles jpayne@69: * @stable ICU 2.6 jpayne@69: */ jpayne@69: typedef enum UDateFormatStyle { jpayne@69: /** Full style */ jpayne@69: UDAT_FULL, jpayne@69: /** Long style */ jpayne@69: UDAT_LONG, jpayne@69: /** Medium style */ jpayne@69: UDAT_MEDIUM, jpayne@69: /** Short style */ jpayne@69: UDAT_SHORT, jpayne@69: /** Default style */ jpayne@69: UDAT_DEFAULT = UDAT_MEDIUM, jpayne@69: jpayne@69: /** Bitfield for relative date */ jpayne@69: UDAT_RELATIVE = (1 << 7), jpayne@69: jpayne@69: UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE, jpayne@69: jpayne@69: UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE, jpayne@69: jpayne@69: UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE, jpayne@69: jpayne@69: UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE, jpayne@69: jpayne@69: jpayne@69: /** No style */ jpayne@69: UDAT_NONE = -1, jpayne@69: jpayne@69: /** jpayne@69: * Use the pattern given in the parameter to udat_open jpayne@69: * @see udat_open jpayne@69: * @stable ICU 50 jpayne@69: */ jpayne@69: UDAT_PATTERN = -2, jpayne@69: jpayne@69: #ifndef U_HIDE_INTERNAL_API jpayne@69: /** @internal alias to UDAT_PATTERN */ jpayne@69: UDAT_IGNORE = UDAT_PATTERN jpayne@69: #endif /* U_HIDE_INTERNAL_API */ jpayne@69: } UDateFormatStyle; jpayne@69: jpayne@69: /* Skeletons for dates. */ jpayne@69: jpayne@69: /** jpayne@69: * Constant for date skeleton with year. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_YEAR "y" jpayne@69: /** jpayne@69: * Constant for date skeleton with quarter. jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_QUARTER "QQQQ" jpayne@69: /** jpayne@69: * Constant for date skeleton with abbreviated quarter. jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_ABBR_QUARTER "QQQ" jpayne@69: /** jpayne@69: * Constant for date skeleton with year and quarter. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_YEAR_QUARTER "yQQQQ" jpayne@69: /** jpayne@69: * Constant for date skeleton with year and abbreviated quarter. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_YEAR_ABBR_QUARTER "yQQQ" jpayne@69: /** jpayne@69: * Constant for date skeleton with month. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_MONTH "MMMM" jpayne@69: /** jpayne@69: * Constant for date skeleton with abbreviated month. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_ABBR_MONTH "MMM" jpayne@69: /** jpayne@69: * Constant for date skeleton with numeric month. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_NUM_MONTH "M" jpayne@69: /** jpayne@69: * Constant for date skeleton with year and month. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_YEAR_MONTH "yMMMM" jpayne@69: /** jpayne@69: * Constant for date skeleton with year and abbreviated month. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_YEAR_ABBR_MONTH "yMMM" jpayne@69: /** jpayne@69: * Constant for date skeleton with year and numeric month. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_YEAR_NUM_MONTH "yM" jpayne@69: /** jpayne@69: * Constant for date skeleton with day. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_DAY "d" jpayne@69: /** jpayne@69: * Constant for date skeleton with year, month, and day. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_YEAR_MONTH_DAY "yMMMMd" jpayne@69: /** jpayne@69: * Constant for date skeleton with year, abbreviated month, and day. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_YEAR_ABBR_MONTH_DAY "yMMMd" jpayne@69: /** jpayne@69: * Constant for date skeleton with year, numeric month, and day. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_YEAR_NUM_MONTH_DAY "yMd" jpayne@69: /** jpayne@69: * Constant for date skeleton with weekday. jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_WEEKDAY "EEEE" jpayne@69: /** jpayne@69: * Constant for date skeleton with abbreviated weekday. jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_ABBR_WEEKDAY "E" jpayne@69: /** jpayne@69: * Constant for date skeleton with year, month, weekday, and day. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_YEAR_MONTH_WEEKDAY_DAY "yMMMMEEEEd" jpayne@69: /** jpayne@69: * Constant for date skeleton with year, abbreviated month, weekday, and day. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd" jpayne@69: /** jpayne@69: * Constant for date skeleton with year, numeric month, weekday, and day. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_YEAR_NUM_MONTH_WEEKDAY_DAY "yMEd" jpayne@69: /** jpayne@69: * Constant for date skeleton with long month and day. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_MONTH_DAY "MMMMd" jpayne@69: /** jpayne@69: * Constant for date skeleton with abbreviated month and day. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_ABBR_MONTH_DAY "MMMd" jpayne@69: /** jpayne@69: * Constant for date skeleton with numeric month and day. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_NUM_MONTH_DAY "Md" jpayne@69: /** jpayne@69: * Constant for date skeleton with month, weekday, and day. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_MONTH_WEEKDAY_DAY "MMMMEEEEd" jpayne@69: /** jpayne@69: * Constant for date skeleton with abbreviated month, weekday, and day. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_ABBR_MONTH_WEEKDAY_DAY "MMMEd" jpayne@69: /** jpayne@69: * Constant for date skeleton with numeric month, weekday, and day. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_NUM_MONTH_WEEKDAY_DAY "MEd" jpayne@69: jpayne@69: /* Skeletons for times. */ jpayne@69: jpayne@69: /** jpayne@69: * Constant for date skeleton with hour, with the locale's preferred hour format (12 or 24). jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_HOUR "j" jpayne@69: /** jpayne@69: * Constant for date skeleton with hour in 24-hour presentation. jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_HOUR24 "H" jpayne@69: /** jpayne@69: * Constant for date skeleton with minute. jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_MINUTE "m" jpayne@69: /** jpayne@69: * Constant for date skeleton with hour and minute, with the locale's preferred hour format (12 or 24). jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_HOUR_MINUTE "jm" jpayne@69: /** jpayne@69: * Constant for date skeleton with hour and minute in 24-hour presentation. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_HOUR24_MINUTE "Hm" jpayne@69: /** jpayne@69: * Constant for date skeleton with second. jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_SECOND "s" jpayne@69: /** jpayne@69: * Constant for date skeleton with hour, minute, and second, jpayne@69: * with the locale's preferred hour format (12 or 24). jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_HOUR_MINUTE_SECOND "jms" jpayne@69: /** jpayne@69: * Constant for date skeleton with hour, minute, and second in jpayne@69: * 24-hour presentation. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_HOUR24_MINUTE_SECOND "Hms" jpayne@69: /** jpayne@69: * Constant for date skeleton with minute and second. jpayne@69: * Used in combinations date + time, date + time + zone, or time + zone. jpayne@69: * @stable ICU 4.0 jpayne@69: */ jpayne@69: #define UDAT_MINUTE_SECOND "ms" jpayne@69: jpayne@69: /* Skeletons for time zones. */ jpayne@69: jpayne@69: /** jpayne@69: * Constant for generic location format, such as Los Angeles Time; jpayne@69: * used in combinations date + time + zone, or time + zone. jpayne@69: * @see LDML Date Format Patterns jpayne@69: * @see LDML Time Zone Fallback jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_LOCATION_TZ "VVVV" jpayne@69: /** jpayne@69: * Constant for generic non-location format, such as Pacific Time; jpayne@69: * used in combinations date + time + zone, or time + zone. jpayne@69: * @see LDML Date Format Patterns jpayne@69: * @see LDML Time Zone Fallback jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_GENERIC_TZ "vvvv" jpayne@69: /** jpayne@69: * Constant for generic non-location format, abbreviated if possible, such as PT; jpayne@69: * used in combinations date + time + zone, or time + zone. jpayne@69: * @see LDML Date Format Patterns jpayne@69: * @see LDML Time Zone Fallback jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_ABBR_GENERIC_TZ "v" jpayne@69: /** jpayne@69: * Constant for specific non-location format, such as Pacific Daylight Time; jpayne@69: * used in combinations date + time + zone, or time + zone. jpayne@69: * @see LDML Date Format Patterns jpayne@69: * @see LDML Time Zone Fallback jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_SPECIFIC_TZ "zzzz" jpayne@69: /** jpayne@69: * Constant for specific non-location format, abbreviated if possible, such as PDT; jpayne@69: * used in combinations date + time + zone, or time + zone. jpayne@69: * @see LDML Date Format Patterns jpayne@69: * @see LDML Time Zone Fallback jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_ABBR_SPECIFIC_TZ "z" jpayne@69: /** jpayne@69: * Constant for localized GMT/UTC format, such as GMT+8:00 or HPG-8:00; jpayne@69: * used in combinations date + time + zone, or time + zone. jpayne@69: * @see LDML Date Format Patterns jpayne@69: * @see LDML Time Zone Fallback jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: #define UDAT_ABBR_UTC_TZ "ZZZZ" jpayne@69: jpayne@69: /* deprecated skeleton constants */ jpayne@69: jpayne@69: #ifndef U_HIDE_DEPRECATED_API jpayne@69: /** jpayne@69: * Constant for date skeleton with standalone month. jpayne@69: * @deprecated ICU 50 Use UDAT_MONTH instead. jpayne@69: */ jpayne@69: #define UDAT_STANDALONE_MONTH "LLLL" jpayne@69: /** jpayne@69: * Constant for date skeleton with standalone abbreviated month. jpayne@69: * @deprecated ICU 50 Use UDAT_ABBR_MONTH instead. jpayne@69: */ jpayne@69: #define UDAT_ABBR_STANDALONE_MONTH "LLL" jpayne@69: jpayne@69: /** jpayne@69: * Constant for date skeleton with hour, minute, and generic timezone. jpayne@69: * @deprecated ICU 50 Use instead UDAT_HOUR_MINUTE UDAT_ABBR_GENERIC_TZ or some other timezone presentation. jpayne@69: */ jpayne@69: #define UDAT_HOUR_MINUTE_GENERIC_TZ "jmv" jpayne@69: /** jpayne@69: * Constant for date skeleton with hour, minute, and timezone. jpayne@69: * @deprecated ICU 50 Use instead UDAT_HOUR_MINUTE UDAT_ABBR_SPECIFIC_TZ or some other timezone presentation. jpayne@69: */ jpayne@69: #define UDAT_HOUR_MINUTE_TZ "jmz" jpayne@69: /** jpayne@69: * Constant for date skeleton with hour and generic timezone. jpayne@69: * @deprecated ICU 50 Use instead UDAT_HOUR UDAT_ABBR_GENERIC_TZ or some other timezone presentation. jpayne@69: */ jpayne@69: #define UDAT_HOUR_GENERIC_TZ "jv" jpayne@69: /** jpayne@69: * Constant for date skeleton with hour and timezone. jpayne@69: * @deprecated ICU 50 Use instead UDAT_HOUR UDAT_ABBR_SPECIFIC_TZ or some other timezone presentation. jpayne@69: */ jpayne@69: #define UDAT_HOUR_TZ "jz" jpayne@69: #endif /* U_HIDE_DEPRECATED_API */ jpayne@69: jpayne@69: #ifndef U_HIDE_INTERNAL_API jpayne@69: /** jpayne@69: * Constant for Unicode string name of new (in 2019) Japanese calendar era, jpayne@69: * root/English abbreviated version (ASCII-range characters). jpayne@69: * @internal jpayne@69: */ jpayne@69: #define JP_ERA_2019_ROOT "Reiwa" jpayne@69: /** jpayne@69: * Constant for Unicode string name of new (in 2019) Japanese calendar era, jpayne@69: * Japanese abbreviated version (Han, or fullwidth Latin for testing). jpayne@69: * @internal jpayne@69: */ jpayne@69: #define JP_ERA_2019_JA "\\u4EE4\\u548C" jpayne@69: /** jpayne@69: * Constant for Unicode string name of new (in 2019) Japanese calendar era, jpayne@69: * root and Japanese narrow version (ASCII-range characters). jpayne@69: * @internal jpayne@69: */ jpayne@69: #define JP_ERA_2019_NARROW "R" jpayne@69: #endif // U_HIDE_INTERNAL_API jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selectors for format fields jpayne@69: * defined by DateFormat and UDateFormat. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: typedef enum UDateFormatField { jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'G' field alignment, jpayne@69: * corresponding to the UCAL_ERA field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_ERA_FIELD = 0, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'y' field alignment, jpayne@69: * corresponding to the UCAL_YEAR field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_YEAR_FIELD = 1, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'M' field alignment, jpayne@69: * corresponding to the UCAL_MONTH field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_MONTH_FIELD = 2, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'd' field alignment, jpayne@69: * corresponding to the UCAL_DATE field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_DATE_FIELD = 3, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'k' field alignment, jpayne@69: * corresponding to the UCAL_HOUR_OF_DAY field. jpayne@69: * UDAT_HOUR_OF_DAY1_FIELD is used for the one-based 24-hour clock. jpayne@69: * For example, 23:59 + 01:00 results in 24:59. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_HOUR_OF_DAY1_FIELD = 4, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'H' field alignment, jpayne@69: * corresponding to the UCAL_HOUR_OF_DAY field. jpayne@69: * UDAT_HOUR_OF_DAY0_FIELD is used for the zero-based 24-hour clock. jpayne@69: * For example, 23:59 + 01:00 results in 00:59. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_HOUR_OF_DAY0_FIELD = 5, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'm' field alignment, jpayne@69: * corresponding to the UCAL_MINUTE field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_MINUTE_FIELD = 6, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 's' field alignment, jpayne@69: * corresponding to the UCAL_SECOND field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_SECOND_FIELD = 7, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'S' field alignment, jpayne@69: * corresponding to the UCAL_MILLISECOND field. jpayne@69: * jpayne@69: * Note: Time formats that use 'S' can display a maximum of three jpayne@69: * significant digits for fractional seconds, corresponding to millisecond jpayne@69: * resolution and a fractional seconds sub-pattern of SSS. If the jpayne@69: * sub-pattern is S or SS, the fractional seconds value will be truncated jpayne@69: * (not rounded) to the number of display places specified. If the jpayne@69: * fractional seconds sub-pattern is longer than SSS, the additional jpayne@69: * display places will be filled with zeros. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_FRACTIONAL_SECOND_FIELD = 8, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'E' field alignment, jpayne@69: * corresponding to the UCAL_DAY_OF_WEEK field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_DAY_OF_WEEK_FIELD = 9, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'D' field alignment, jpayne@69: * corresponding to the UCAL_DAY_OF_YEAR field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_DAY_OF_YEAR_FIELD = 10, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'F' field alignment, jpayne@69: * corresponding to the UCAL_DAY_OF_WEEK_IN_MONTH field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_DAY_OF_WEEK_IN_MONTH_FIELD = 11, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'w' field alignment, jpayne@69: * corresponding to the UCAL_WEEK_OF_YEAR field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_WEEK_OF_YEAR_FIELD = 12, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'W' field alignment, jpayne@69: * corresponding to the UCAL_WEEK_OF_MONTH field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_WEEK_OF_MONTH_FIELD = 13, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'a' field alignment, jpayne@69: * corresponding to the UCAL_AM_PM field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_AM_PM_FIELD = 14, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'h' field alignment, jpayne@69: * corresponding to the UCAL_HOUR field. jpayne@69: * UDAT_HOUR1_FIELD is used for the one-based 12-hour clock. jpayne@69: * For example, 11:30 PM + 1 hour results in 12:30 AM. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_HOUR1_FIELD = 15, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'K' field alignment, jpayne@69: * corresponding to the UCAL_HOUR field. jpayne@69: * UDAT_HOUR0_FIELD is used for the zero-based 12-hour clock. jpayne@69: * For example, 11:30 PM + 1 hour results in 00:30 AM. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_HOUR0_FIELD = 16, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'z' field alignment, jpayne@69: * corresponding to the UCAL_ZONE_OFFSET and jpayne@69: * UCAL_DST_OFFSET fields. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_TIMEZONE_FIELD = 17, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'Y' field alignment, jpayne@69: * corresponding to the UCAL_YEAR_WOY field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_YEAR_WOY_FIELD = 18, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'e' field alignment, jpayne@69: * corresponding to the UCAL_DOW_LOCAL field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_DOW_LOCAL_FIELD = 19, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'u' field alignment, jpayne@69: * corresponding to the UCAL_EXTENDED_YEAR field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_EXTENDED_YEAR_FIELD = 20, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'g' field alignment, jpayne@69: * corresponding to the UCAL_JULIAN_DAY field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_JULIAN_DAY_FIELD = 21, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'A' field alignment, jpayne@69: * corresponding to the UCAL_MILLISECONDS_IN_DAY field. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_MILLISECONDS_IN_DAY_FIELD = 22, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'Z' field alignment, jpayne@69: * corresponding to the UCAL_ZONE_OFFSET and jpayne@69: * UCAL_DST_OFFSET fields. jpayne@69: * @stable ICU 3.0 jpayne@69: */ jpayne@69: UDAT_TIMEZONE_RFC_FIELD = 23, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'v' field alignment, jpayne@69: * corresponding to the UCAL_ZONE_OFFSET field. jpayne@69: * @stable ICU 3.4 jpayne@69: */ jpayne@69: UDAT_TIMEZONE_GENERIC_FIELD = 24, jpayne@69: /** jpayne@69: * FieldPosition selector for 'c' field alignment, jpayne@69: * corresponding to the {@link #UCAL_DOW_LOCAL} field. jpayne@69: * This displays the stand alone day name, if available. jpayne@69: * @stable ICU 3.4 jpayne@69: */ jpayne@69: UDAT_STANDALONE_DAY_FIELD = 25, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition selector for 'L' field alignment, jpayne@69: * corresponding to the {@link #UCAL_MONTH} field. jpayne@69: * This displays the stand alone month name, if available. jpayne@69: * @stable ICU 3.4 jpayne@69: */ jpayne@69: UDAT_STANDALONE_MONTH_FIELD = 26, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition selector for "Q" field alignment, jpayne@69: * corresponding to quarters. This is implemented jpayne@69: * using the {@link #UCAL_MONTH} field. This jpayne@69: * displays the quarter. jpayne@69: * @stable ICU 3.6 jpayne@69: */ jpayne@69: UDAT_QUARTER_FIELD = 27, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition selector for the "q" field alignment, jpayne@69: * corresponding to stand-alone quarters. This is jpayne@69: * implemented using the {@link #UCAL_MONTH} field. jpayne@69: * This displays the stand-alone quarter. jpayne@69: * @stable ICU 3.6 jpayne@69: */ jpayne@69: UDAT_STANDALONE_QUARTER_FIELD = 28, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'V' field alignment, jpayne@69: * corresponding to the UCAL_ZONE_OFFSET field. jpayne@69: * @stable ICU 3.8 jpayne@69: */ jpayne@69: UDAT_TIMEZONE_SPECIAL_FIELD = 29, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition selector for "U" field alignment, jpayne@69: * corresponding to cyclic year names. This is implemented jpayne@69: * using the {@link #UCAL_YEAR} field. This displays jpayne@69: * the cyclic year name, if available. jpayne@69: * @stable ICU 49 jpayne@69: */ jpayne@69: UDAT_YEAR_NAME_FIELD = 30, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition selector for 'O' field alignment, jpayne@69: * corresponding to the UCAL_ZONE_OFFSET and UCAL_DST_OFFSETfields. jpayne@69: * This displays the localized GMT format. jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: UDAT_TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD = 31, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition selector for 'X' field alignment, jpayne@69: * corresponding to the UCAL_ZONE_OFFSET and UCAL_DST_OFFSETfields. jpayne@69: * This displays the ISO 8601 local time offset format or UTC indicator ("Z"). jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: UDAT_TIMEZONE_ISO_FIELD = 32, jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition selector for 'x' field alignment, jpayne@69: * corresponding to the UCAL_ZONE_OFFSET and UCAL_DST_OFFSET fields. jpayne@69: * This displays the ISO 8601 local time offset format. jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: UDAT_TIMEZONE_ISO_LOCAL_FIELD = 33, jpayne@69: jpayne@69: #ifndef U_HIDE_INTERNAL_API jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for 'r' field alignment, jpayne@69: * no directly corresponding UCAL_ field. jpayne@69: * @internal ICU 53 jpayne@69: */ jpayne@69: UDAT_RELATED_YEAR_FIELD = 34, jpayne@69: #endif /* U_HIDE_INTERNAL_API */ jpayne@69: jpayne@69: /** jpayne@69: * FieldPosition selector for 'b' field alignment. jpayne@69: * Displays midnight and noon for 12am and 12pm, respectively, if available; jpayne@69: * otherwise fall back to AM / PM. jpayne@69: * @stable ICU 57 jpayne@69: */ jpayne@69: UDAT_AM_PM_MIDNIGHT_NOON_FIELD = 35, jpayne@69: jpayne@69: /* FieldPosition selector for 'B' field alignment. jpayne@69: * Displays flexible day periods, such as "in the morning", if available. jpayne@69: * @stable ICU 57 jpayne@69: */ jpayne@69: UDAT_FLEXIBLE_DAY_PERIOD_FIELD = 36, jpayne@69: jpayne@69: #ifndef U_HIDE_INTERNAL_API jpayne@69: /** jpayne@69: * FieldPosition and UFieldPosition selector for time separator, jpayne@69: * no corresponding UCAL_ field. No pattern character is currently jpayne@69: * defined for this. jpayne@69: * @internal jpayne@69: */ jpayne@69: UDAT_TIME_SEPARATOR_FIELD = 37, jpayne@69: #endif /* U_HIDE_INTERNAL_API */ jpayne@69: jpayne@69: #ifndef U_HIDE_DEPRECATED_API jpayne@69: /** jpayne@69: * Number of FieldPosition and UFieldPosition selectors for jpayne@69: * DateFormat and UDateFormat. jpayne@69: * Valid selectors range from 0 to UDAT_FIELD_COUNT-1. jpayne@69: * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. jpayne@69: */ jpayne@69: UDAT_FIELD_COUNT = 38 jpayne@69: #endif /* U_HIDE_DEPRECATED_API */ jpayne@69: } UDateFormatField; jpayne@69: jpayne@69: jpayne@69: #ifndef U_HIDE_INTERNAL_API jpayne@69: /** jpayne@69: * Is a pattern character defined for UDAT_TIME_SEPARATOR_FIELD? jpayne@69: * In ICU 55 it was COLON, but that was withdrawn in ICU 56. jpayne@69: * @internal ICU 56 jpayne@69: */ jpayne@69: #define UDAT_HAS_PATTERN_CHAR_FOR_TIME_SEPARATOR 0 jpayne@69: #endif /* U_HIDE_INTERNAL_API */ jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Maps from a UDateFormatField to the corresponding UCalendarDateFields. jpayne@69: * Note: since the mapping is many-to-one, there is no inverse mapping. jpayne@69: * @param field the UDateFormatField. jpayne@69: * @return the UCalendarDateField. This will be UCAL_FIELD_COUNT in case jpayne@69: * of error (e.g., the input field is UDAT_FIELD_COUNT). jpayne@69: * @stable ICU 4.4 jpayne@69: */ jpayne@69: U_CAPI UCalendarDateFields U_EXPORT2 jpayne@69: udat_toCalendarDateField(UDateFormatField field); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Open a new UDateFormat for formatting and parsing dates and times. jpayne@69: * A UDateFormat may be used to format dates in calls to {@link #udat_format }, jpayne@69: * and to parse dates in calls to {@link #udat_parse }. jpayne@69: * @param timeStyle The style used to format times; one of UDAT_FULL, UDAT_LONG, jpayne@69: * UDAT_MEDIUM, UDAT_SHORT, UDAT_DEFAULT, or UDAT_NONE (relative time styles jpayne@69: * are not currently supported). jpayne@69: * When the pattern parameter is used, pass in UDAT_PATTERN for both timeStyle and dateStyle. jpayne@69: * @param dateStyle The style used to format dates; one of UDAT_FULL, UDAT_LONG, jpayne@69: * UDAT_MEDIUM, UDAT_SHORT, UDAT_DEFAULT, UDAT_FULL_RELATIVE, UDAT_LONG_RELATIVE, jpayne@69: * UDAT_MEDIUM_RELATIVE, UDAT_SHORT_RELATIVE, or UDAT_NONE. jpayne@69: * When the pattern parameter is used, pass in UDAT_PATTERN for both timeStyle and dateStyle. jpayne@69: * As currently implemented, jpayne@69: * relative date formatting only affects a limited range of calendar days before or jpayne@69: * after the current date, based on the CLDR <field type="day">/<relative> data: For jpayne@69: * example, in English, "Yesterday", "Today", and "Tomorrow". Outside of this range, jpayne@69: * dates are formatted using the corresponding non-relative style. jpayne@69: * @param locale The locale specifying the formatting conventions jpayne@69: * @param tzID A timezone ID specifying the timezone to use. If 0, use jpayne@69: * the default timezone. jpayne@69: * @param tzIDLength The length of tzID, or -1 if null-terminated. jpayne@69: * @param pattern A pattern specifying the format to use. jpayne@69: * @param patternLength The number of characters in the pattern, or -1 if null-terminated. jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @return A pointer to a UDateFormat to use for formatting dates and times, or 0 if jpayne@69: * an error occurred. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI UDateFormat* U_EXPORT2 jpayne@69: udat_open(UDateFormatStyle timeStyle, jpayne@69: UDateFormatStyle dateStyle, jpayne@69: const char *locale, jpayne@69: const UChar *tzID, jpayne@69: int32_t tzIDLength, jpayne@69: const UChar *pattern, jpayne@69: int32_t patternLength, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Close a UDateFormat. jpayne@69: * Once closed, a UDateFormat may no longer be used. jpayne@69: * @param format The formatter to close. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI void U_EXPORT2 jpayne@69: udat_close(UDateFormat* format); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * DateFormat boolean attributes jpayne@69: * jpayne@69: * @stable ICU 53 jpayne@69: */ jpayne@69: typedef enum UDateFormatBooleanAttribute { jpayne@69: /** jpayne@69: * indicates whether whitespace is allowed. Includes trailing dot tolerance. jpayne@69: * @stable ICU 53 jpayne@69: */ jpayne@69: UDAT_PARSE_ALLOW_WHITESPACE = 0, jpayne@69: /** jpayne@69: * indicates tolerance of numeric data when String data may be assumed. eg: UDAT_YEAR_NAME_FIELD, jpayne@69: * UDAT_STANDALONE_MONTH_FIELD, UDAT_DAY_OF_WEEK_FIELD jpayne@69: * @stable ICU 53 jpayne@69: */ jpayne@69: UDAT_PARSE_ALLOW_NUMERIC = 1, jpayne@69: /** jpayne@69: * indicates tolerance of a partial literal match jpayne@69: * e.g. accepting "--mon-02-march-2011" for a pattern of "'--: 'EEE-WW-MMMM-yyyy" jpayne@69: * @stable ICU 56 jpayne@69: */ jpayne@69: UDAT_PARSE_PARTIAL_LITERAL_MATCH = 2, jpayne@69: /** jpayne@69: * indicates tolerance of pattern mismatch between input data and specified format pattern. jpayne@69: * e.g. accepting "September" for a month pattern of MMM ("Sep") jpayne@69: * @stable ICU 56 jpayne@69: */ jpayne@69: UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH = 3, jpayne@69: jpayne@69: /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, jpayne@69: * it is needed for layout of DateFormat object. */ jpayne@69: #ifndef U_FORCE_HIDE_DEPRECATED_API jpayne@69: /** jpayne@69: * One more than the highest normal UDateFormatBooleanAttribute value. jpayne@69: * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. jpayne@69: */ jpayne@69: UDAT_BOOLEAN_ATTRIBUTE_COUNT = 4 jpayne@69: #endif // U_FORCE_HIDE_DEPRECATED_API jpayne@69: } UDateFormatBooleanAttribute; jpayne@69: jpayne@69: /** jpayne@69: * Get a boolean attribute associated with a UDateFormat. jpayne@69: * An example would be a true value for a key of UDAT_PARSE_ALLOW_WHITESPACE indicating allowing whitespace leniency. jpayne@69: * If the formatter does not understand the attribute, -1 is returned. jpayne@69: * @param fmt The formatter to query. jpayne@69: * @param attr The attribute to query; e.g. UDAT_PARSE_ALLOW_WHITESPACE. jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @return The value of attr. jpayne@69: * @stable ICU 53 jpayne@69: */ jpayne@69: U_CAPI UBool U_EXPORT2 jpayne@69: udat_getBooleanAttribute(const UDateFormat* fmt, UDateFormatBooleanAttribute attr, UErrorCode* status); jpayne@69: jpayne@69: /** jpayne@69: * Set a boolean attribute associated with a UDateFormat. jpayne@69: * An example of a boolean attribute is parse leniency control. If the formatter does not understand jpayne@69: * the attribute, the call is ignored. jpayne@69: * @param fmt The formatter to set. jpayne@69: * @param attr The attribute to set; one of UDAT_PARSE_ALLOW_WHITESPACE or UDAT_PARSE_ALLOW_NUMERIC jpayne@69: * @param newValue The new value of attr. jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @stable ICU 53 jpayne@69: */ jpayne@69: U_CAPI void U_EXPORT2 jpayne@69: udat_setBooleanAttribute(UDateFormat *fmt, UDateFormatBooleanAttribute attr, UBool newValue, UErrorCode* status); jpayne@69: jpayne@69: #ifndef U_HIDE_DRAFT_API jpayne@69: /** jpayne@69: * Hour Cycle. jpayne@69: * @draft ICU 67 jpayne@69: */ jpayne@69: typedef enum UDateFormatHourCycle { jpayne@69: /** jpayne@69: * Hour in am/pm (0~11) jpayne@69: * @draft ICU 67 jpayne@69: */ jpayne@69: UDAT_HOUR_CYCLE_11, jpayne@69: jpayne@69: /** jpayne@69: * Hour in am/pm (1~12) jpayne@69: * @draft ICU 67 jpayne@69: */ jpayne@69: UDAT_HOUR_CYCLE_12, jpayne@69: jpayne@69: /** jpayne@69: * Hour in day (0~23) jpayne@69: * @draft ICU 67 jpayne@69: */ jpayne@69: UDAT_HOUR_CYCLE_23, jpayne@69: jpayne@69: /** jpayne@69: * Hour in day (1~24) jpayne@69: * @draft ICU 67 jpayne@69: */ jpayne@69: UDAT_HOUR_CYCLE_24 jpayne@69: } UDateFormatHourCycle; jpayne@69: #endif /* U_HIDE_DRAFT_API */ jpayne@69: jpayne@69: #if U_SHOW_CPLUSPLUS_API jpayne@69: jpayne@69: U_NAMESPACE_BEGIN jpayne@69: jpayne@69: /** jpayne@69: * \class LocalUDateFormatPointer jpayne@69: * "Smart pointer" class, closes a UDateFormat via udat_close(). jpayne@69: * For most methods see the LocalPointerBase base class. jpayne@69: * jpayne@69: * @see LocalPointerBase jpayne@69: * @see LocalPointer jpayne@69: * @stable ICU 4.4 jpayne@69: */ jpayne@69: U_DEFINE_LOCAL_OPEN_POINTER(LocalUDateFormatPointer, UDateFormat, udat_close); jpayne@69: jpayne@69: U_NAMESPACE_END jpayne@69: jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * Open a copy of a UDateFormat. jpayne@69: * This function performs a deep copy. jpayne@69: * @param fmt The format to copy jpayne@69: * @param status A pointer to an UErrorCode to receive any errors. jpayne@69: * @return A pointer to a UDateFormat identical to fmt. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI UDateFormat* U_EXPORT2 jpayne@69: udat_clone(const UDateFormat *fmt, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Format a date using a UDateFormat. jpayne@69: * The date will be formatted using the conventions specified in {@link #udat_open } jpayne@69: * @param format The formatter to use jpayne@69: * @param dateToFormat The date to format jpayne@69: * @param result A pointer to a buffer to receive the formatted number. jpayne@69: * @param resultLength The maximum size of result. jpayne@69: * @param position A pointer to a UFieldPosition. On input, position->field jpayne@69: * is read. On output, position->beginIndex and position->endIndex indicate jpayne@69: * the beginning and ending indices of field number position->field, if such jpayne@69: * a field exists. This parameter may be NULL, in which case no field jpayne@69: * position data is returned. jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @return The total buffer size needed; if greater than resultLength, the output was truncated. jpayne@69: * @see udat_parse jpayne@69: * @see UFieldPosition jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI int32_t U_EXPORT2 jpayne@69: udat_format( const UDateFormat* format, jpayne@69: UDate dateToFormat, jpayne@69: UChar* result, jpayne@69: int32_t resultLength, jpayne@69: UFieldPosition* position, jpayne@69: UErrorCode* status); jpayne@69: jpayne@69: /** jpayne@69: * Format a date using an UDateFormat. jpayne@69: * The date will be formatted using the conventions specified in {@link #udat_open } jpayne@69: * @param format The formatter to use jpayne@69: * @param calendar The calendar to format. The calendar instance might be jpayne@69: * mutated if fields are not yet fully calculated, though jpayne@69: * the function won't change the logical date and time held jpayne@69: * by the instance. jpayne@69: * @param result A pointer to a buffer to receive the formatted number. jpayne@69: * @param capacity The maximum size of result. jpayne@69: * @param position A pointer to a UFieldPosition. On input, position->field jpayne@69: * is read. On output, position->beginIndex and position->endIndex indicate jpayne@69: * the beginning and ending indices of field number position->field, if such jpayne@69: * a field exists. This parameter may be NULL, in which case no field jpayne@69: * position data is returned. jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @return The total buffer size needed; if greater than resultLength, the output was truncated. jpayne@69: * @see udat_format jpayne@69: * @see udat_parseCalendar jpayne@69: * @see UFieldPosition jpayne@69: * @stable ICU 55 jpayne@69: */ jpayne@69: U_CAPI int32_t U_EXPORT2 jpayne@69: udat_formatCalendar( const UDateFormat* format, jpayne@69: UCalendar* calendar, jpayne@69: UChar* result, jpayne@69: int32_t capacity, jpayne@69: UFieldPosition* position, jpayne@69: UErrorCode* status); jpayne@69: jpayne@69: /** jpayne@69: * Format a date using a UDateFormat. jpayne@69: * The date will be formatted using the conventions specified in {@link #udat_open} jpayne@69: * @param format jpayne@69: * The formatter to use jpayne@69: * @param dateToFormat jpayne@69: * The date to format jpayne@69: * @param result jpayne@69: * A pointer to a buffer to receive the formatted number. jpayne@69: * @param resultLength jpayne@69: * The maximum size of result. jpayne@69: * @param fpositer jpayne@69: * A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open} jpayne@69: * (may be NULL if field position information is not needed). Any jpayne@69: * iteration information already present in the UFieldPositionIterator jpayne@69: * will be deleted, and the iterator will be reset to apply to the jpayne@69: * fields in the formatted string created by this function call; the jpayne@69: * field values provided by {@link #ufieldpositer_next} will be from the jpayne@69: * UDateFormatField enum. jpayne@69: * @param status jpayne@69: * A pointer to a UErrorCode to receive any errors jpayne@69: * @return jpayne@69: * The total buffer size needed; if greater than resultLength, the output was truncated. jpayne@69: * @see udat_parse jpayne@69: * @see UFieldPositionIterator jpayne@69: * @stable ICU 55 jpayne@69: */ jpayne@69: U_CAPI int32_t U_EXPORT2 jpayne@69: udat_formatForFields( const UDateFormat* format, jpayne@69: UDate dateToFormat, jpayne@69: UChar* result, jpayne@69: int32_t resultLength, jpayne@69: UFieldPositionIterator* fpositer, jpayne@69: UErrorCode* status); jpayne@69: jpayne@69: /** jpayne@69: * Format a date using a UDateFormat. jpayne@69: * The date will be formatted using the conventions specified in {@link #udat_open } jpayne@69: * @param format jpayne@69: * The formatter to use jpayne@69: * @param calendar jpayne@69: * The calendar to format. The calendar instance might be mutated if fields jpayne@69: * are not yet fully calculated, though the function won't change the logical jpayne@69: * date and time held by the instance. jpayne@69: * @param result jpayne@69: * A pointer to a buffer to receive the formatted number. jpayne@69: * @param capacity jpayne@69: * The maximum size of result. jpayne@69: * @param fpositer jpayne@69: * A pointer to a UFieldPositionIterator created by {@link #ufieldpositer_open} jpayne@69: * (may be NULL if field position information is not needed). Any jpayne@69: * iteration information already present in the UFieldPositionIterator jpayne@69: * will be deleted, and the iterator will be reset to apply to the jpayne@69: * fields in the formatted string created by this function call; the jpayne@69: * field values provided by {@link #ufieldpositer_next} will be from the jpayne@69: * UDateFormatField enum. jpayne@69: * @param status jpayne@69: * A pointer to a UErrorCode to receive any errors jpayne@69: * @return jpayne@69: * The total buffer size needed; if greater than resultLength, the output was truncated. jpayne@69: * @see udat_format jpayne@69: * @see udat_parseCalendar jpayne@69: * @see UFieldPositionIterator jpayne@69: * @stable ICU 55 jpayne@69: */ jpayne@69: U_CAPI int32_t U_EXPORT2 jpayne@69: udat_formatCalendarForFields( const UDateFormat* format, jpayne@69: UCalendar* calendar, jpayne@69: UChar* result, jpayne@69: int32_t capacity, jpayne@69: UFieldPositionIterator* fpositer, jpayne@69: UErrorCode* status); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * Parse a string into an date/time using a UDateFormat. jpayne@69: * The date will be parsed using the conventions specified in {@link #udat_open }. jpayne@69: *

jpayne@69: * Note that the normal date formats associated with some calendars - such jpayne@69: * as the Chinese lunar calendar - do not specify enough fields to enable jpayne@69: * dates to be parsed unambiguously. In the case of the Chinese lunar jpayne@69: * calendar, while the year within the current 60-year cycle is specified, jpayne@69: * the number of such cycles since the start date of the calendar (in the jpayne@69: * UCAL_ERA field of the UCalendar object) is not normally part of the format, jpayne@69: * and parsing may assume the wrong era. For cases such as this it is jpayne@69: * recommended that clients parse using udat_parseCalendar with the UCalendar jpayne@69: * passed in set to the current date, or to a date within the era/cycle that jpayne@69: * should be assumed if absent in the format. jpayne@69: * jpayne@69: * @param format The formatter to use. jpayne@69: * @param text The text to parse. jpayne@69: * @param textLength The length of text, or -1 if null-terminated. jpayne@69: * @param parsePos If not 0, on input a pointer to an integer specifying the offset at which jpayne@69: * to begin parsing. If not 0, on output the offset at which parsing ended. jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @return The value of the parsed date/time jpayne@69: * @see udat_format jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI UDate U_EXPORT2 jpayne@69: udat_parse(const UDateFormat* format, jpayne@69: const UChar* text, jpayne@69: int32_t textLength, jpayne@69: int32_t *parsePos, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Parse a string into an date/time using a UDateFormat. jpayne@69: * The date will be parsed using the conventions specified in {@link #udat_open }. jpayne@69: * @param format The formatter to use. jpayne@69: * @param calendar A calendar set on input to the date and time to be used for jpayne@69: * missing values in the date/time string being parsed, and set jpayne@69: * on output to the parsed date/time. When the calendar type is jpayne@69: * different from the internal calendar held by the UDateFormat jpayne@69: * instance, the internal calendar will be cloned to a work jpayne@69: * calendar set to the same milliseconds and time zone as this jpayne@69: * calendar parameter, field values will be parsed based on the jpayne@69: * work calendar, then the result (milliseconds and time zone) jpayne@69: * will be set in this calendar. jpayne@69: * @param text The text to parse. jpayne@69: * @param textLength The length of text, or -1 if null-terminated. jpayne@69: * @param parsePos If not 0, on input a pointer to an integer specifying the offset at which jpayne@69: * to begin parsing. If not 0, on output the offset at which parsing ended. jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @see udat_format jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI void U_EXPORT2 jpayne@69: udat_parseCalendar(const UDateFormat* format, jpayne@69: UCalendar* calendar, jpayne@69: const UChar* text, jpayne@69: int32_t textLength, jpayne@69: int32_t *parsePos, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Determine if an UDateFormat will perform lenient parsing. jpayne@69: * With lenient parsing, the parser may use heuristics to interpret inputs that do not jpayne@69: * precisely match the pattern. With strict parsing, inputs must match the pattern. jpayne@69: * @param fmt The formatter to query jpayne@69: * @return TRUE if fmt is set to perform lenient parsing, FALSE otherwise. jpayne@69: * @see udat_setLenient jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI UBool U_EXPORT2 jpayne@69: udat_isLenient(const UDateFormat* fmt); jpayne@69: jpayne@69: /** jpayne@69: * Specify whether an UDateFormat will perform lenient parsing. jpayne@69: * With lenient parsing, the parser may use heuristics to interpret inputs that do not jpayne@69: * precisely match the pattern. With strict parsing, inputs must match the pattern. jpayne@69: * @param fmt The formatter to set jpayne@69: * @param isLenient TRUE if fmt should perform lenient parsing, FALSE otherwise. jpayne@69: * @see dat_isLenient jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI void U_EXPORT2 jpayne@69: udat_setLenient( UDateFormat* fmt, jpayne@69: UBool isLenient); jpayne@69: jpayne@69: /** jpayne@69: * Get the UCalendar associated with an UDateFormat. jpayne@69: * A UDateFormat uses a UCalendar to convert a raw value to, for example, jpayne@69: * the day of the week. jpayne@69: * @param fmt The formatter to query. jpayne@69: * @return A pointer to the UCalendar used by fmt. jpayne@69: * @see udat_setCalendar jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI const UCalendar* U_EXPORT2 jpayne@69: udat_getCalendar(const UDateFormat* fmt); jpayne@69: jpayne@69: /** jpayne@69: * Set the UCalendar associated with an UDateFormat. jpayne@69: * A UDateFormat uses a UCalendar to convert a raw value to, for example, jpayne@69: * the day of the week. jpayne@69: * @param fmt The formatter to set. jpayne@69: * @param calendarToSet A pointer to an UCalendar to be used by fmt. jpayne@69: * @see udat_setCalendar jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI void U_EXPORT2 jpayne@69: udat_setCalendar( UDateFormat* fmt, jpayne@69: const UCalendar* calendarToSet); jpayne@69: jpayne@69: /** jpayne@69: * Get the UNumberFormat associated with an UDateFormat. jpayne@69: * A UDateFormat uses a UNumberFormat to format numbers within a date, jpayne@69: * for example the day number. jpayne@69: * @param fmt The formatter to query. jpayne@69: * @return A pointer to the UNumberFormat used by fmt to format numbers. jpayne@69: * @see udat_setNumberFormat jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI const UNumberFormat* U_EXPORT2 jpayne@69: udat_getNumberFormat(const UDateFormat* fmt); jpayne@69: jpayne@69: /** jpayne@69: * Get the UNumberFormat for specific field associated with an UDateFormat. jpayne@69: * For example: 'y' for year and 'M' for month jpayne@69: * @param fmt The formatter to query. jpayne@69: * @param field the field to query jpayne@69: * @return A pointer to the UNumberFormat used by fmt to format field numbers. jpayne@69: * @see udat_setNumberFormatForField jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: U_CAPI const UNumberFormat* U_EXPORT2 jpayne@69: udat_getNumberFormatForField(const UDateFormat* fmt, UChar field); jpayne@69: jpayne@69: /** jpayne@69: * Set the UNumberFormat for specific field associated with an UDateFormat. jpayne@69: * It can be a single field like: "y"(year) or "M"(month) jpayne@69: * It can be several field combined together: "yM"(year and month) jpayne@69: * Note: jpayne@69: * 1 symbol field is enough for multiple symbol field (so "y" will override "yy", "yyy") jpayne@69: * If the field is not numeric, then override has no effect (like "MMM" will use abbreviation, not numerical field) jpayne@69: * jpayne@69: * @param fields the fields to set jpayne@69: * @param fmt The formatter to set. jpayne@69: * @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to format numbers. jpayne@69: * @param status error code passed around (memory allocation or invalid fields) jpayne@69: * @see udat_getNumberFormatForField jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: U_CAPI void U_EXPORT2 jpayne@69: udat_adoptNumberFormatForFields( UDateFormat* fmt, jpayne@69: const UChar* fields, jpayne@69: UNumberFormat* numberFormatToSet, jpayne@69: UErrorCode* status); jpayne@69: /** jpayne@69: * Set the UNumberFormat associated with an UDateFormat. jpayne@69: * A UDateFormat uses a UNumberFormat to format numbers within a date, jpayne@69: * for example the day number. jpayne@69: * This method also clears per field NumberFormat instances previously jpayne@69: * set by {@see udat_setNumberFormatForField} jpayne@69: * @param fmt The formatter to set. jpayne@69: * @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to format numbers. jpayne@69: * @see udat_getNumberFormat jpayne@69: * @see udat_setNumberFormatForField jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI void U_EXPORT2 jpayne@69: udat_setNumberFormat( UDateFormat* fmt, jpayne@69: const UNumberFormat* numberFormatToSet); jpayne@69: /** jpayne@69: * Adopt the UNumberFormat associated with an UDateFormat. jpayne@69: * A UDateFormat uses a UNumberFormat to format numbers within a date, jpayne@69: * for example the day number. jpayne@69: * @param fmt The formatter to set. jpayne@69: * @param numberFormatToAdopt A pointer to the UNumberFormat to be used by fmt to format numbers. jpayne@69: * @see udat_getNumberFormat jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: U_CAPI void U_EXPORT2 jpayne@69: udat_adoptNumberFormat( UDateFormat* fmt, jpayne@69: UNumberFormat* numberFormatToAdopt); jpayne@69: /** jpayne@69: * Get a locale for which date/time formatting patterns are available. jpayne@69: * A UDateFormat in a locale returned by this function will perform the correct jpayne@69: * formatting and parsing for the locale. jpayne@69: * @param localeIndex The index of the desired locale. jpayne@69: * @return A locale for which date/time formatting patterns are available, or 0 if none. jpayne@69: * @see udat_countAvailable jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI const char* U_EXPORT2 jpayne@69: udat_getAvailable(int32_t localeIndex); jpayne@69: jpayne@69: /** jpayne@69: * Determine how many locales have date/time formatting patterns available. jpayne@69: * This function is most useful as determining the loop ending condition for jpayne@69: * calls to {@link #udat_getAvailable }. jpayne@69: * @return The number of locales for which date/time formatting patterns are available. jpayne@69: * @see udat_getAvailable jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI int32_t U_EXPORT2 jpayne@69: udat_countAvailable(void); jpayne@69: jpayne@69: /** jpayne@69: * Get the year relative to which all 2-digit years are interpreted. jpayne@69: * For example, if the 2-digit start year is 2100, the year 99 will be jpayne@69: * interpreted as 2199. jpayne@69: * @param fmt The formatter to query. jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @return The year relative to which all 2-digit years are interpreted. jpayne@69: * @see udat_Set2DigitYearStart jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI UDate U_EXPORT2 jpayne@69: udat_get2DigitYearStart( const UDateFormat *fmt, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Set the year relative to which all 2-digit years will be interpreted. jpayne@69: * For example, if the 2-digit start year is 2100, the year 99 will be jpayne@69: * interpreted as 2199. jpayne@69: * @param fmt The formatter to set. jpayne@69: * @param d The year relative to which all 2-digit years will be interpreted. jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @see udat_Set2DigitYearStart jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI void U_EXPORT2 jpayne@69: udat_set2DigitYearStart( UDateFormat *fmt, jpayne@69: UDate d, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Extract the pattern from a UDateFormat. jpayne@69: * The pattern will follow the pattern syntax rules. jpayne@69: * @param fmt The formatter to query. jpayne@69: * @param localized TRUE if the pattern should be localized, FALSE otherwise. jpayne@69: * @param result A pointer to a buffer to receive the pattern. jpayne@69: * @param resultLength The maximum size of result. jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @return The total buffer size needed; if greater than resultLength, the output was truncated. jpayne@69: * @see udat_applyPattern jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI int32_t U_EXPORT2 jpayne@69: udat_toPattern( const UDateFormat *fmt, jpayne@69: UBool localized, jpayne@69: UChar *result, jpayne@69: int32_t resultLength, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Set the pattern used by an UDateFormat. jpayne@69: * The pattern should follow the pattern syntax rules. jpayne@69: * @param format The formatter to set. jpayne@69: * @param localized TRUE if the pattern is localized, FALSE otherwise. jpayne@69: * @param pattern The new pattern jpayne@69: * @param patternLength The length of pattern, or -1 if null-terminated. jpayne@69: * @see udat_toPattern jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI void U_EXPORT2 jpayne@69: udat_applyPattern( UDateFormat *format, jpayne@69: UBool localized, jpayne@69: const UChar *pattern, jpayne@69: int32_t patternLength); jpayne@69: jpayne@69: /** jpayne@69: * The possible types of date format symbols jpayne@69: * @stable ICU 2.6 jpayne@69: */ jpayne@69: typedef enum UDateFormatSymbolType { jpayne@69: /** The era names, for example AD */ jpayne@69: UDAT_ERAS, jpayne@69: /** The month names, for example February */ jpayne@69: UDAT_MONTHS, jpayne@69: /** The short month names, for example Feb. */ jpayne@69: UDAT_SHORT_MONTHS, jpayne@69: /** The CLDR-style format "wide" weekday names, for example Monday */ jpayne@69: UDAT_WEEKDAYS, jpayne@69: /** jpayne@69: * The CLDR-style format "abbreviated" (not "short") weekday names, for example "Mon." jpayne@69: * For the CLDR-style format "short" weekday names, use UDAT_SHORTER_WEEKDAYS. jpayne@69: */ jpayne@69: UDAT_SHORT_WEEKDAYS, jpayne@69: /** The AM/PM names, for example AM */ jpayne@69: UDAT_AM_PMS, jpayne@69: /** The localized characters */ jpayne@69: UDAT_LOCALIZED_CHARS, jpayne@69: /** The long era names, for example Anno Domini */ jpayne@69: UDAT_ERA_NAMES, jpayne@69: /** The narrow month names, for example F */ jpayne@69: UDAT_NARROW_MONTHS, jpayne@69: /** The CLDR-style format "narrow" weekday names, for example "M" */ jpayne@69: UDAT_NARROW_WEEKDAYS, jpayne@69: /** Standalone context versions of months */ jpayne@69: UDAT_STANDALONE_MONTHS, jpayne@69: UDAT_STANDALONE_SHORT_MONTHS, jpayne@69: UDAT_STANDALONE_NARROW_MONTHS, jpayne@69: /** The CLDR-style stand-alone "wide" weekday names */ jpayne@69: UDAT_STANDALONE_WEEKDAYS, jpayne@69: /** jpayne@69: * The CLDR-style stand-alone "abbreviated" (not "short") weekday names. jpayne@69: * For the CLDR-style stand-alone "short" weekday names, use UDAT_STANDALONE_SHORTER_WEEKDAYS. jpayne@69: */ jpayne@69: UDAT_STANDALONE_SHORT_WEEKDAYS, jpayne@69: /** The CLDR-style stand-alone "narrow" weekday names */ jpayne@69: UDAT_STANDALONE_NARROW_WEEKDAYS, jpayne@69: /** The quarters, for example 1st Quarter */ jpayne@69: UDAT_QUARTERS, jpayne@69: /** The short quarter names, for example Q1 */ jpayne@69: UDAT_SHORT_QUARTERS, jpayne@69: /** Standalone context versions of quarters */ jpayne@69: UDAT_STANDALONE_QUARTERS, jpayne@69: UDAT_STANDALONE_SHORT_QUARTERS, jpayne@69: /** jpayne@69: * The CLDR-style short weekday names, e.g. "Su", Mo", etc. jpayne@69: * These are named "SHORTER" to contrast with the constants using _SHORT_ jpayne@69: * above, which actually get the CLDR-style *abbreviated* versions of the jpayne@69: * corresponding names. jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: UDAT_SHORTER_WEEKDAYS, jpayne@69: /** jpayne@69: * Standalone version of UDAT_SHORTER_WEEKDAYS. jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: UDAT_STANDALONE_SHORTER_WEEKDAYS, jpayne@69: /** jpayne@69: * Cyclic year names (only supported for some calendars, and only for FORMAT usage; jpayne@69: * udat_setSymbols not supported for UDAT_CYCLIC_YEARS_WIDE) jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: UDAT_CYCLIC_YEARS_WIDE, jpayne@69: /** jpayne@69: * Cyclic year names (only supported for some calendars, and only for FORMAT usage) jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: UDAT_CYCLIC_YEARS_ABBREVIATED, jpayne@69: /** jpayne@69: * Cyclic year names (only supported for some calendars, and only for FORMAT usage; jpayne@69: * udat_setSymbols not supported for UDAT_CYCLIC_YEARS_NARROW) jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: UDAT_CYCLIC_YEARS_NARROW, jpayne@69: /** jpayne@69: * Calendar zodiac names (only supported for some calendars, and only for FORMAT usage; jpayne@69: * udat_setSymbols not supported for UDAT_ZODIAC_NAMES_WIDE) jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: UDAT_ZODIAC_NAMES_WIDE, jpayne@69: /** jpayne@69: * Calendar zodiac names (only supported for some calendars, and only for FORMAT usage) jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: UDAT_ZODIAC_NAMES_ABBREVIATED, jpayne@69: /** jpayne@69: * Calendar zodiac names (only supported for some calendars, and only for FORMAT usage; jpayne@69: * udat_setSymbols not supported for UDAT_ZODIAC_NAMES_NARROW) jpayne@69: * @stable ICU 54 jpayne@69: */ jpayne@69: UDAT_ZODIAC_NAMES_NARROW jpayne@69: } UDateFormatSymbolType; jpayne@69: jpayne@69: struct UDateFormatSymbols; jpayne@69: /** Date format symbols. jpayne@69: * For usage in C programs. jpayne@69: * @stable ICU 2.6 jpayne@69: */ jpayne@69: typedef struct UDateFormatSymbols UDateFormatSymbols; jpayne@69: jpayne@69: /** jpayne@69: * Get the symbols associated with an UDateFormat. jpayne@69: * The symbols are what a UDateFormat uses to represent locale-specific data, jpayne@69: * for example month or day names. jpayne@69: * @param fmt The formatter to query. jpayne@69: * @param type The type of symbols to get. One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS, jpayne@69: * UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS jpayne@69: * @param symbolIndex The desired symbol of type type. jpayne@69: * @param result A pointer to a buffer to receive the pattern. jpayne@69: * @param resultLength The maximum size of result. jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @return The total buffer size needed; if greater than resultLength, the output was truncated. jpayne@69: * @see udat_countSymbols jpayne@69: * @see udat_setSymbols jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI int32_t U_EXPORT2 jpayne@69: udat_getSymbols(const UDateFormat *fmt, jpayne@69: UDateFormatSymbolType type, jpayne@69: int32_t symbolIndex, jpayne@69: UChar *result, jpayne@69: int32_t resultLength, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Count the number of particular symbols for an UDateFormat. jpayne@69: * This function is most useful as for detemining the loop termination condition jpayne@69: * for calls to {@link #udat_getSymbols }. jpayne@69: * @param fmt The formatter to query. jpayne@69: * @param type The type of symbols to count. One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS, jpayne@69: * UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS jpayne@69: * @return The number of symbols of type type. jpayne@69: * @see udat_getSymbols jpayne@69: * @see udat_setSymbols jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI int32_t U_EXPORT2 jpayne@69: udat_countSymbols( const UDateFormat *fmt, jpayne@69: UDateFormatSymbolType type); jpayne@69: jpayne@69: /** jpayne@69: * Set the symbols associated with an UDateFormat. jpayne@69: * The symbols are what a UDateFormat uses to represent locale-specific data, jpayne@69: * for example month or day names. jpayne@69: * @param format The formatter to set jpayne@69: * @param type The type of symbols to set. One of UDAT_ERAS, UDAT_MONTHS, UDAT_SHORT_MONTHS, jpayne@69: * UDAT_WEEKDAYS, UDAT_SHORT_WEEKDAYS, UDAT_AM_PMS, or UDAT_LOCALIZED_CHARS jpayne@69: * @param symbolIndex The index of the symbol to set of type type. jpayne@69: * @param value The new value jpayne@69: * @param valueLength The length of value, or -1 if null-terminated jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @see udat_getSymbols jpayne@69: * @see udat_countSymbols jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: U_CAPI void U_EXPORT2 jpayne@69: udat_setSymbols( UDateFormat *format, jpayne@69: UDateFormatSymbolType type, jpayne@69: int32_t symbolIndex, jpayne@69: UChar *value, jpayne@69: int32_t valueLength, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Get the locale for this date format object. jpayne@69: * You can choose between valid and actual locale. jpayne@69: * @param fmt The formatter to get the locale from jpayne@69: * @param type type of the locale we're looking for (valid or actual) jpayne@69: * @param status error code for the operation jpayne@69: * @return the locale name jpayne@69: * @stable ICU 2.8 jpayne@69: */ jpayne@69: U_CAPI const char* U_EXPORT2 jpayne@69: udat_getLocaleByType(const UDateFormat *fmt, jpayne@69: ULocDataLocaleType type, jpayne@69: UErrorCode* status); jpayne@69: jpayne@69: /** jpayne@69: * Set a particular UDisplayContext value in the formatter, such as jpayne@69: * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. jpayne@69: * @param fmt The formatter for which to set a UDisplayContext value. jpayne@69: * @param value The UDisplayContext value to set. jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @stable ICU 51 jpayne@69: */ jpayne@69: U_CAPI void U_EXPORT2 jpayne@69: udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status); jpayne@69: jpayne@69: /** jpayne@69: * Get the formatter's UDisplayContext value for the specified UDisplayContextType, jpayne@69: * such as UDISPCTX_TYPE_CAPITALIZATION. jpayne@69: * @param fmt The formatter to query. jpayne@69: * @param type The UDisplayContextType whose value to return jpayne@69: * @param status A pointer to an UErrorCode to receive any errors jpayne@69: * @return The UDisplayContextValue for the specified type. jpayne@69: * @stable ICU 53 jpayne@69: */ jpayne@69: U_CAPI UDisplayContext U_EXPORT2 jpayne@69: udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* status); jpayne@69: jpayne@69: #ifndef U_HIDE_INTERNAL_API jpayne@69: /** jpayne@69: * Extract the date pattern from a UDateFormat set for relative date formatting. jpayne@69: * The pattern will follow the pattern syntax rules. jpayne@69: * @param fmt The formatter to query. jpayne@69: * @param result A pointer to a buffer to receive the pattern. jpayne@69: * @param resultLength The maximum size of result. jpayne@69: * @param status A pointer to a UErrorCode to receive any errors jpayne@69: * @return The total buffer size needed; if greater than resultLength, the output was truncated. jpayne@69: * @see udat_applyPatternRelative jpayne@69: * @internal ICU 4.2 technology preview jpayne@69: */ jpayne@69: U_INTERNAL int32_t U_EXPORT2 jpayne@69: udat_toPatternRelativeDate(const UDateFormat *fmt, jpayne@69: UChar *result, jpayne@69: int32_t resultLength, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Extract the time pattern from a UDateFormat set for relative date formatting. jpayne@69: * The pattern will follow the pattern syntax rules. jpayne@69: * @param fmt The formatter to query. jpayne@69: * @param result A pointer to a buffer to receive the pattern. jpayne@69: * @param resultLength The maximum size of result. jpayne@69: * @param status A pointer to a UErrorCode to receive any errors jpayne@69: * @return The total buffer size needed; if greater than resultLength, the output was truncated. jpayne@69: * @see udat_applyPatternRelative jpayne@69: * @internal ICU 4.2 technology preview jpayne@69: */ jpayne@69: U_INTERNAL int32_t U_EXPORT2 jpayne@69: udat_toPatternRelativeTime(const UDateFormat *fmt, jpayne@69: UChar *result, jpayne@69: int32_t resultLength, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Set the date & time patterns used by a UDateFormat set for relative date formatting. jpayne@69: * The patterns should follow the pattern syntax rules. jpayne@69: * @param format The formatter to set. jpayne@69: * @param datePattern The new date pattern jpayne@69: * @param datePatternLength The length of datePattern, or -1 if null-terminated. jpayne@69: * @param timePattern The new time pattern jpayne@69: * @param timePatternLength The length of timePattern, or -1 if null-terminated. jpayne@69: * @param status A pointer to a UErrorCode to receive any errors jpayne@69: * @see udat_toPatternRelativeDate, udat_toPatternRelativeTime jpayne@69: * @internal ICU 4.2 technology preview jpayne@69: */ jpayne@69: U_INTERNAL void U_EXPORT2 jpayne@69: udat_applyPatternRelative(UDateFormat *format, jpayne@69: const UChar *datePattern, jpayne@69: int32_t datePatternLength, jpayne@69: const UChar *timePattern, jpayne@69: int32_t timePatternLength, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * @internal jpayne@69: * @see udat_open jpayne@69: */ jpayne@69: typedef UDateFormat* (U_EXPORT2 *UDateFormatOpener) (UDateFormatStyle timeStyle, jpayne@69: UDateFormatStyle dateStyle, jpayne@69: const char *locale, jpayne@69: const UChar *tzID, jpayne@69: int32_t tzIDLength, jpayne@69: const UChar *pattern, jpayne@69: int32_t patternLength, jpayne@69: UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Register a provider factory jpayne@69: * @internal ICU 49 jpayne@69: */ jpayne@69: U_INTERNAL void U_EXPORT2 jpayne@69: udat_registerOpener(UDateFormatOpener opener, UErrorCode *status); jpayne@69: jpayne@69: /** jpayne@69: * Un-Register a provider factory jpayne@69: * @internal ICU 49 jpayne@69: */ jpayne@69: U_INTERNAL UDateFormatOpener U_EXPORT2 jpayne@69: udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status); jpayne@69: #endif /* U_HIDE_INTERNAL_API */ jpayne@69: jpayne@69: jpayne@69: #endif /* #if !UCONFIG_NO_FORMATTING */ jpayne@69: jpayne@69: #endif