/*
*******************************************************************************
- * Copyright (C) 1996-2015, International Business Machines
+ * Copyright (C) 1996-2016, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
*/
*/
typedef void* UDateFormat;
-/** The possible date/time format styles
+/** The possible date/time format styles
* @stable ICU 2.6
*/
typedef enum UDateFormatStyle {
/** Bitfield for relative date */
UDAT_RELATIVE = (1 << 7),
-
+
UDAT_FULL_RELATIVE = UDAT_FULL | UDAT_RELATIVE,
-
+
UDAT_LONG_RELATIVE = UDAT_LONG | UDAT_RELATIVE,
-
+
UDAT_MEDIUM_RELATIVE = UDAT_MEDIUM | UDAT_RELATIVE,
-
+
UDAT_SHORT_RELATIVE = UDAT_SHORT | UDAT_RELATIVE,
-
-
+
+
/** No style */
UDAT_NONE = -1,
* Used in combinations date + time, date + time + zone, or time + zone.
* @stable ICU 4.0
*/
-#define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd"
+#define UDAT_YEAR_ABBR_MONTH_WEEKDAY_DAY "yMMMEd"
/**
* Constant for date skeleton with year, numeric month, weekday, and day.
* Used in combinations date + time, date + time + zone, or time + zone.
/* deprecated skeleton constants */
-#ifndef U_HIDE_DEPRECATED_API
+#ifndef U_HIDE_DEPRECATED_API
/**
* Constant for date skeleton with standalone month.
* @deprecated ICU 50 Use UDAT_MONTH instead.
* @internal ICU 53
*/
UDAT_RELATED_YEAR_FIELD = 34,
-#endif /* U_HIDE_INTERNAL_API */
+#endif /* U_HIDE_INTERNAL_API */
#ifndef U_HIDE_DRAFT_API
/**
- * FieldPosition and UFieldPosition selector for ':' time separator,
- * no corresponding UCAL_ field.
- * @draft ICU 55
+ * FieldPosition selector for 'b' field alignment.
+ * Displays midnight and noon for 12am and 12pm, respectively, if available;
+ * otherwise fall back to AM / PM.
+ * @draft ICU 57
+ */
+ UDAT_AM_PM_MIDNIGHT_NOON_FIELD = 35,
+
+ /* FieldPosition selector for 'B' field alignment.
+ * Displays flexible day periods, such as "in the morning", if available.
+ * @draft ICU 57
+ */
+ UDAT_FLEXIBLE_DAY_PERIOD_FIELD = 36,
+#endif /* U_HIDE_DRAFT_API */
+
+#ifndef U_HIDE_INTERNAL_API
+ /**
+ * FieldPosition and UFieldPosition selector for time separator,
+ * no corresponding UCAL_ field. No pattern character is currently
+ * defined for this.
+ * @internal
*/
- UDAT_TIME_SEPARATOR_FIELD = 35,
-#endif /* U_HIDE_DRAFT_API */
+ UDAT_TIME_SEPARATOR_FIELD = 37,
+#endif /* U_HIDE_INTERNAL_API */
/**
* Number of FieldPosition and UFieldPosition selectors for
* in the future.
* @stable ICU 3.0
*/
- UDAT_FIELD_COUNT = 36
+ UDAT_FIELD_COUNT = 38
} UDateFormatField;
+#ifndef U_HIDE_INTERNAL_API
+/**
+ * Is a pattern character defined for UDAT_TIME_SEPARATOR_FIELD?
+ * In ICU 55 it was COLON, but that was withdrawn in ICU 56.
+ * @internal ICU 56
+ */
+#define UDAT_HAS_PATTERN_CHAR_FOR_TIME_SEPARATOR 0
+#endif /* U_HIDE_INTERNAL_API */
+
+
/**
* Maps from a UDateFormatField to the corresponding UCalendarDateFields.
* Note: since the mapping is many-to-one, there is no inverse mapping.
* an error occurred.
* @stable ICU 2.0
*/
-U_STABLE UDateFormat* U_EXPORT2
+U_STABLE UDateFormat* U_EXPORT2
udat_open(UDateFormatStyle timeStyle,
UDateFormatStyle dateStyle,
const char *locale,
* @param format The formatter to close.
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_STABLE void U_EXPORT2
udat_close(UDateFormat* format);
/**
* DateFormat boolean attributes
- *
+ *
* @stable ICU 53
*/
typedef enum UDateFormatBooleanAttribute {
#ifndef U_HIDE_DRAFT_API
/**
* indicates tolerance of a partial literal match
- * @draft ICU 53
+ * e.g. accepting "--mon-02-march-2011" for a pattern of "'--: 'EEE-WW-MMMM-yyyy"
+ * @draft ICU 56
+ */
+ UDAT_PARSE_PARTIAL_LITERAL_MATCH = 2,
+ /**
+ * indicates tolerance of pattern mismatch between input data and specified format pattern.
+ * e.g. accepting "September" for a month pattern of MMM ("Sep")
+ * @draft ICU 56
*/
- UDAT_PARSE_PARTIAL_MATCH = 2,
- /**
- * indicates tolerance of pattern mismatch between input data and specified format pattern.
- * e.g. accepting "September" for a month pattern of MMM ("Sep")
- * @draft ICU 53
- */
UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH = 3,
#endif /* U_HIDE_DRAFT_API */
/**
* @return A pointer to a UDateFormat identical to fmt.
* @stable ICU 2.0
*/
-U_STABLE UDateFormat* U_EXPORT2
+U_STABLE UDateFormat* U_EXPORT2
udat_clone(const UDateFormat *fmt,
UErrorCode *status);
* @see UFieldPosition
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
udat_format( const UDateFormat* format,
UDate dateToFormat,
UChar* result,
UFieldPosition* position,
UErrorCode* status);
-#ifndef U_HIDE_DRAFT_API
/**
* Format a date using an UDateFormat.
* The date will be formatted using the conventions specified in {@link #udat_open }
* @see udat_format
* @see udat_parseCalendar
* @see UFieldPosition
-* @draft ICU 55
+* @stable ICU 55
*/
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
udat_formatCalendar( const UDateFormat* format,
UCalendar* calendar,
UChar* result,
* The total buffer size needed; if greater than resultLength, the output was truncated.
* @see udat_parse
* @see UFieldPositionIterator
-* @draft ICU 55
+* @stable ICU 55
*/
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
udat_formatForFields( const UDateFormat* format,
UDate dateToFormat,
UChar* result,
* @see udat_format
* @see udat_parseCalendar
* @see UFieldPositionIterator
-* @draft ICU 55
+* @stable ICU 55
*/
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
udat_formatCalendarForFields( const UDateFormat* format,
UCalendar* calendar,
UChar* result,
UFieldPositionIterator* fpositer,
UErrorCode* status);
-#endif /* U_HIDE_DRAFT_API */
/**
* Parse a string into an date/time using a UDateFormat.
* @see udat_format
* @stable ICU 2.0
*/
-U_STABLE UDate U_EXPORT2
+U_STABLE UDate U_EXPORT2
udat_parse(const UDateFormat* format,
const UChar* text,
int32_t textLength,
* @see udat_format
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_STABLE void U_EXPORT2
udat_parseCalendar(const UDateFormat* format,
UCalendar* calendar,
const UChar* text,
* @see udat_setLenient
* @stable ICU 2.0
*/
-U_STABLE UBool U_EXPORT2
+U_STABLE UBool U_EXPORT2
udat_isLenient(const UDateFormat* fmt);
/**
* @see dat_isLenient
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_STABLE void U_EXPORT2
udat_setLenient( UDateFormat* fmt,
UBool isLenient);
* @see udat_setCalendar
* @stable ICU 2.0
*/
-U_STABLE const UCalendar* U_EXPORT2
+U_STABLE const UCalendar* U_EXPORT2
udat_getCalendar(const UDateFormat* fmt);
/**
* @see udat_setCalendar
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_STABLE void U_EXPORT2
udat_setCalendar( UDateFormat* fmt,
const UCalendar* calendarToSet);
* @see udat_setNumberFormat
* @stable ICU 2.0
*/
-U_STABLE const UNumberFormat* U_EXPORT2
+U_STABLE const UNumberFormat* U_EXPORT2
udat_getNumberFormat(const UDateFormat* fmt);
-#ifndef U_HIDE_DRAFT_API
/**
* Get the UNumberFormat for specific field associated with an UDateFormat.
* For example: 'y' for year and 'M' for month
* @param field the field to query
* @return A pointer to the UNumberFormat used by fmt to format field numbers.
* @see udat_setNumberFormatForField
-* @draft ICU 54
+* @stable ICU 54
*/
-U_DRAFT const UNumberFormat* U_EXPORT2
+U_STABLE const UNumberFormat* U_EXPORT2
udat_getNumberFormatForField(const UDateFormat* fmt, UChar field);
/**
* Set the UNumberFormat for specific field associated with an UDateFormat.
* It can be a single field like: "y"(year) or "M"(month)
* It can be several field combined together: "yM"(year and month)
-* Note:
+* Note:
* 1 symbol field is enough for multiple symbol field (so "y" will override "yy", "yyy")
* If the field is not numeric, then override has no effect (like "MMM" will use abbreviation, not numerical field)
*
* @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to format numbers.
* @param status error code passed around (memory allocation or invalid fields)
* @see udat_getNumberFormatForField
-* @draft ICU 54
+* @stable ICU 54
*/
-U_DRAFT void U_EXPORT2
+U_STABLE void U_EXPORT2
udat_adoptNumberFormatForFields( UDateFormat* fmt,
const UChar* fields,
UNumberFormat* numberFormatToSet,
UErrorCode* status);
-#endif /* U_HIDE_DRAFT_API */
-
/**
* Set the UNumberFormat associated with an UDateFormat.
* A UDateFormat uses a UNumberFormat to format numbers within a date,
* for example the day number.
-* This method also clears per field NumberFormat instances previously
-* set by {@see udat_setNumberFormatForField}
+* This method also clears per field NumberFormat instances previously
+* set by {@see udat_setNumberFormatForField}
* @param fmt The formatter to set.
* @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to format numbers.
* @see udat_getNumberFormat
* @see udat_setNumberFormatForField
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_STABLE void U_EXPORT2
udat_setNumberFormat( UDateFormat* fmt,
const UNumberFormat* numberFormatToSet);
-
-#ifndef U_HIDE_DRAFT_API
/**
* Adopt the UNumberFormat associated with an UDateFormat.
* A UDateFormat uses a UNumberFormat to format numbers within a date,
* @param fmt The formatter to set.
* @param numberFormatToAdopt A pointer to the UNumberFormat to be used by fmt to format numbers.
* @see udat_getNumberFormat
-* @draft ICU 54
+* @stable ICU 54
*/
-U_DRAFT void U_EXPORT2
+U_STABLE void U_EXPORT2
udat_adoptNumberFormat( UDateFormat* fmt,
UNumberFormat* numberFormatToAdopt);
-#endif /* U_HIDE_DRAFT_API */
-
/**
* Get a locale for which date/time formatting patterns are available.
* A UDateFormat in a locale returned by this function will perform the correct
* @see udat_countAvailable
* @stable ICU 2.0
*/
-U_STABLE const char* U_EXPORT2
+U_STABLE const char* U_EXPORT2
udat_getAvailable(int32_t localeIndex);
/**
* @see udat_getAvailable
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
udat_countAvailable(void);
/**
* @see udat_Set2DigitYearStart
* @stable ICU 2.0
*/
-U_STABLE UDate U_EXPORT2
+U_STABLE UDate U_EXPORT2
udat_get2DigitYearStart( const UDateFormat *fmt,
UErrorCode *status);
* @see udat_Set2DigitYearStart
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_STABLE void U_EXPORT2
udat_set2DigitYearStart( UDateFormat *fmt,
UDate d,
UErrorCode *status);
* @see udat_applyPattern
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
udat_toPattern( const UDateFormat *fmt,
UBool localized,
UChar *result,
* @see udat_toPattern
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_STABLE void U_EXPORT2
udat_applyPattern( UDateFormat *format,
UBool localized,
const UChar *pattern,
int32_t patternLength);
-/**
- * The possible types of date format symbols
+/**
+ * The possible types of date format symbols
* @stable ICU 2.6
*/
typedef enum UDateFormatSymbolType {
* Standalone version of UDAT_SHORTER_WEEKDAYS.
* @stable ICU 51
*/
- UDAT_STANDALONE_SHORTER_WEEKDAYS
-#ifndef U_HIDE_DRAFT_API
- ,
+ UDAT_STANDALONE_SHORTER_WEEKDAYS,
/**
* Cyclic year names (only supported for some calendars, and only for FORMAT usage;
* udat_setSymbols not supported for UDAT_CYCLIC_YEARS_WIDE)
- * @draft ICU 54
+ * @stable ICU 54
*/
UDAT_CYCLIC_YEARS_WIDE,
/**
* Cyclic year names (only supported for some calendars, and only for FORMAT usage)
- * @draft ICU 54
+ * @stable ICU 54
*/
UDAT_CYCLIC_YEARS_ABBREVIATED,
/**
* Cyclic year names (only supported for some calendars, and only for FORMAT usage;
* udat_setSymbols not supported for UDAT_CYCLIC_YEARS_NARROW)
- * @draft ICU 54
+ * @stable ICU 54
*/
UDAT_CYCLIC_YEARS_NARROW,
/**
* Calendar zodiac names (only supported for some calendars, and only for FORMAT usage;
* udat_setSymbols not supported for UDAT_ZODIAC_NAMES_WIDE)
- * @draft ICU 54
+ * @stable ICU 54
*/
UDAT_ZODIAC_NAMES_WIDE,
/**
* Calendar zodiac names (only supported for some calendars, and only for FORMAT usage)
- * @draft ICU 54
+ * @stable ICU 54
*/
UDAT_ZODIAC_NAMES_ABBREVIATED,
/**
* Calendar zodiac names (only supported for some calendars, and only for FORMAT usage;
* udat_setSymbols not supported for UDAT_ZODIAC_NAMES_NARROW)
- * @draft ICU 54
+ * @stable ICU 54
*/
UDAT_ZODIAC_NAMES_NARROW
-#endif /* U_HIDE_DRAFT_API */
#ifndef U_HIDE_INTERNAL_API
,
/**
* @see udat_setSymbols
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
udat_getSymbols(const UDateFormat *fmt,
UDateFormatSymbolType type,
int32_t symbolIndex,
* @see udat_setSymbols
* @stable ICU 2.0
*/
-U_STABLE int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
udat_countSymbols( const UDateFormat *fmt,
UDateFormatSymbolType type);
* @see udat_countSymbols
* @stable ICU 2.0
*/
-U_STABLE void U_EXPORT2
+U_STABLE void U_EXPORT2
udat_setSymbols( UDateFormat *format,
UDateFormatSymbolType type,
int32_t symbolIndex,
* Get the locale for this date format object.
* You can choose between valid and actual locale.
* @param fmt The formatter to get the locale from
- * @param type type of the locale we're looking for (valid or actual)
+ * @param type type of the locale we're looking for (valid or actual)
* @param status error code for the operation
* @return the locale name
* @stable ICU 2.8
U_STABLE const char* U_EXPORT2
udat_getLocaleByType(const UDateFormat *fmt,
ULocDataLocaleType type,
- UErrorCode* status);
+ UErrorCode* status);
/**
* Set a particular UDisplayContext value in the formatter, such as
* @see udat_applyPatternRelative
* @internal ICU 4.2 technology preview
*/
-U_INTERNAL int32_t U_EXPORT2
+U_INTERNAL int32_t U_EXPORT2
udat_toPatternRelativeDate(const UDateFormat *fmt,
UChar *result,
int32_t resultLength,
* @see udat_applyPatternRelative
* @internal ICU 4.2 technology preview
*/
-U_INTERNAL int32_t U_EXPORT2
+U_INTERNAL int32_t U_EXPORT2
udat_toPatternRelativeTime(const UDateFormat *fmt,
UChar *result,
int32_t resultLength,
* @see udat_toPatternRelativeDate, udat_toPatternRelativeTime
* @internal ICU 4.2 technology preview
*/
-U_INTERNAL void U_EXPORT2
+U_INTERNAL void U_EXPORT2
udat_applyPatternRelative(UDateFormat *format,
const UChar *datePattern,
int32_t datePatternLength,