| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * Copyright (C) 1996-2014, International Business Machines | 3 * Copyright (C) 1996-2015, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
| 5 ******************************************************************************* | 5 ******************************************************************************* |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef UDAT_H | 8 #ifndef UDAT_H |
| 9 #define UDAT_H | 9 #define UDAT_H |
| 10 | 10 |
| 11 #include "unicode/utypes.h" | 11 #include "unicode/utypes.h" |
| 12 | 12 |
| 13 #if !UCONFIG_NO_FORMATTING | 13 #if !UCONFIG_NO_FORMATTING |
| 14 | 14 |
| 15 #include "unicode/localpointer.h" | 15 #include "unicode/localpointer.h" |
| 16 #include "unicode/ucal.h" | 16 #include "unicode/ucal.h" |
| 17 #include "unicode/unum.h" | 17 #include "unicode/unum.h" |
| 18 #include "unicode/udisplaycontext.h" | 18 #include "unicode/udisplaycontext.h" |
| 19 #include "unicode/ufieldpositer.h" |
| 19 /** | 20 /** |
| 20 * \file | 21 * \file |
| 21 * \brief C API: DateFormat | 22 * \brief C API: DateFormat |
| 22 * | 23 * |
| 23 * <h2> Date Format C API</h2> | 24 * <h2> Date Format C API</h2> |
| 24 * | 25 * |
| 25 * Date Format C API consists of functions that convert dates and | 26 * Date Format C API consists of functions that convert dates and |
| 26 * times from their internal representations to textual form and back again in a | 27 * times from their internal representations to textual form and back again in a |
| 27 * language-independent manner. Converting from the internal representation (mil
liseconds | 28 * language-independent manner. Converting from the internal representation (mil
liseconds |
| 28 * since midnight, January 1, 1970) to text is known as "formatting," and conver
ting | 29 * since midnight, January 1, 1970) to text is known as "formatting," and conver
ting |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 | 754 |
| 754 #ifndef U_HIDE_INTERNAL_API | 755 #ifndef U_HIDE_INTERNAL_API |
| 755 /** | 756 /** |
| 756 * FieldPosition and UFieldPosition selector for 'r' field alignment, | 757 * FieldPosition and UFieldPosition selector for 'r' field alignment, |
| 757 * no directly corresponding UCAL_ field. | 758 * no directly corresponding UCAL_ field. |
| 758 * @internal ICU 53 | 759 * @internal ICU 53 |
| 759 */ | 760 */ |
| 760 UDAT_RELATED_YEAR_FIELD = 34, | 761 UDAT_RELATED_YEAR_FIELD = 34, |
| 761 #endif /* U_HIDE_INTERNAL_API */ | 762 #endif /* U_HIDE_INTERNAL_API */ |
| 762 | 763 |
| 764 #ifndef U_HIDE_DRAFT_API |
| 765 /** |
| 766 * FieldPosition and UFieldPosition selector for time separator, |
| 767 * no corresponding UCAL_ field. No pattern character is currently |
| 768 * defined for this. |
| 769 * @draft ICU 55 |
| 770 */ |
| 771 UDAT_TIME_SEPARATOR_FIELD = 35, |
| 772 #endif /* U_HIDE_DRAFT_API */ |
| 773 |
| 763 /** | 774 /** |
| 764 * Number of FieldPosition and UFieldPosition selectors for | 775 * Number of FieldPosition and UFieldPosition selectors for |
| 765 * DateFormat and UDateFormat. | 776 * DateFormat and UDateFormat. |
| 766 * Valid selectors range from 0 to UDAT_FIELD_COUNT-1. | 777 * Valid selectors range from 0 to UDAT_FIELD_COUNT-1. |
| 767 * This value is subject to change if new fields are defined | 778 * This value is subject to change if new fields are defined |
| 768 * in the future. | 779 * in the future. |
| 769 * @stable ICU 3.0 | 780 * @stable ICU 3.0 |
| 770 */ | 781 */ |
| 771 UDAT_FIELD_COUNT = 35 | 782 UDAT_FIELD_COUNT = 36 |
| 772 | 783 |
| 773 } UDateFormatField; | 784 } UDateFormatField; |
| 774 | 785 |
| 775 | 786 |
| 787 #ifndef U_HIDE_INTERNAL_API |
| 788 /** |
| 789 * Is a pattern character defined for UDAT_TIME_SEPARATOR_FIELD? |
| 790 * In ICU 55 it was COLON, but that was withdrawn in ICU 56. |
| 791 * @internal ICU 56 |
| 792 */ |
| 793 #define UDAT_HAS_PATTERN_CHAR_FOR_TIME_SEPARATOR 0 |
| 794 #endif /* U_HIDE_INTERNAL_API */ |
| 795 |
| 796 |
| 776 /** | 797 /** |
| 777 * Maps from a UDateFormatField to the corresponding UCalendarDateFields. | 798 * Maps from a UDateFormatField to the corresponding UCalendarDateFields. |
| 778 * Note: since the mapping is many-to-one, there is no inverse mapping. | 799 * Note: since the mapping is many-to-one, there is no inverse mapping. |
| 779 * @param field the UDateFormatField. | 800 * @param field the UDateFormatField. |
| 780 * @return the UCalendarDateField. This will be UCAL_FIELD_COUNT in case | 801 * @return the UCalendarDateField. This will be UCAL_FIELD_COUNT in case |
| 781 * of error (e.g., the input field is UDAT_FIELD_COUNT). | 802 * of error (e.g., the input field is UDAT_FIELD_COUNT). |
| 782 * @stable ICU 4.4 | 803 * @stable ICU 4.4 |
| 783 */ | 804 */ |
| 784 U_STABLE UCalendarDateFields U_EXPORT2 | 805 U_STABLE UCalendarDateFields U_EXPORT2 |
| 785 udat_toCalendarDateField(UDateFormatField field); | 806 udat_toCalendarDateField(UDateFormatField field); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 /** | 848 /** |
| 828 * Close a UDateFormat. | 849 * Close a UDateFormat. |
| 829 * Once closed, a UDateFormat may no longer be used. | 850 * Once closed, a UDateFormat may no longer be used. |
| 830 * @param format The formatter to close. | 851 * @param format The formatter to close. |
| 831 * @stable ICU 2.0 | 852 * @stable ICU 2.0 |
| 832 */ | 853 */ |
| 833 U_STABLE void U_EXPORT2 | 854 U_STABLE void U_EXPORT2 |
| 834 udat_close(UDateFormat* format); | 855 udat_close(UDateFormat* format); |
| 835 | 856 |
| 836 | 857 |
| 837 /* Dont hide UDateFormatBooleanAttribute type with #ifndef U_HIDE_DRAFT_API, nee
ded by virtual methods */ | |
| 838 /* Also don't hide UDAT_BOOLEAN_ATTRIBUTE_COUNT, needed by template class EnumSe
t<UDateFormatBooleanAttribute,...> */ | |
| 839 /** | 858 /** |
| 840 * DateFormat boolean attributes | 859 * DateFormat boolean attributes |
| 841 * | 860 * |
| 842 * @draft ICU 53 | 861 * @stable ICU 53 |
| 843 */ | 862 */ |
| 844 typedef enum UDateFormatBooleanAttribute { | 863 typedef enum UDateFormatBooleanAttribute { |
| 845 #ifndef U_HIDE_DRAFT_API | |
| 846 /** | 864 /** |
| 847 * indicates whether whitespace is allowed. Includes trailing dot tolerance. | 865 * indicates whether whitespace is allowed. Includes trailing dot tolerance. |
| 848 * @draft ICU 53 | 866 * @stable ICU 53 |
| 849 */ | 867 */ |
| 850 UDAT_PARSE_ALLOW_WHITESPACE = 0, | 868 UDAT_PARSE_ALLOW_WHITESPACE = 0, |
| 851 /** | 869 /** |
| 852 * indicates tolerance of numeric data when String data may be assumed. eg:
UDAT_YEAR_NAME_FIELD, | 870 * indicates tolerance of numeric data when String data may be assumed. eg:
UDAT_YEAR_NAME_FIELD, |
| 853 * UDAT_STANDALONE_MONTH_FIELD, UDAT_DAY_OF_WEEK_FIELD | 871 * UDAT_STANDALONE_MONTH_FIELD, UDAT_DAY_OF_WEEK_FIELD |
| 854 * @draft ICU 53 | 872 * @stable ICU 53 |
| 855 */ | 873 */ |
| 856 UDAT_PARSE_ALLOW_NUMERIC = 1, | 874 UDAT_PARSE_ALLOW_NUMERIC = 1, |
| 875 #ifndef U_HIDE_DRAFT_API |
| 857 /** | 876 /** |
| 858 * indicates tolerance of a partial literal match | 877 * indicates tolerance of a partial literal match |
| 859 * @draft ICU 53 | 878 * e.g. accepting "--mon-02-march-2011" for a pattern of "'--: 'EEE-WW-MMMM-
yyyy" |
| 879 * @draft ICU 56 |
| 860 */ | 880 */ |
| 861 UDAT_PARSE_PARTIAL_MATCH = 2, | 881 UDAT_PARSE_PARTIAL_LITERAL_MATCH = 2, |
| 862 /** | 882 /** |
| 863 * indicates tolerance of pattern mismatch between input data and specified
format pattern. | 883 * indicates tolerance of pattern mismatch between input data and specified
format pattern. |
| 864 * e.g. accepting "September" for a month pattern of MMM ("Sep") | 884 * e.g. accepting "September" for a month pattern of MMM ("Sep") |
| 865 * @draft ICU 53 | 885 * @draft ICU 56 |
| 866 */ | 886 */ |
| 867 UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH = 3, | 887 UDAT_PARSE_MULTIPLE_PATTERNS_FOR_MATCH = 3, |
| 868 #endif /* U_HIDE_DRAFT_API */ | 888 #endif /* U_HIDE_DRAFT_API */ |
| 869 /** | 889 /** |
| 870 * count boolean date format constants | 890 * count boolean date format constants |
| 871 * @draft ICU 53 | 891 * @stable ICU 53 |
| 872 */ | 892 */ |
| 873 UDAT_BOOLEAN_ATTRIBUTE_COUNT = 4 | 893 UDAT_BOOLEAN_ATTRIBUTE_COUNT = 4 |
| 874 } UDateFormatBooleanAttribute; | 894 } UDateFormatBooleanAttribute; |
| 875 | 895 |
| 876 #ifndef U_HIDE_DRAFT_API | |
| 877 /** | 896 /** |
| 878 * Get a boolean attribute associated with a UDateFormat. | 897 * Get a boolean attribute associated with a UDateFormat. |
| 879 * An example would be a true value for a key of UDAT_PARSE_ALLOW_WHITESPACE ind
icating allowing whitespace leniency. | 898 * An example would be a true value for a key of UDAT_PARSE_ALLOW_WHITESPACE ind
icating allowing whitespace leniency. |
| 880 * If the formatter does not understand the attribute, -1 is returned. | 899 * If the formatter does not understand the attribute, -1 is returned. |
| 881 * @param fmt The formatter to query. | 900 * @param fmt The formatter to query. |
| 882 * @param attr The attribute to query; e.g. UDAT_PARSE_ALLOW_WHITESPACE. | 901 * @param attr The attribute to query; e.g. UDAT_PARSE_ALLOW_WHITESPACE. |
| 883 * @param status A pointer to an UErrorCode to receive any errors | 902 * @param status A pointer to an UErrorCode to receive any errors |
| 884 * @return The value of attr. | 903 * @return The value of attr. |
| 885 * @draft ICU 53 | 904 * @stable ICU 53 |
| 886 */ | 905 */ |
| 887 U_DRAFT UBool U_EXPORT2 | 906 U_STABLE UBool U_EXPORT2 |
| 888 udat_getBooleanAttribute(const UDateFormat* fmt, UDateFormatBooleanAttribute att
r, UErrorCode* status); | 907 udat_getBooleanAttribute(const UDateFormat* fmt, UDateFormatBooleanAttribute att
r, UErrorCode* status); |
| 889 | 908 |
| 890 /** | 909 /** |
| 891 * Set a boolean attribute associated with a UDateFormat. | 910 * Set a boolean attribute associated with a UDateFormat. |
| 892 * An example of a boolean attribute is parse leniency control. If the formatte
r does not understand | 911 * An example of a boolean attribute is parse leniency control. If the formatte
r does not understand |
| 893 * the attribute, the call is ignored. | 912 * the attribute, the call is ignored. |
| 894 * @param fmt The formatter to set. | 913 * @param fmt The formatter to set. |
| 895 * @param attr The attribute to set; one of UDAT_PARSE_ALLOW_WHITESPACE or UDAT_
PARSE_ALLOW_NUMERIC | 914 * @param attr The attribute to set; one of UDAT_PARSE_ALLOW_WHITESPACE or UDAT_
PARSE_ALLOW_NUMERIC |
| 896 * @param newValue The new value of attr. | 915 * @param newValue The new value of attr. |
| 897 * @param status A pointer to an UErrorCode to receive any errors | 916 * @param status A pointer to an UErrorCode to receive any errors |
| 898 * @draft ICU 53 | 917 * @stable ICU 53 |
| 899 */ | 918 */ |
| 900 U_DRAFT void U_EXPORT2 | 919 U_STABLE void U_EXPORT2 |
| 901 udat_setBooleanAttribute(UDateFormat *fmt, UDateFormatBooleanAttribute attr, UBo
ol newValue, UErrorCode* status); | 920 udat_setBooleanAttribute(UDateFormat *fmt, UDateFormatBooleanAttribute attr, UBo
ol newValue, UErrorCode* status); |
| 902 | 921 |
| 903 #endif /* U_HIDE_DRAFT_API */ | |
| 904 | |
| 905 | 922 |
| 906 | 923 |
| 907 #if U_SHOW_CPLUSPLUS_API | 924 #if U_SHOW_CPLUSPLUS_API |
| 908 | 925 |
| 909 U_NAMESPACE_BEGIN | 926 U_NAMESPACE_BEGIN |
| 910 | 927 |
| 911 /** | 928 /** |
| 912 * \class LocalUDateFormatPointer | 929 * \class LocalUDateFormatPointer |
| 913 * "Smart pointer" class, closes a UDateFormat via udat_close(). | 930 * "Smart pointer" class, closes a UDateFormat via udat_close(). |
| 914 * For most methods see the LocalPointerBase base class. | 931 * For most methods see the LocalPointerBase base class. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 929 * @param fmt The format to copy | 946 * @param fmt The format to copy |
| 930 * @param status A pointer to an UErrorCode to receive any errors. | 947 * @param status A pointer to an UErrorCode to receive any errors. |
| 931 * @return A pointer to a UDateFormat identical to fmt. | 948 * @return A pointer to a UDateFormat identical to fmt. |
| 932 * @stable ICU 2.0 | 949 * @stable ICU 2.0 |
| 933 */ | 950 */ |
| 934 U_STABLE UDateFormat* U_EXPORT2 | 951 U_STABLE UDateFormat* U_EXPORT2 |
| 935 udat_clone(const UDateFormat *fmt, | 952 udat_clone(const UDateFormat *fmt, |
| 936 UErrorCode *status); | 953 UErrorCode *status); |
| 937 | 954 |
| 938 /** | 955 /** |
| 939 * Format a date using an UDateFormat. | 956 * Format a date using a UDateFormat. |
| 940 * The date will be formatted using the conventions specified in {@link #udat_ope
n } | 957 * The date will be formatted using the conventions specified in {@link #udat_ope
n } |
| 941 * @param format The formatter to use | 958 * @param format The formatter to use |
| 942 * @param dateToFormat The date to format | 959 * @param dateToFormat The date to format |
| 943 * @param result A pointer to a buffer to receive the formatted number. | 960 * @param result A pointer to a buffer to receive the formatted number. |
| 944 * @param resultLength The maximum size of result. | 961 * @param resultLength The maximum size of result. |
| 945 * @param position A pointer to a UFieldPosition. On input, position->field | 962 * @param position A pointer to a UFieldPosition. On input, position->field |
| 946 * is read. On output, position->beginIndex and position->endIndex indicate | 963 * is read. On output, position->beginIndex and position->endIndex indicate |
| 947 * the beginning and ending indices of field number position->field, if such | 964 * the beginning and ending indices of field number position->field, if such |
| 948 * a field exists. This parameter may be NULL, in which case no field | 965 * a field exists. This parameter may be NULL, in which case no field |
| 949 * position data is returned. | 966 * position data is returned. |
| 950 * @param status A pointer to an UErrorCode to receive any errors | 967 * @param status A pointer to an UErrorCode to receive any errors |
| 951 * @return The total buffer size needed; if greater than resultLength, the output
was truncated. | 968 * @return The total buffer size needed; if greater than resultLength, the output
was truncated. |
| 952 * @see udat_parse | 969 * @see udat_parse |
| 953 * @see UFieldPosition | 970 * @see UFieldPosition |
| 954 * @stable ICU 2.0 | 971 * @stable ICU 2.0 |
| 955 */ | 972 */ |
| 956 U_STABLE int32_t U_EXPORT2 | 973 U_STABLE int32_t U_EXPORT2 |
| 957 udat_format( const UDateFormat* format, | 974 udat_format( const UDateFormat* format, |
| 958 UDate dateToFormat, | 975 UDate dateToFormat, |
| 959 UChar* result, | 976 UChar* result, |
| 960 int32_t resultLength, | 977 int32_t resultLength, |
| 961 UFieldPosition* position, | 978 UFieldPosition* position, |
| 962 UErrorCode* status); | 979 UErrorCode* status); |
| 963 | 980 |
| 981 #ifndef U_HIDE_DRAFT_API |
| 982 /** |
| 983 * Format a date using an UDateFormat. |
| 984 * The date will be formatted using the conventions specified in {@link #udat_ope
n } |
| 985 * @param format The formatter to use |
| 986 * @param calendar The calendar to format. The calendar instance might be |
| 987 * mutated if fields are not yet fully calculated, though |
| 988 * the function won't change the logical date and time held |
| 989 * by the instance. |
| 990 * @param result A pointer to a buffer to receive the formatted number. |
| 991 * @param capacity The maximum size of result. |
| 992 * @param position A pointer to a UFieldPosition. On input, position->field |
| 993 * is read. On output, position->beginIndex and position->endIndex indicate |
| 994 * the beginning and ending indices of field number position->field, if such |
| 995 * a field exists. This parameter may be NULL, in which case no field |
| 996 * position data is returned. |
| 997 * @param status A pointer to an UErrorCode to receive any errors |
| 998 * @return The total buffer size needed; if greater than resultLength, the output
was truncated. |
| 999 * @see udat_format |
| 1000 * @see udat_parseCalendar |
| 1001 * @see UFieldPosition |
| 1002 * @draft ICU 55 |
| 1003 */ |
| 1004 U_DRAFT int32_t U_EXPORT2 |
| 1005 udat_formatCalendar( const UDateFormat* format, |
| 1006 UCalendar* calendar, |
| 1007 UChar* result, |
| 1008 int32_t capacity, |
| 1009 UFieldPosition* position, |
| 1010 UErrorCode* status); |
| 1011 |
| 964 /** | 1012 /** |
| 1013 * Format a date using a UDateFormat. |
| 1014 * The date will be formatted using the conventions specified in {@link #udat_ope
n} |
| 1015 * @param format |
| 1016 * The formatter to use |
| 1017 * @param dateToFormat |
| 1018 * The date to format |
| 1019 * @param result |
| 1020 * A pointer to a buffer to receive the formatted number. |
| 1021 * @param resultLength |
| 1022 * The maximum size of result. |
| 1023 * @param fpositer |
| 1024 * A pointer to a UFieldPositionIterator created by {@link #ufieldposite
r_open} |
| 1025 * (may be NULL if field position information is not needed). Any |
| 1026 * iteration information already present in the UFieldPositionIterator |
| 1027 * will be deleted, and the iterator will be reset to apply to the |
| 1028 * fields in the formatted string created by this function call; the |
| 1029 * field values provided by {@link #ufieldpositer_next} will be from the |
| 1030 * UDateFormatField enum. |
| 1031 * @param status |
| 1032 * A pointer to a UErrorCode to receive any errors |
| 1033 * @return |
| 1034 * The total buffer size needed; if greater than resultLength, the outpu
t was truncated. |
| 1035 * @see udat_parse |
| 1036 * @see UFieldPositionIterator |
| 1037 * @draft ICU 55 |
| 1038 */ |
| 1039 U_DRAFT int32_t U_EXPORT2 |
| 1040 udat_formatForFields( const UDateFormat* format, |
| 1041 UDate dateToFormat, |
| 1042 UChar* result, |
| 1043 int32_t resultLength, |
| 1044 UFieldPositionIterator* fpositer, |
| 1045 UErrorCode* status); |
| 1046 |
| 1047 /** |
| 1048 * Format a date using a UDateFormat. |
| 1049 * The date will be formatted using the conventions specified in {@link #udat_ope
n } |
| 1050 * @param format |
| 1051 * The formatter to use |
| 1052 * @param calendar |
| 1053 * The calendar to format. The calendar instance might be mutated if fie
lds |
| 1054 * are not yet fully calculated, though the function won't change the lo
gical |
| 1055 * date and time held by the instance. |
| 1056 * @param result |
| 1057 * A pointer to a buffer to receive the formatted number. |
| 1058 * @param capacity |
| 1059 * The maximum size of result. |
| 1060 * @param fpositer |
| 1061 * A pointer to a UFieldPositionIterator created by {@link #ufieldposite
r_open} |
| 1062 * (may be NULL if field position information is not needed). Any |
| 1063 * iteration information already present in the UFieldPositionIterator |
| 1064 * will be deleted, and the iterator will be reset to apply to the |
| 1065 * fields in the formatted string created by this function call; the |
| 1066 * field values provided by {@link #ufieldpositer_next} will be from the |
| 1067 * UDateFormatField enum. |
| 1068 * @param status |
| 1069 * A pointer to a UErrorCode to receive any errors |
| 1070 * @return |
| 1071 * The total buffer size needed; if greater than resultLength, the outpu
t was truncated. |
| 1072 * @see udat_format |
| 1073 * @see udat_parseCalendar |
| 1074 * @see UFieldPositionIterator |
| 1075 * @draft ICU 55 |
| 1076 */ |
| 1077 U_DRAFT int32_t U_EXPORT2 |
| 1078 udat_formatCalendarForFields( const UDateFormat* format, |
| 1079 UCalendar* calendar, |
| 1080 UChar* result, |
| 1081 int32_t capacity, |
| 1082 UFieldPositionIterator* fpositer, |
| 1083 UErrorCode* status); |
| 1084 |
| 1085 #endif /* U_HIDE_DRAFT_API */ |
| 1086 |
| 1087 /** |
| 965 * Parse a string into an date/time using a UDateFormat. | 1088 * Parse a string into an date/time using a UDateFormat. |
| 966 * The date will be parsed using the conventions specified in {@link #udat_open }
. | 1089 * The date will be parsed using the conventions specified in {@link #udat_open }
. |
| 967 * <P> | 1090 * <P> |
| 968 * Note that the normal date formats associated with some calendars - such | 1091 * Note that the normal date formats associated with some calendars - such |
| 969 * as the Chinese lunar calendar - do not specify enough fields to enable | 1092 * as the Chinese lunar calendar - do not specify enough fields to enable |
| 970 * dates to be parsed unambiguously. In the case of the Chinese lunar | 1093 * dates to be parsed unambiguously. In the case of the Chinese lunar |
| 971 * calendar, while the year within the current 60-year cycle is specified, | 1094 * calendar, while the year within the current 60-year cycle is specified, |
| 972 * the number of such cycles since the start date of the calendar (in the | 1095 * the number of such cycles since the start date of the calendar (in the |
| 973 * UCAL_ERA field of the UCalendar object) is not normally part of the format, | 1096 * UCAL_ERA field of the UCalendar object) is not normally part of the format, |
| 974 * and parsing may assume the wrong era. For cases such as this it is | 1097 * and parsing may assume the wrong era. For cases such as this it is |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 * A UDateFormat uses a UNumberFormat to format numbers within a date, | 1200 * A UDateFormat uses a UNumberFormat to format numbers within a date, |
| 1078 * for example the day number. | 1201 * for example the day number. |
| 1079 * @param fmt The formatter to query. | 1202 * @param fmt The formatter to query. |
| 1080 * @return A pointer to the UNumberFormat used by fmt to format numbers. | 1203 * @return A pointer to the UNumberFormat used by fmt to format numbers. |
| 1081 * @see udat_setNumberFormat | 1204 * @see udat_setNumberFormat |
| 1082 * @stable ICU 2.0 | 1205 * @stable ICU 2.0 |
| 1083 */ | 1206 */ |
| 1084 U_STABLE const UNumberFormat* U_EXPORT2 | 1207 U_STABLE const UNumberFormat* U_EXPORT2 |
| 1085 udat_getNumberFormat(const UDateFormat* fmt); | 1208 udat_getNumberFormat(const UDateFormat* fmt); |
| 1086 | 1209 |
| 1087 #ifndef U_HIDE_DRAFT_API | |
| 1088 /** | 1210 /** |
| 1089 * Get the UNumberFormat for specific field associated with an UDateFormat. | 1211 * Get the UNumberFormat for specific field associated with an UDateFormat. |
| 1090 * For example: 'y' for year and 'M' for month | 1212 * For example: 'y' for year and 'M' for month |
| 1091 * @param fmt The formatter to query. | 1213 * @param fmt The formatter to query. |
| 1092 * @param field the field to query | 1214 * @param field the field to query |
| 1093 * @return A pointer to the UNumberFormat used by fmt to format field numbers. | 1215 * @return A pointer to the UNumberFormat used by fmt to format field numbers. |
| 1094 * @see udat_setNumberFormatForField | 1216 * @see udat_setNumberFormatForField |
| 1095 * @draft ICU 54 | 1217 * @stable ICU 54 |
| 1096 */ | 1218 */ |
| 1097 U_DRAFT const UNumberFormat* U_EXPORT2 | 1219 U_STABLE const UNumberFormat* U_EXPORT2 |
| 1098 udat_getNumberFormatForField(const UDateFormat* fmt, UChar field); | 1220 udat_getNumberFormatForField(const UDateFormat* fmt, UChar field); |
| 1099 | 1221 |
| 1100 /** | 1222 /** |
| 1101 * Set the UNumberFormat for specific field associated with an UDateFormat. | 1223 * Set the UNumberFormat for specific field associated with an UDateFormat. |
| 1102 * It can be a single field like: "y"(year) or "M"(month) | 1224 * It can be a single field like: "y"(year) or "M"(month) |
| 1103 * It can be several field combined together: "yM"(year and month) | 1225 * It can be several field combined together: "yM"(year and month) |
| 1104 * Note: | 1226 * Note: |
| 1105 * 1 symbol field is enough for multiple symbol field (so "y" will override "yy",
"yyy") | 1227 * 1 symbol field is enough for multiple symbol field (so "y" will override "yy",
"yyy") |
| 1106 * If the field is not numeric, then override has no effect (like "MMM" will use
abbreviation, not numerical field) | 1228 * If the field is not numeric, then override has no effect (like "MMM" will use
abbreviation, not numerical field) |
| 1107 * | 1229 * |
| 1108 * @param fields the fields to set | 1230 * @param fields the fields to set |
| 1109 * @param fmt The formatter to set. | 1231 * @param fmt The formatter to set. |
| 1110 * @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to f
ormat numbers. | 1232 * @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to f
ormat numbers. |
| 1111 * @param status error code passed around (memory allocation or invalid fields) | 1233 * @param status error code passed around (memory allocation or invalid fields) |
| 1112 * @see udat_getNumberFormatForField | 1234 * @see udat_getNumberFormatForField |
| 1113 * @draft ICU 54 | 1235 * @stable ICU 54 |
| 1114 */ | 1236 */ |
| 1115 U_DRAFT void U_EXPORT2 | 1237 U_STABLE void U_EXPORT2 |
| 1116 udat_adoptNumberFormatForFields( UDateFormat* fmt, | 1238 udat_adoptNumberFormatForFields( UDateFormat* fmt, |
| 1117 const UChar* fields, | 1239 const UChar* fields, |
| 1118 UNumberFormat* numberFormatToSet, | 1240 UNumberFormat* numberFormatToSet, |
| 1119 UErrorCode* status); | 1241 UErrorCode* status); |
| 1120 #endif /* U_HIDE_DRAFT_API */ | |
| 1121 | |
| 1122 /** | 1242 /** |
| 1123 * Set the UNumberFormat associated with an UDateFormat. | 1243 * Set the UNumberFormat associated with an UDateFormat. |
| 1124 * A UDateFormat uses a UNumberFormat to format numbers within a date, | 1244 * A UDateFormat uses a UNumberFormat to format numbers within a date, |
| 1125 * for example the day number. | 1245 * for example the day number. |
| 1126 * This method also clears per field NumberFormat instances previously | 1246 * This method also clears per field NumberFormat instances previously |
| 1127 * set by {@see udat_setNumberFormatForField} | 1247 * set by {@see udat_setNumberFormatForField} |
| 1128 * @param fmt The formatter to set. | 1248 * @param fmt The formatter to set. |
| 1129 * @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to f
ormat numbers. | 1249 * @param numberFormatToSet A pointer to the UNumberFormat to be used by fmt to f
ormat numbers. |
| 1130 * @see udat_getNumberFormat | 1250 * @see udat_getNumberFormat |
| 1131 * @see udat_setNumberFormatForField | 1251 * @see udat_setNumberFormatForField |
| 1132 * @stable ICU 2.0 | 1252 * @stable ICU 2.0 |
| 1133 */ | 1253 */ |
| 1134 U_STABLE void U_EXPORT2 | 1254 U_STABLE void U_EXPORT2 |
| 1135 udat_setNumberFormat( UDateFormat* fmt, | 1255 udat_setNumberFormat( UDateFormat* fmt, |
| 1136 const UNumberFormat* numberFormatToSet); | 1256 const UNumberFormat* numberFormatToSet); |
| 1137 | |
| 1138 #ifndef U_HIDE_DRAFT_API | |
| 1139 /** | 1257 /** |
| 1140 * Adopt the UNumberFormat associated with an UDateFormat. | 1258 * Adopt the UNumberFormat associated with an UDateFormat. |
| 1141 * A UDateFormat uses a UNumberFormat to format numbers within a date, | 1259 * A UDateFormat uses a UNumberFormat to format numbers within a date, |
| 1142 * for example the day number. | 1260 * for example the day number. |
| 1143 * @param fmt The formatter to set. | 1261 * @param fmt The formatter to set. |
| 1144 * @param numberFormatToAdopt A pointer to the UNumberFormat to be used by fmt to
format numbers. | 1262 * @param numberFormatToAdopt A pointer to the UNumberFormat to be used by fmt to
format numbers. |
| 1145 * @see udat_getNumberFormat | 1263 * @see udat_getNumberFormat |
| 1146 * @draft ICU 54 | 1264 * @stable ICU 54 |
| 1147 */ | 1265 */ |
| 1148 U_DRAFT void U_EXPORT2 | 1266 U_STABLE void U_EXPORT2 |
| 1149 udat_adoptNumberFormat( UDateFormat* fmt, | 1267 udat_adoptNumberFormat( UDateFormat* fmt, |
| 1150 UNumberFormat* numberFormatToAdopt); | 1268 UNumberFormat* numberFormatToAdopt); |
| 1151 #endif /* U_HIDE_DRAFT_API */ | |
| 1152 | |
| 1153 /** | 1269 /** |
| 1154 * Get a locale for which date/time formatting patterns are available. | 1270 * Get a locale for which date/time formatting patterns are available. |
| 1155 * A UDateFormat in a locale returned by this function will perform the correct | 1271 * A UDateFormat in a locale returned by this function will perform the correct |
| 1156 * formatting and parsing for the locale. | 1272 * formatting and parsing for the locale. |
| 1157 * @param localeIndex The index of the desired locale. | 1273 * @param localeIndex The index of the desired locale. |
| 1158 * @return A locale for which date/time formatting patterns are available, or 0 i
f none. | 1274 * @return A locale for which date/time formatting patterns are available, or 0 i
f none. |
| 1159 * @see udat_countAvailable | 1275 * @see udat_countAvailable |
| 1160 * @stable ICU 2.0 | 1276 * @stable ICU 2.0 |
| 1161 */ | 1277 */ |
| 1162 U_STABLE const char* U_EXPORT2 | 1278 U_STABLE const char* U_EXPORT2 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 * These are named "SHORTER" to contrast with the constants using _SHORT_ | 1406 * These are named "SHORTER" to contrast with the constants using _SHORT_ |
| 1291 * above, which actually get the CLDR-style *abbreviated* versions of the | 1407 * above, which actually get the CLDR-style *abbreviated* versions of the |
| 1292 * corresponding names. | 1408 * corresponding names. |
| 1293 * @stable ICU 51 | 1409 * @stable ICU 51 |
| 1294 */ | 1410 */ |
| 1295 UDAT_SHORTER_WEEKDAYS, | 1411 UDAT_SHORTER_WEEKDAYS, |
| 1296 /** | 1412 /** |
| 1297 * Standalone version of UDAT_SHORTER_WEEKDAYS. | 1413 * Standalone version of UDAT_SHORTER_WEEKDAYS. |
| 1298 * @stable ICU 51 | 1414 * @stable ICU 51 |
| 1299 */ | 1415 */ |
| 1300 UDAT_STANDALONE_SHORTER_WEEKDAYS | 1416 UDAT_STANDALONE_SHORTER_WEEKDAYS, |
| 1301 #ifndef U_HIDE_DRAFT_API | 1417 /** |
| 1302 , | 1418 * Cyclic year names (only supported for some calendars, and only for FORMAT
usage; |
| 1303 » /** | 1419 * udat_setSymbols not supported for UDAT_CYCLIC_YEARS_WIDE) |
| 1304 » * Cyclic year names (only supported for some calendars, and only for FO
RMAT usage; | 1420 * @stable ICU 54 |
| 1305 » * udat_setSymbols not supported for UDAT_CYCLIC_YEARS_WIDE) | 1421 */ |
| 1306 » * @draft ICU 54 | 1422 UDAT_CYCLIC_YEARS_WIDE, |
| 1307 » */ | 1423 /** |
| 1308 » UDAT_CYCLIC_YEARS_WIDE, | 1424 * Cyclic year names (only supported for some calendars, and only for FORMAT
usage) |
| 1309 » /** | 1425 * @stable ICU 54 |
| 1310 » * Cyclic year names (only supported for some calendars, and only for FO
RMAT usage) | 1426 */ |
| 1311 » * @draft ICU 54 | 1427 UDAT_CYCLIC_YEARS_ABBREVIATED, |
| 1312 » */ | 1428 /** |
| 1313 » UDAT_CYCLIC_YEARS_ABBREVIATED, | 1429 * Cyclic year names (only supported for some calendars, and only for FORMAT
usage; |
| 1314 » /** | 1430 * udat_setSymbols not supported for UDAT_CYCLIC_YEARS_NARROW) |
| 1315 » * Cyclic year names (only supported for some calendars, and only for FO
RMAT usage; | 1431 * @stable ICU 54 |
| 1316 » * udat_setSymbols not supported for UDAT_CYCLIC_YEARS_NARROW) | 1432 */ |
| 1317 » * @draft ICU 54 | 1433 UDAT_CYCLIC_YEARS_NARROW, |
| 1318 » */ | 1434 /** |
| 1319 » UDAT_CYCLIC_YEARS_NARROW, | 1435 * Calendar zodiac names (only supported for some calendars, and only for F
ORMAT usage; |
| 1320 » /** | 1436 * udat_setSymbols not supported for UDAT_ZODIAC_NAMES_WIDE) |
| 1321 » * Calendar zodiac names (only supported for some calendars, and only f
or FORMAT usage; | 1437 * @stable ICU 54 |
| 1322 » * udat_setSymbols not supported for UDAT_ZODIAC_NAMES_WIDE) | 1438 */ |
| 1323 » * @draft ICU 54 | 1439 UDAT_ZODIAC_NAMES_WIDE, |
| 1324 » */ | 1440 /** |
| 1325 » UDAT_ZODIAC_NAMES_WIDE, | 1441 * Calendar zodiac names (only supported for some calendars, and only for F
ORMAT usage) |
| 1326 » /** | 1442 * @stable ICU 54 |
| 1327 » * Calendar zodiac names (only supported for some calendars, and only f
or FORMAT usage) | 1443 */ |
| 1328 » * @draft ICU 54 | 1444 UDAT_ZODIAC_NAMES_ABBREVIATED, |
| 1329 » */ | 1445 /** |
| 1330 » UDAT_ZODIAC_NAMES_ABBREVIATED, | 1446 * Calendar zodiac names (only supported for some calendars, and only for F
ORMAT usage; |
| 1331 » /** | 1447 * udat_setSymbols not supported for UDAT_ZODIAC_NAMES_NARROW) |
| 1332 » * Calendar zodiac names (only supported for some calendars, and only f
or FORMAT usage; | 1448 * @stable ICU 54 |
| 1333 » * udat_setSymbols not supported for UDAT_ZODIAC_NAMES_NARROW) | 1449 */ |
| 1334 » * @draft ICU 54 | 1450 UDAT_ZODIAC_NAMES_NARROW |
| 1335 » */ | |
| 1336 » UDAT_ZODIAC_NAMES_NARROW | |
| 1337 #endif /* U_HIDE_DRAFT_API */ | |
| 1338 } UDateFormatSymbolType; | 1451 } UDateFormatSymbolType; |
| 1339 | 1452 |
| 1340 struct UDateFormatSymbols; | 1453 struct UDateFormatSymbols; |
| 1341 /** Date format symbols. | 1454 /** Date format symbols. |
| 1342 * For usage in C programs. | 1455 * For usage in C programs. |
| 1343 * @stable ICU 2.6 | 1456 * @stable ICU 2.6 |
| 1344 */ | 1457 */ |
| 1345 typedef struct UDateFormatSymbols UDateFormatSymbols; | 1458 typedef struct UDateFormatSymbols UDateFormatSymbols; |
| 1346 | 1459 |
| 1347 /** | 1460 /** |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1425 * Set a particular UDisplayContext value in the formatter, such as | 1538 * Set a particular UDisplayContext value in the formatter, such as |
| 1426 * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. | 1539 * UDISPCTX_CAPITALIZATION_FOR_STANDALONE. |
| 1427 * @param fmt The formatter for which to set a UDisplayContext value. | 1540 * @param fmt The formatter for which to set a UDisplayContext value. |
| 1428 * @param value The UDisplayContext value to set. | 1541 * @param value The UDisplayContext value to set. |
| 1429 * @param status A pointer to an UErrorCode to receive any errors | 1542 * @param status A pointer to an UErrorCode to receive any errors |
| 1430 * @stable ICU 51 | 1543 * @stable ICU 51 |
| 1431 */ | 1544 */ |
| 1432 U_DRAFT void U_EXPORT2 | 1545 U_DRAFT void U_EXPORT2 |
| 1433 udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status); | 1546 udat_setContext(UDateFormat* fmt, UDisplayContext value, UErrorCode* status); |
| 1434 | 1547 |
| 1435 #ifndef U_HIDE_DRAFT_API | |
| 1436 /** | 1548 /** |
| 1437 * Get the formatter's UDisplayContext value for the specified UDisplayContextTy
pe, | 1549 * Get the formatter's UDisplayContext value for the specified UDisplayContextTy
pe, |
| 1438 * such as UDISPCTX_TYPE_CAPITALIZATION. | 1550 * such as UDISPCTX_TYPE_CAPITALIZATION. |
| 1439 * @param fmt The formatter to query. | 1551 * @param fmt The formatter to query. |
| 1440 * @param type The UDisplayContextType whose value to return | 1552 * @param type The UDisplayContextType whose value to return |
| 1441 * @param status A pointer to an UErrorCode to receive any errors | 1553 * @param status A pointer to an UErrorCode to receive any errors |
| 1442 * @return The UDisplayContextValue for the specified type. | 1554 * @return The UDisplayContextValue for the specified type. |
| 1443 * @draft ICU 53 | 1555 * @stable ICU 53 |
| 1444 */ | 1556 */ |
| 1445 U_DRAFT UDisplayContext U_EXPORT2 | 1557 U_STABLE UDisplayContext U_EXPORT2 |
| 1446 udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* st
atus); | 1558 udat_getContext(const UDateFormat* fmt, UDisplayContextType type, UErrorCode* st
atus); |
| 1447 | 1559 |
| 1448 #endif /* U_HIDE_DRAFT_API */ | |
| 1449 | |
| 1450 #ifndef U_HIDE_INTERNAL_API | 1560 #ifndef U_HIDE_INTERNAL_API |
| 1451 /** | 1561 /** |
| 1452 * Extract the date pattern from a UDateFormat set for relative date formatting. | 1562 * Extract the date pattern from a UDateFormat set for relative date formatting. |
| 1453 * The pattern will follow the pattern syntax rules. | 1563 * The pattern will follow the pattern syntax rules. |
| 1454 * @param fmt The formatter to query. | 1564 * @param fmt The formatter to query. |
| 1455 * @param result A pointer to a buffer to receive the pattern. | 1565 * @param result A pointer to a buffer to receive the pattern. |
| 1456 * @param resultLength The maximum size of result. | 1566 * @param resultLength The maximum size of result. |
| 1457 * @param status A pointer to a UErrorCode to receive any errors | 1567 * @param status A pointer to a UErrorCode to receive any errors |
| 1458 * @return The total buffer size needed; if greater than resultLength, the output
was truncated. | 1568 * @return The total buffer size needed; if greater than resultLength, the output
was truncated. |
| 1459 * @see udat_applyPatternRelative | 1569 * @see udat_applyPatternRelative |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 * @internal ICU 49 | 1637 * @internal ICU 49 |
| 1528 */ | 1638 */ |
| 1529 U_INTERNAL UDateFormatOpener U_EXPORT2 | 1639 U_INTERNAL UDateFormatOpener U_EXPORT2 |
| 1530 udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status); | 1640 udat_unregisterOpener(UDateFormatOpener opener, UErrorCode *status); |
| 1531 #endif /* U_HIDE_INTERNAL_API */ | 1641 #endif /* U_HIDE_INTERNAL_API */ |
| 1532 | 1642 |
| 1533 | 1643 |
| 1534 #endif /* #if !UCONFIG_NO_FORMATTING */ | 1644 #endif /* #if !UCONFIG_NO_FORMATTING */ |
| 1535 | 1645 |
| 1536 #endif | 1646 #endif |
| OLD | NEW |