]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unicode/udatintv.h
ICU-531.30.tar.gz
[apple/icu.git] / icuSources / i18n / unicode / udatintv.h
1 /*
2 ******************************************************************************
3 * Copyright (C) 2010-2011 Apple Inc. All Rights Reserved.
4 ******************************************************************************
5 */
6
7 #ifndef UDATINTV_H
8 #define UDATINTV_H
9
10 #include "unicode/utypes.h"
11
12 #if !UCONFIG_NO_FORMATTING
13
14 #include "unicode/umisc.h"
15 #include "unicode/udateintervalformat.h"
16
17 /**
18 * NOTE - THE TEMPORARY APPLE INTERFACES DECLARED HERE ARE OBSOLETE, PLEASE USE
19 * THE REAL ICU EQUIVALENTS IN udateintervalformat.h
20 *
21 * A UDateIntervalFormat is used to format the range between two UDate values
22 * in a locale-sensitive way, using a skeleton that specifies the precision and
23 * completeness of the information to show. If the range smaller than the resolution
24 * specified by the skeleton, a single date format will be produced. If the range
25 * is larger than the format specified by the skeleton, a locale-specific fallback
26 * will be used to format the items missing from the skeleton.
27 *
28 * For example, if the range is 2010-03-04 07:56 - 2010-03-04 19:56 (12 hours)
29 * - The skeleton jm will produce
30 * for en_US, "7:56 AM – 7:56 PM"
31 * for en_GB, "7:56 – 19:56"
32 * - The skeleton MMMd will produce
33 * for en_US, "Mar 4"
34 * for en_GB, "4 Mar"
35 * If the range is 2010-03-04 07:56 - 2010-03-08 16:11 (4 days, 8 hours, 15 minutes)
36 * - The skeleton jm will produce
37 * for en_US, "3/4/2010 7:56 AM – 3/8/2010 4:11 PM"
38 * for en_GB, "4/3/2010 7:56 – 8/3/2010 16:11"
39 * - The skeleton MMMd will produce
40 * for en_US, "Mar 4–8"
41 * for en_GB, "4-8 Mar"
42 *
43 * Note, in ICU 4.4 the standard skeletons for which date interval format data
44 * is usually available are as follows; best results will be obtained by using
45 * skeletons from this set, or those formed by combining these standard skeletons
46 * (note that for these skeletons, the length of digit field such as d, y, or
47 * M vs MM is irrelevant (but for non-digit fields such as MMM vs MMMM it is
48 * relevant). Note that a skeleton involving h or H generally explicitly requests
49 * that time style (12- or 24-hour time respectively). For a skeleton that
50 * requests the locale's default time style (h or H), use 'j' instead of h or H.
51 * h, H, hm, Hm,
52 * hv, Hv, hmv, Hmv,
53 * d,
54 * M, MMM, MMMM,
55 * Md, MMMd,
56 * MEd, MMMEd,
57 * y,
58 * yM, yMMM, yMMMM,
59 * yMd, yMMMd,
60 * yMEd, yMMMEd
61 *
62 * Locales for which ICU 4.4 seems to have a reasonable amount of this data
63 * include:
64 * af, am, ar, be, bg, bn, ca, cs, da, de (_AT), el, en (_AU,_CA,_GB,_IE,_IN...),
65 * eo, es (_AR,_CL,_CO,...,_US) et, fa, fi, fo, fr (_BE,_CH,_CA), fur, gsw, he,
66 * hr, hu, hy, is, it (_CH), ja, kk, km, ko, lt, lv, mk, ml, mt, nb, nl )_BE),
67 * nn, pl, pt (_PT), rm, ro, ru (_UA), sk, sl, so, sq, sr, sr_Latn, sv, th, to,
68 * tr, uk, ur, vi, zh (_SG), zh_Hant (_HK,_MO)
69 */
70
71 /**
72 * A UDateIntervalFormat object for use in C programs.
73 * struct UDateIntervalFormat; defined in udateintervalformat.h
74 */
75
76 /**
77 * Open a new UDateIntervalFormat object using the predefined rules for a
78 * given locale plus a specified skeleton.
79 * @param locale
80 * The locale for whose rules should be used; may be NULL for
81 * default locale.
82 * @param skeleton
83 * A pattern containing only the fields desired for the interval
84 * format, for example "Hm", "yMMMd", or "yMMMEdHm".
85 * @param length
86 * The length of skeleton; may be -1 if the skeleton is zero-terminated.
87 * @param status
88 * A pointer to a UErrorCode to receive any errors.
89 * @return
90 * A UDateIntervalFormat object for the specified locale, or NULL
91 * if an error occurred.
92 * @internal/obsolete, use udtitvfmt_open in udateintervalformat.h
93 */
94 U_INTERNAL UDateIntervalFormat* U_EXPORT2
95 udatintv_open(const char* locale,
96 const UChar* skeleton,
97 int32_t skeletonLength,
98 UErrorCode* status);
99
100 /**
101 * Close a UDateIntervalFormat object. Once closed it may no longer be used.
102 * @param datintv
103 * The UDateIntervalFormat object to close.
104 * @internal/obsolete, use udtitvfmt_close in udateintervalformat.h
105 */
106 U_INTERNAL void U_EXPORT2
107 udatintv_close(UDateIntervalFormat *datintv);
108
109 /**
110 * Formats a date/time range using the conventions established for the
111 * UDateIntervalFormat object.
112 * @param datintv
113 * The UDateIntervalFormat object specifying the format conventions.
114 * @param fromDate
115 * The starting point of the range.
116 * @param fromDate
117 * The ending point of the range.
118 * @param result
119 * A pointer to a buffer to receive the formatted range.
120 * @param resultCapacity
121 * The maximum size of result.
122 * @param position
123 * A pointer to a UFieldPosition. On input, position->field is read.
124 * On output, position->beginIndex and position->endIndex indicate
125 * the beginning and ending indices of field number position->field,
126 * if such a field exists. This parameter may be NULL, in which case
127 * no field position data is returned.
128 * @param status
129 * A pointer to a UErrorCode to receive any errors.
130 * @return
131 * The total buffer size needed; if greater than resultLength, the
132 * output was truncated.
133 * @internal/obsolete, use udtitvfmt_format in udateintervalformat.h
134 */
135 U_INTERNAL int32_t U_EXPORT2
136 udatintv_format(const UDateIntervalFormat* datintv,
137 UDate fromDate,
138 UDate toDate,
139 UChar* result,
140 int32_t resultCapacity,
141 UFieldPosition* position,
142 UErrorCode* status);
143
144 #endif /* #if !UCONFIG_NO_FORMATTING */
145
146 #endif