]>
Commit | Line | Data |
---|---|---|
b75a7d8f | 1 | /* |
46f4442e | 2 | ******************************************************************************* |
4388f060 | 3 | * Copyright (C) 1996-2012, International Business Machines Corporation and |
46f4442e A |
4 | * others. All Rights Reserved. |
5 | ******************************************************************************* | |
6 | */ | |
b75a7d8f A |
7 | |
8 | #ifndef UCAL_H | |
9 | #define UCAL_H | |
10 | ||
11 | #include "unicode/utypes.h" | |
12 | #include "unicode/uenum.h" | |
374ca955 | 13 | #include "unicode/uloc.h" |
729e4ab9 | 14 | #include "unicode/localpointer.h" |
b75a7d8f A |
15 | |
16 | #if !UCONFIG_NO_FORMATTING | |
17 | ||
18 | /** | |
19 | * \file | |
20 | * \brief C API: Calendar | |
21 | * | |
22 | * <h2>Calendar C API</h2> | |
23 | * | |
24 | * UCalendar C API is used for converting between a <code>UDate</code> object | |
25 | * and a set of integer fields such as <code>UCAL_YEAR</code>, <code>UCAL_MONTH</code>, | |
26 | * <code>UCAL_DAY</code>, <code>UCAL_HOUR</code>, and so on. | |
27 | * (A <code>UDate</code> object represents a specific instant in | |
28 | * time with millisecond precision. See UDate | |
29 | * for information about the <code>UDate</code> .) | |
30 | * | |
31 | * <p> | |
32 | * Types of <code>UCalendar</code> interpret a <code>UDate</code> | |
374ca955 | 33 | * according to the rules of a specific calendar system. The U_STABLE |
b75a7d8f A |
34 | * provides the enum UCalendarType with UCAL_TRADITIONAL and |
35 | * UCAL_GREGORIAN. | |
36 | * <p> | |
37 | * Like other locale-sensitive C API, calendar API provides a | |
38 | * function, <code>ucal_open()</code>, which returns a pointer to | |
39 | * <code>UCalendar</code> whose time fields have been initialized | |
40 | * with the current date and time. We need to specify the type of | |
41 | * calendar to be opened and the timezoneId. | |
374ca955 | 42 | * \htmlonly<blockquote>\endhtmlonly |
b75a7d8f A |
43 | * <pre> |
44 | * \code | |
45 | * UCalendar *caldef; | |
46 | * UChar *tzId; | |
47 | * UErrorCode status; | |
48 | * tzId=(UChar*)malloc(sizeof(UChar) * (strlen("PST") +1) ); | |
49 | * u_uastrcpy(tzId, "PST"); | |
50 | * caldef=ucal_open(tzID, u_strlen(tzID), NULL, UCAL_TRADITIONAL, &status); | |
51 | * \endcode | |
52 | * </pre> | |
374ca955 | 53 | * \htmlonly</blockquote>\endhtmlonly |
b75a7d8f A |
54 | * |
55 | * <p> | |
56 | * A <code>UCalendar</code> object can produce all the time field values | |
57 | * needed to implement the date-time formatting for a particular language | |
58 | * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional). | |
59 | * | |
60 | * <p> | |
61 | * When computing a <code>UDate</code> from time fields, two special circumstances | |
62 | * may arise: there may be insufficient information to compute the | |
63 | * <code>UDate</code> (such as only year and month but no day in the month), | |
64 | * or there may be inconsistent information (such as "Tuesday, July 15, 1996" | |
65 | * -- July 15, 1996 is actually a Monday). | |
66 | * | |
67 | * <p> | |
68 | * <strong>Insufficient information.</strong> The calendar will use default | |
69 | * information to specify the missing fields. This may vary by calendar; for | |
70 | * the Gregorian calendar, the default for a field is the same as that of the | |
71 | * start of the epoch: i.e., UCAL_YEAR = 1970, UCAL_MONTH = JANUARY, UCAL_DATE = 1, etc. | |
72 | * | |
73 | * <p> | |
74 | * <strong>Inconsistent information.</strong> If fields conflict, the calendar | |
75 | * will give preference to fields set more recently. For example, when | |
76 | * determining the day, the calendar will look for one of the following | |
77 | * combinations of fields. The most recent combination, as determined by the | |
78 | * most recently set single field, will be used. | |
79 | * | |
374ca955 | 80 | * \htmlonly<blockquote>\endhtmlonly |
b75a7d8f A |
81 | * <pre> |
82 | * \code | |
83 | * UCAL_MONTH + UCAL_DAY_OF_MONTH | |
84 | * UCAL_MONTH + UCAL_WEEK_OF_MONTH + UCAL_DAY_OF_WEEK | |
85 | * UCAL_MONTH + UCAL_DAY_OF_WEEK_IN_MONTH + UCAL_DAY_OF_WEEK | |
86 | * UCAL_DAY_OF_YEAR | |
87 | * UCAL_DAY_OF_WEEK + UCAL_WEEK_OF_YEAR | |
88 | * \endcode | |
89 | * </pre> | |
374ca955 | 90 | * \htmlonly</blockquote>\endhtmlonly |
b75a7d8f A |
91 | * |
92 | * For the time of day: | |
93 | * | |
374ca955 | 94 | * \htmlonly<blockquote>\endhtmlonly |
b75a7d8f A |
95 | * <pre> |
96 | * \code | |
97 | * UCAL_HOUR_OF_DAY | |
98 | * UCAL_AM_PM + UCAL_HOUR | |
99 | * \endcode | |
100 | * </pre> | |
374ca955 | 101 | * \htmlonly</blockquote>\endhtmlonly |
b75a7d8f A |
102 | * |
103 | * <p> | |
104 | * <strong>Note:</strong> for some non-Gregorian calendars, different | |
105 | * fields may be necessary for complete disambiguation. For example, a full | |
106 | * specification of the historial Arabic astronomical calendar requires year, | |
107 | * month, day-of-month <em>and</em> day-of-week in some cases. | |
108 | * | |
109 | * <p> | |
110 | * <strong>Note:</strong> There are certain possible ambiguities in | |
111 | * interpretation of certain singular times, which are resolved in the | |
112 | * following ways: | |
113 | * <ol> | |
114 | * <li> 24:00:00 "belongs" to the following day. That is, | |
115 | * 23:59 on Dec 31, 1969 < 24:00 on Jan 1, 1970 < 24:01:00 on Jan 1, 1970 | |
116 | * | |
117 | * <li> Although historically not precise, midnight also belongs to "am", | |
118 | * and noon belongs to "pm", so on the same day, | |
119 | * 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm | |
120 | * </ol> | |
121 | * | |
122 | * <p> | |
123 | * The date or time format strings are not part of the definition of a | |
124 | * calendar, as those must be modifiable or overridable by the user at | |
125 | * runtime. Use {@link DateFormat} | |
126 | * to format dates. | |
127 | * | |
128 | * <p> | |
129 | * <code>Calendar</code> provides an API for field "rolling", where fields | |
130 | * can be incremented or decremented, but wrap around. For example, rolling the | |
131 | * month up in the date <code>December 12, <b>1996</b></code> results in | |
132 | * <code>January 12, <b>1996</b></code>. | |
133 | * | |
134 | * <p> | |
135 | * <code>Calendar</code> also provides a date arithmetic function for | |
136 | * adding the specified (signed) amount of time to a particular time field. | |
137 | * For example, subtracting 5 days from the date <code>September 12, 1996</code> | |
138 | * results in <code>September 7, 1996</code>. | |
139 | * | |
140 | * @stable ICU 2.0 | |
141 | */ | |
142 | ||
4388f060 A |
143 | /** |
144 | * The time zone ID reserved for unknown time zone. | |
145 | * @stable ICU 4.8 | |
146 | */ | |
147 | #define UCAL_UNKNOWN_ZONE_ID "Etc/Unknown" | |
148 | ||
b75a7d8f A |
149 | /** A calendar. |
150 | * For usage in C programs. | |
151 | * @stable ICU 2.0 | |
152 | */ | |
153 | typedef void* UCalendar; | |
154 | ||
155 | /** Possible types of UCalendars | |
156 | * @stable ICU 2.0 | |
157 | */ | |
158 | enum UCalendarType { | |
46f4442e A |
159 | /** |
160 | * Despite the name, UCAL_TRADITIONAL designates the locale's default calendar, | |
161 | * which may be the Gregorian calendar or some other calendar. | |
162 | * @stable ICU 2.0 | |
163 | */ | |
b75a7d8f | 164 | UCAL_TRADITIONAL, |
46f4442e | 165 | /** |
729e4ab9 A |
166 | * A better name for UCAL_TRADITIONAL. |
167 | * @stable ICU 4.2 | |
46f4442e | 168 | */ |
729e4ab9 | 169 | UCAL_DEFAULT = UCAL_TRADITIONAL, |
46f4442e | 170 | /** |
729e4ab9 A |
171 | * Unambiguously designates the Gregorian calendar for the locale. |
172 | * @stable ICU 2.0 | |
46f4442e | 173 | */ |
729e4ab9 | 174 | UCAL_GREGORIAN |
b75a7d8f A |
175 | }; |
176 | ||
177 | /** @stable ICU 2.0 */ | |
178 | typedef enum UCalendarType UCalendarType; | |
179 | ||
180 | /** Possible fields in a UCalendar | |
181 | * @stable ICU 2.0 | |
182 | */ | |
183 | enum UCalendarDateFields { | |
374ca955 | 184 | /** |
73c04bcf A |
185 | * Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar. |
186 | * This is a calendar-specific value. | |
374ca955 A |
187 | * @stable ICU 2.6 |
188 | */ | |
b75a7d8f | 189 | UCAL_ERA, |
73c04bcf | 190 | |
374ca955 | 191 | /** |
73c04bcf | 192 | * Field number indicating the year. This is a calendar-specific value. |
374ca955 A |
193 | * @stable ICU 2.6 |
194 | */ | |
b75a7d8f | 195 | UCAL_YEAR, |
73c04bcf | 196 | |
374ca955 | 197 | /** |
73c04bcf A |
198 | * Field number indicating the month. This is a calendar-specific value. |
199 | * The first month of the year is | |
200 | * <code>JANUARY</code>; the last depends on the number of months in a year. | |
201 | * @see #UCAL_JANUARY | |
202 | * @see #UCAL_FEBRUARY | |
203 | * @see #UCAL_MARCH | |
204 | * @see #UCAL_APRIL | |
205 | * @see #UCAL_MAY | |
206 | * @see #UCAL_JUNE | |
207 | * @see #UCAL_JULY | |
208 | * @see #UCAL_AUGUST | |
209 | * @see #UCAL_SEPTEMBER | |
210 | * @see #UCAL_OCTOBER | |
211 | * @see #UCAL_NOVEMBER | |
212 | * @see #UCAL_DECEMBER | |
213 | * @see #UCAL_UNDECIMBER | |
374ca955 A |
214 | * @stable ICU 2.6 |
215 | */ | |
b75a7d8f | 216 | UCAL_MONTH, |
73c04bcf | 217 | |
374ca955 | 218 | /** |
73c04bcf A |
219 | * Field number indicating the |
220 | * week number within the current year. The first week of the year, as | |
221 | * defined by <code>UCAL_FIRST_DAY_OF_WEEK</code> and <code>UCAL_MINIMAL_DAYS_IN_FIRST_WEEK</code> | |
222 | * attributes, has value 1. Subclasses define | |
223 | * the value of <code>UCAL_WEEK_OF_YEAR</code> for days before the first week of | |
224 | * the year. | |
46f4442e | 225 | * @see ucal_getAttribute |
73c04bcf | 226 | * @see ucal_setAttribute |
374ca955 A |
227 | * @stable ICU 2.6 |
228 | */ | |
b75a7d8f | 229 | UCAL_WEEK_OF_YEAR, |
73c04bcf A |
230 | |
231 | /** | |
232 | * Field number indicating the | |
233 | * week number within the current month. The first week of the month, as | |
234 | * defined by <code>UCAL_FIRST_DAY_OF_WEEK</code> and <code>UCAL_MINIMAL_DAYS_IN_FIRST_WEEK</code> | |
235 | * attributes, has value 1. Subclasses define | |
236 | * the value of <code>WEEK_OF_MONTH</code> for days before the first week of | |
237 | * the month. | |
46f4442e A |
238 | * @see ucal_getAttribute |
239 | * @see ucal_setAttribute | |
240 | * @see #UCAL_FIRST_DAY_OF_WEEK | |
241 | * @see #UCAL_MINIMAL_DAYS_IN_FIRST_WEEK | |
374ca955 A |
242 | * @stable ICU 2.6 |
243 | */ | |
b75a7d8f | 244 | UCAL_WEEK_OF_MONTH, |
73c04bcf A |
245 | |
246 | /** | |
247 | * Field number indicating the | |
248 | * day of the month. This is a synonym for <code>DAY_OF_MONTH</code>. | |
249 | * The first day of the month has value 1. | |
46f4442e | 250 | * @see #UCAL_DAY_OF_MONTH |
374ca955 A |
251 | * @stable ICU 2.6 |
252 | */ | |
b75a7d8f | 253 | UCAL_DATE, |
73c04bcf A |
254 | |
255 | /** | |
256 | * Field number indicating the day | |
257 | * number within the current year. The first day of the year has value 1. | |
374ca955 A |
258 | * @stable ICU 2.6 |
259 | */ | |
b75a7d8f | 260 | UCAL_DAY_OF_YEAR, |
73c04bcf A |
261 | |
262 | /** | |
263 | * Field number indicating the day | |
264 | * of the week. This field takes values <code>SUNDAY</code>, | |
265 | * <code>MONDAY</code>, <code>TUESDAY</code>, <code>WEDNESDAY</code>, | |
266 | * <code>THURSDAY</code>, <code>FRIDAY</code>, and <code>SATURDAY</code>. | |
46f4442e A |
267 | * @see #UCAL_SUNDAY |
268 | * @see #UCAL_MONDAY | |
269 | * @see #UCAL_TUESDAY | |
270 | * @see #UCAL_WEDNESDAY | |
271 | * @see #UCAL_THURSDAY | |
272 | * @see #UCAL_FRIDAY | |
273 | * @see #UCAL_SATURDAY | |
374ca955 A |
274 | * @stable ICU 2.6 |
275 | */ | |
b75a7d8f | 276 | UCAL_DAY_OF_WEEK, |
73c04bcf A |
277 | |
278 | /** | |
279 | * Field number indicating the | |
280 | * ordinal number of the day of the week within the current month. Together | |
281 | * with the <code>DAY_OF_WEEK</code> field, this uniquely specifies a day | |
282 | * within a month. Unlike <code>WEEK_OF_MONTH</code> and | |
283 | * <code>WEEK_OF_YEAR</code>, this field's value does <em>not</em> depend on | |
284 | * <code>getFirstDayOfWeek()</code> or | |
285 | * <code>getMinimalDaysInFirstWeek()</code>. <code>DAY_OF_MONTH 1</code> | |
286 | * through <code>7</code> always correspond to <code>DAY_OF_WEEK_IN_MONTH | |
287 | * 1</code>; <code>8</code> through <code>15</code> correspond to | |
288 | * <code>DAY_OF_WEEK_IN_MONTH 2</code>, and so on. | |
289 | * <code>DAY_OF_WEEK_IN_MONTH 0</code> indicates the week before | |
290 | * <code>DAY_OF_WEEK_IN_MONTH 1</code>. Negative values count back from the | |
291 | * end of the month, so the last Sunday of a month is specified as | |
292 | * <code>DAY_OF_WEEK = SUNDAY, DAY_OF_WEEK_IN_MONTH = -1</code>. Because | |
293 | * negative values count backward they will usually be aligned differently | |
294 | * within the month than positive values. For example, if a month has 31 | |
295 | * days, <code>DAY_OF_WEEK_IN_MONTH -1</code> will overlap | |
296 | * <code>DAY_OF_WEEK_IN_MONTH 5</code> and the end of <code>4</code>. | |
46f4442e A |
297 | * @see #UCAL_DAY_OF_WEEK |
298 | * @see #UCAL_WEEK_OF_MONTH | |
374ca955 A |
299 | * @stable ICU 2.6 |
300 | */ | |
b75a7d8f | 301 | UCAL_DAY_OF_WEEK_IN_MONTH, |
73c04bcf A |
302 | |
303 | /** | |
304 | * Field number indicating | |
305 | * whether the <code>HOUR</code> is before or after noon. | |
306 | * E.g., at 10:04:15.250 PM the <code>AM_PM</code> is <code>PM</code>. | |
307 | * @see #UCAL_AM | |
308 | * @see #UCAL_PM | |
309 | * @see #UCAL_HOUR | |
374ca955 A |
310 | * @stable ICU 2.6 |
311 | */ | |
b75a7d8f | 312 | UCAL_AM_PM, |
73c04bcf A |
313 | |
314 | /** | |
315 | * Field number indicating the | |
316 | * hour of the morning or afternoon. <code>HOUR</code> is used for the 12-hour | |
317 | * clock. | |
318 | * E.g., at 10:04:15.250 PM the <code>HOUR</code> is 10. | |
319 | * @see #UCAL_AM_PM | |
320 | * @see #UCAL_HOUR_OF_DAY | |
374ca955 A |
321 | * @stable ICU 2.6 |
322 | */ | |
b75a7d8f | 323 | UCAL_HOUR, |
73c04bcf A |
324 | |
325 | /** | |
326 | * Field number indicating the | |
327 | * hour of the day. <code>HOUR_OF_DAY</code> is used for the 24-hour clock. | |
328 | * E.g., at 10:04:15.250 PM the <code>HOUR_OF_DAY</code> is 22. | |
329 | * @see #UCAL_HOUR | |
374ca955 A |
330 | * @stable ICU 2.6 |
331 | */ | |
b75a7d8f | 332 | UCAL_HOUR_OF_DAY, |
73c04bcf A |
333 | |
334 | /** | |
335 | * Field number indicating the | |
336 | * minute within the hour. | |
337 | * E.g., at 10:04:15.250 PM the <code>UCAL_MINUTE</code> is 4. | |
374ca955 A |
338 | * @stable ICU 2.6 |
339 | */ | |
b75a7d8f | 340 | UCAL_MINUTE, |
73c04bcf A |
341 | |
342 | /** | |
343 | * Field number indicating the | |
344 | * second within the minute. | |
345 | * E.g., at 10:04:15.250 PM the <code>UCAL_SECOND</code> is 15. | |
374ca955 A |
346 | * @stable ICU 2.6 |
347 | */ | |
b75a7d8f | 348 | UCAL_SECOND, |
73c04bcf A |
349 | |
350 | /** | |
351 | * Field number indicating the | |
352 | * millisecond within the second. | |
353 | * E.g., at 10:04:15.250 PM the <code>UCAL_MILLISECOND</code> is 250. | |
374ca955 A |
354 | * @stable ICU 2.6 |
355 | */ | |
b75a7d8f | 356 | UCAL_MILLISECOND, |
73c04bcf A |
357 | |
358 | /** | |
359 | * Field number indicating the | |
360 | * raw offset from GMT in milliseconds. | |
374ca955 A |
361 | * @stable ICU 2.6 |
362 | */ | |
b75a7d8f | 363 | UCAL_ZONE_OFFSET, |
73c04bcf A |
364 | |
365 | /** | |
366 | * Field number indicating the | |
367 | * daylight savings offset in milliseconds. | |
374ca955 A |
368 | * @stable ICU 2.6 |
369 | */ | |
b75a7d8f | 370 | UCAL_DST_OFFSET, |
73c04bcf A |
371 | |
372 | /** | |
373 | * Field number | |
374 | * indicating the extended year corresponding to the | |
375 | * <code>UCAL_WEEK_OF_YEAR</code> field. This may be one greater or less | |
376 | * than the value of <code>UCAL_EXTENDED_YEAR</code>. | |
374ca955 A |
377 | * @stable ICU 2.6 |
378 | */ | |
b75a7d8f | 379 | UCAL_YEAR_WOY, |
73c04bcf A |
380 | |
381 | /** | |
382 | * Field number | |
383 | * indicating the localized day of week. This will be a value from 1 | |
384 | * to 7 inclusive, with 1 being the localized first day of the week. | |
374ca955 A |
385 | * @stable ICU 2.6 |
386 | */ | |
b75a7d8f | 387 | UCAL_DOW_LOCAL, |
46f4442e | 388 | |
374ca955 | 389 | /** |
73c04bcf A |
390 | * Year of this calendar system, encompassing all supra-year fields. For example, |
391 | * in Gregorian/Julian calendars, positive Extended Year values indicate years AD, | |
392 | * 1 BC = 0 extended, 2 BC = -1 extended, and so on. | |
393 | * @stable ICU 2.8 | |
374ca955 | 394 | */ |
46f4442e A |
395 | UCAL_EXTENDED_YEAR, |
396 | ||
73c04bcf A |
397 | /** |
398 | * Field number | |
399 | * indicating the modified Julian day number. This is different from | |
400 | * the conventional Julian day number in two regards. First, it | |
401 | * demarcates days at local zone midnight, rather than noon GMT. | |
402 | * Second, it is a local number; that is, it depends on the local time | |
403 | * zone. It can be thought of as a single number that encompasses all | |
404 | * the date-related fields. | |
405 | * @stable ICU 2.8 | |
374ca955 A |
406 | */ |
407 | UCAL_JULIAN_DAY, | |
73c04bcf | 408 | |
374ca955 | 409 | /** |
73c04bcf A |
410 | * Ranges from 0 to 23:59:59.999 (regardless of DST). This field behaves <em>exactly</em> |
411 | * like a composite of all time-related fields, not including the zone fields. As such, | |
412 | * it also reflects discontinuities of those fields on DST transition days. On a day | |
413 | * of DST onset, it will jump forward. On a day of DST cessation, it will jump | |
414 | * backward. This reflects the fact that it must be combined with the DST_OFFSET field | |
415 | * to obtain a unique local time value. | |
416 | * @stable ICU 2.8 | |
374ca955 A |
417 | */ |
418 | UCAL_MILLISECONDS_IN_DAY, | |
46f4442e A |
419 | |
420 | /** | |
421 | * Whether or not the current month is a leap month (0 or 1). See the Chinese calendar for | |
422 | * an example of this. | |
423 | */ | |
424 | UCAL_IS_LEAP_MONTH, | |
374ca955 A |
425 | |
426 | /** | |
427 | * Field count | |
428 | * @stable ICU 2.6 | |
429 | */ | |
430 | UCAL_FIELD_COUNT, | |
431 | ||
73c04bcf A |
432 | /** |
433 | * Field number indicating the | |
434 | * day of the month. This is a synonym for <code>UCAL_DATE</code>. | |
435 | * The first day of the month has value 1. | |
436 | * @see #UCAL_DATE | |
374ca955 | 437 | * Synonym for UCAL_DATE |
73c04bcf | 438 | * @stable ICU 2.8 |
374ca955 A |
439 | **/ |
440 | UCAL_DAY_OF_MONTH=UCAL_DATE | |
b75a7d8f A |
441 | }; |
442 | ||
443 | /** @stable ICU 2.0 */ | |
444 | typedef enum UCalendarDateFields UCalendarDateFields; | |
445 | /** | |
446 | * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients | |
447 | * who create locale resources for the field of first-day-of-week should be aware of | |
448 | * this. For instance, in US locale, first-day-of-week is set to 1, i.e., UCAL_SUNDAY. | |
449 | */ | |
450 | /** Possible days of the week in a UCalendar | |
451 | * @stable ICU 2.0 | |
452 | */ | |
453 | enum UCalendarDaysOfWeek { | |
454 | /** Sunday */ | |
455 | UCAL_SUNDAY = 1, | |
456 | /** Monday */ | |
457 | UCAL_MONDAY, | |
458 | /** Tuesday */ | |
459 | UCAL_TUESDAY, | |
460 | /** Wednesday */ | |
461 | UCAL_WEDNESDAY, | |
462 | /** Thursday */ | |
463 | UCAL_THURSDAY, | |
464 | /** Friday */ | |
465 | UCAL_FRIDAY, | |
466 | /** Saturday */ | |
467 | UCAL_SATURDAY | |
468 | }; | |
469 | ||
470 | /** @stable ICU 2.0 */ | |
471 | typedef enum UCalendarDaysOfWeek UCalendarDaysOfWeek; | |
472 | ||
473 | /** Possible months in a UCalendar. Note: Calendar month is 0-based. | |
474 | * @stable ICU 2.0 | |
475 | */ | |
476 | enum UCalendarMonths { | |
477 | /** January */ | |
478 | UCAL_JANUARY, | |
479 | /** February */ | |
480 | UCAL_FEBRUARY, | |
481 | /** March */ | |
482 | UCAL_MARCH, | |
483 | /** April */ | |
484 | UCAL_APRIL, | |
485 | /** May */ | |
486 | UCAL_MAY, | |
487 | /** June */ | |
488 | UCAL_JUNE, | |
489 | /** July */ | |
490 | UCAL_JULY, | |
491 | /** August */ | |
492 | UCAL_AUGUST, | |
493 | /** September */ | |
494 | UCAL_SEPTEMBER, | |
495 | /** October */ | |
496 | UCAL_OCTOBER, | |
497 | /** November */ | |
498 | UCAL_NOVEMBER, | |
499 | /** December */ | |
500 | UCAL_DECEMBER, | |
73c04bcf A |
501 | /** Value of the <code>UCAL_MONTH</code> field indicating the |
502 | * thirteenth month of the year. Although the Gregorian calendar | |
503 | * does not use this value, lunar calendars do. | |
504 | */ | |
b75a7d8f A |
505 | UCAL_UNDECIMBER |
506 | }; | |
507 | ||
508 | /** @stable ICU 2.0 */ | |
509 | typedef enum UCalendarMonths UCalendarMonths; | |
510 | ||
511 | /** Possible AM/PM values in a UCalendar | |
512 | * @stable ICU 2.0 | |
513 | */ | |
514 | enum UCalendarAMPMs { | |
515 | /** AM */ | |
516 | UCAL_AM, | |
517 | /** PM */ | |
518 | UCAL_PM | |
519 | }; | |
520 | ||
521 | /** @stable ICU 2.0 */ | |
522 | typedef enum UCalendarAMPMs UCalendarAMPMs; | |
523 | ||
4388f060 A |
524 | /** |
525 | * System time zone type constants used by filtering zones | |
526 | * in ucal_openTimeZoneIDEnumeration. | |
527 | * @see ucal_openTimeZoneIDEnumeration | |
528 | * @stable ICU 4.8 | |
529 | */ | |
530 | enum USystemTimeZoneType { | |
531 | /** | |
532 | * Any system zones. | |
533 | * @stable ICU 4.8 | |
534 | */ | |
535 | UCAL_ZONE_TYPE_ANY, | |
536 | /** | |
537 | * Canonical system zones. | |
538 | * @stable ICU 4.8 | |
539 | */ | |
540 | UCAL_ZONE_TYPE_CANONICAL, | |
541 | /** | |
542 | * Canonical system zones associated with actual locations. | |
543 | * @stable ICU 4.8 | |
544 | */ | |
545 | UCAL_ZONE_TYPE_CANONICAL_LOCATION | |
546 | }; | |
547 | ||
548 | /** @stable ICU 4.8 */ | |
549 | typedef enum USystemTimeZoneType USystemTimeZoneType; | |
550 | ||
551 | /** | |
552 | * Create an enumeration over system time zone IDs with the given | |
553 | * filter conditions. | |
554 | * @param zoneType The system time zone type. | |
555 | * @param region The ISO 3166 two-letter country code or UN M.49 | |
556 | * three-digit area code. When NULL, no filtering | |
557 | * done by region. | |
558 | * @param rawOffset An offset from GMT in milliseconds, ignoring the | |
559 | * effect of daylight savings time, if any. When NULL, | |
560 | * no filtering done by zone offset. | |
561 | * @param ec A pointer to an UErrorCode to receive any errors | |
562 | * @return an enumeration object that the caller must dispose of | |
563 | * using enum_close(), or NULL upon failure. In case of failure, | |
564 | * *ec will indicate the error. | |
565 | * @stable ICU 4.8 | |
566 | */ | |
567 | U_DRAFT UEnumeration* U_EXPORT2 | |
568 | ucal_openTimeZoneIDEnumeration(USystemTimeZoneType zoneType, const char* region, | |
569 | const int32_t* rawOffset, UErrorCode* ec); | |
570 | ||
b75a7d8f A |
571 | /** |
572 | * Create an enumeration over all time zones. | |
573 | * | |
574 | * @param ec input/output error code | |
575 | * | |
576 | * @return an enumeration object that the caller must dispose of using | |
577 | * uenum_close(), or NULL upon failure. In case of failure *ec will | |
578 | * indicate the error. | |
579 | * | |
374ca955 | 580 | * @stable ICU 2.6 |
b75a7d8f | 581 | */ |
73c04bcf | 582 | U_STABLE UEnumeration* U_EXPORT2 |
b75a7d8f A |
583 | ucal_openTimeZones(UErrorCode* ec); |
584 | ||
585 | /** | |
586 | * Create an enumeration over all time zones associated with the given | |
587 | * country. Some zones are affiliated with no country (e.g., "UTC"); | |
588 | * these may also be retrieved, as a group. | |
589 | * | |
590 | * @param country the ISO 3166 two-letter country code, or NULL to | |
591 | * retrieve zones not affiliated with any country | |
592 | * | |
593 | * @param ec input/output error code | |
594 | * | |
595 | * @return an enumeration object that the caller must dispose of using | |
596 | * uenum_close(), or NULL upon failure. In case of failure *ec will | |
597 | * indicate the error. | |
598 | * | |
374ca955 | 599 | * @stable ICU 2.6 |
b75a7d8f | 600 | */ |
73c04bcf | 601 | U_STABLE UEnumeration* U_EXPORT2 |
b75a7d8f A |
602 | ucal_openCountryTimeZones(const char* country, UErrorCode* ec); |
603 | ||
604 | /** | |
605 | * Return the default time zone. The default is determined initially | |
606 | * by querying the host operating system. It may be changed with | |
607 | * ucal_setDefaultTimeZone() or with the C++ TimeZone API. | |
608 | * | |
609 | * @param result A buffer to receive the result, or NULL | |
610 | * | |
611 | * @param resultCapacity The capacity of the result buffer | |
612 | * | |
613 | * @param ec input/output error code | |
614 | * | |
615 | * @return The result string length, not including the terminating | |
616 | * null | |
617 | * | |
374ca955 | 618 | * @stable ICU 2.6 |
b75a7d8f | 619 | */ |
73c04bcf | 620 | U_STABLE int32_t U_EXPORT2 |
b75a7d8f A |
621 | ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec); |
622 | ||
623 | /** | |
624 | * Set the default time zone. | |
625 | * | |
626 | * @param zoneID null-terminated time zone ID | |
627 | * | |
628 | * @param ec input/output error code | |
629 | * | |
374ca955 | 630 | * @stable ICU 2.6 |
b75a7d8f | 631 | */ |
73c04bcf | 632 | U_STABLE void U_EXPORT2 |
b75a7d8f A |
633 | ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec); |
634 | ||
635 | /** | |
636 | * Return the amount of time in milliseconds that the clock is | |
637 | * advanced during daylight savings time for the given time zone, or | |
638 | * zero if the time zone does not observe daylight savings time. | |
639 | * | |
640 | * @param zoneID null-terminated time zone ID | |
641 | * | |
642 | * @param ec input/output error code | |
643 | * | |
644 | * @return the number of milliseconds the time is advanced with | |
645 | * respect to standard time when the daylight savings rules are in | |
646 | * effect. This is always a non-negative number, most commonly either | |
647 | * 3,600,000 (one hour) or zero. | |
648 | * | |
374ca955 | 649 | * @stable ICU 2.6 |
b75a7d8f | 650 | */ |
73c04bcf | 651 | U_STABLE int32_t U_EXPORT2 |
b75a7d8f A |
652 | ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec); |
653 | ||
654 | /** | |
655 | * Get the current date and time. | |
656 | * The value returned is represented as milliseconds from the epoch. | |
657 | * @return The current date and time. | |
658 | * @stable ICU 2.0 | |
659 | */ | |
374ca955 | 660 | U_STABLE UDate U_EXPORT2 |
b75a7d8f A |
661 | ucal_getNow(void); |
662 | ||
663 | /** | |
664 | * Open a UCalendar. | |
665 | * A UCalendar may be used to convert a millisecond value to a year, | |
666 | * month, and day. | |
729e4ab9 | 667 | * <p> |
4388f060 A |
668 | * Note: When unknown TimeZone ID is specified or if the TimeZone ID specified is "Etc/Unknown", |
669 | * the UCalendar returned by the function is initialized with GMT zone with TimeZone ID | |
670 | * <code>UCAL_UNKNOWN_ZONE_ID</code> ("Etc/Unknown") without any errors/warnings. If you want | |
671 | * to check if a TimeZone ID is valid prior to this function, use <code>ucal_getCanonicalTimeZoneID</code>. | |
729e4ab9 | 672 | * |
b75a7d8f A |
673 | * @param zoneID The desired TimeZone ID. If 0, use the default time zone. |
674 | * @param len The length of zoneID, or -1 if null-terminated. | |
675 | * @param locale The desired locale | |
46f4442e A |
676 | * @param type The type of UCalendar to open. This can be UCAL_GREGORIAN to open the Gregorian |
677 | * calendar for the locale, or UCAL_DEFAULT to open the default calendar for the locale (the | |
678 | * default calendar may also be Gregorian). To open a specific non-Gregorian calendar for the | |
679 | * locale, use uloc_setKeywordValue to set the value of the calendar keyword for the locale | |
680 | * and then pass the locale to ucal_open with UCAL_DEFAULT as the type. | |
b75a7d8f A |
681 | * @param status A pointer to an UErrorCode to receive any errors |
682 | * @return A pointer to a UCalendar, or 0 if an error occurred. | |
4388f060 | 683 | * @see #UCAL_UNKNOWN_ZONE_ID |
b75a7d8f A |
684 | * @stable ICU 2.0 |
685 | */ | |
374ca955 | 686 | U_STABLE UCalendar* U_EXPORT2 |
b75a7d8f A |
687 | ucal_open(const UChar* zoneID, |
688 | int32_t len, | |
689 | const char* locale, | |
690 | UCalendarType type, | |
691 | UErrorCode* status); | |
692 | ||
693 | /** | |
694 | * Close a UCalendar. | |
695 | * Once closed, a UCalendar may no longer be used. | |
696 | * @param cal The UCalendar to close. | |
697 | * @stable ICU 2.0 | |
698 | */ | |
374ca955 | 699 | U_STABLE void U_EXPORT2 |
b75a7d8f A |
700 | ucal_close(UCalendar *cal); |
701 | ||
729e4ab9 A |
702 | #if U_SHOW_CPLUSPLUS_API |
703 | ||
704 | U_NAMESPACE_BEGIN | |
705 | ||
706 | /** | |
707 | * \class LocalUCalendarPointer | |
708 | * "Smart pointer" class, closes a UCalendar via ucal_close(). | |
709 | * For most methods see the LocalPointerBase base class. | |
710 | * | |
711 | * @see LocalPointerBase | |
712 | * @see LocalPointer | |
713 | * @stable ICU 4.4 | |
714 | */ | |
715 | U_DEFINE_LOCAL_OPEN_POINTER(LocalUCalendarPointer, UCalendar, ucal_close); | |
716 | ||
717 | U_NAMESPACE_END | |
718 | ||
719 | #endif | |
720 | ||
46f4442e A |
721 | /** |
722 | * Open a copy of a UCalendar. | |
723 | * This function performs a deep copy. | |
724 | * @param cal The calendar to copy | |
725 | * @param status A pointer to an UErrorCode to receive any errors. | |
726 | * @return A pointer to a UCalendar identical to cal. | |
729e4ab9 | 727 | * @stable ICU 4.0 |
46f4442e | 728 | */ |
729e4ab9 | 729 | U_STABLE UCalendar* U_EXPORT2 |
46f4442e A |
730 | ucal_clone(const UCalendar* cal, |
731 | UErrorCode* status); | |
732 | ||
b75a7d8f A |
733 | /** |
734 | * Set the TimeZone used by a UCalendar. | |
735 | * A UCalendar uses a timezone for converting from Greenwich time to local time. | |
736 | * @param cal The UCalendar to set. | |
737 | * @param zoneID The desired TimeZone ID. If 0, use the default time zone. | |
738 | * @param len The length of zoneID, or -1 if null-terminated. | |
739 | * @param status A pointer to an UErrorCode to receive any errors. | |
740 | * @stable ICU 2.0 | |
741 | */ | |
374ca955 | 742 | U_STABLE void U_EXPORT2 |
b75a7d8f A |
743 | ucal_setTimeZone(UCalendar* cal, |
744 | const UChar* zoneID, | |
745 | int32_t len, | |
746 | UErrorCode* status); | |
747 | ||
748 | /** | |
749 | * Possible formats for a UCalendar's display name | |
750 | * @stable ICU 2.0 | |
751 | */ | |
752 | enum UCalendarDisplayNameType { | |
753 | /** Standard display name */ | |
754 | UCAL_STANDARD, | |
755 | /** Short standard display name */ | |
756 | UCAL_SHORT_STANDARD, | |
757 | /** Daylight savings display name */ | |
758 | UCAL_DST, | |
759 | /** Short daylight savings display name */ | |
760 | UCAL_SHORT_DST | |
761 | }; | |
762 | ||
763 | /** @stable ICU 2.0 */ | |
764 | typedef enum UCalendarDisplayNameType UCalendarDisplayNameType; | |
765 | ||
766 | /** | |
767 | * Get the display name for a UCalendar's TimeZone. | |
768 | * A display name is suitable for presentation to a user. | |
769 | * @param cal The UCalendar to query. | |
770 | * @param type The desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD, | |
771 | * UCAL_DST, UCAL_SHORT_DST | |
772 | * @param locale The desired locale for the display name. | |
773 | * @param result A pointer to a buffer to receive the formatted number. | |
774 | * @param resultLength The maximum size of result. | |
775 | * @param status A pointer to an UErrorCode to receive any errors | |
776 | * @return The total buffer size needed; if greater than resultLength, the output was truncated. | |
777 | * @stable ICU 2.0 | |
778 | */ | |
374ca955 | 779 | U_STABLE int32_t U_EXPORT2 |
b75a7d8f A |
780 | ucal_getTimeZoneDisplayName(const UCalendar* cal, |
781 | UCalendarDisplayNameType type, | |
782 | const char* locale, | |
783 | UChar* result, | |
784 | int32_t resultLength, | |
785 | UErrorCode* status); | |
786 | ||
787 | /** | |
788 | * Determine if a UCalendar is currently in daylight savings time. | |
789 | * Daylight savings time is not used in all parts of the world. | |
790 | * @param cal The UCalendar to query. | |
791 | * @param status A pointer to an UErrorCode to receive any errors | |
792 | * @return TRUE if cal is currently in daylight savings time, FALSE otherwise | |
793 | * @stable ICU 2.0 | |
794 | */ | |
374ca955 | 795 | U_STABLE UBool U_EXPORT2 |
b75a7d8f A |
796 | ucal_inDaylightTime(const UCalendar* cal, |
797 | UErrorCode* status ); | |
798 | ||
73c04bcf A |
799 | /** |
800 | * Sets the GregorianCalendar change date. This is the point when the switch from | |
801 | * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October | |
802 | * 15, 1582. Previous to this time and date will be Julian dates. | |
803 | * | |
804 | * This function works only for Gregorian calendars. If the UCalendar is not | |
805 | * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR | |
806 | * error code is set. | |
807 | * | |
808 | * @param cal The calendar object. | |
809 | * @param date The given Gregorian cutover date. | |
810 | * @param pErrorCode Pointer to a standard ICU error code. Its input value must | |
811 | * pass the U_SUCCESS() test, or else the function returns | |
812 | * immediately. Check for U_FAILURE() on output or use with | |
813 | * function chaining. (See User Guide for details.) | |
814 | * | |
815 | * @see GregorianCalendar::setGregorianChange | |
816 | * @see ucal_getGregorianChange | |
46f4442e | 817 | * @stable ICU 3.6 |
73c04bcf | 818 | */ |
46f4442e | 819 | U_STABLE void U_EXPORT2 |
73c04bcf A |
820 | ucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode); |
821 | ||
822 | /** | |
823 | * Gets the Gregorian Calendar change date. This is the point when the switch from | |
824 | * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October | |
825 | * 15, 1582. Previous to this time and date will be Julian dates. | |
826 | * | |
827 | * This function works only for Gregorian calendars. If the UCalendar is not | |
828 | * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR | |
829 | * error code is set. | |
830 | * | |
831 | * @param cal The calendar object. | |
832 | * @param pErrorCode Pointer to a standard ICU error code. Its input value must | |
833 | * pass the U_SUCCESS() test, or else the function returns | |
834 | * immediately. Check for U_FAILURE() on output or use with | |
835 | * function chaining. (See User Guide for details.) | |
836 | * @return The Gregorian cutover time for this calendar. | |
837 | * | |
838 | * @see GregorianCalendar::getGregorianChange | |
839 | * @see ucal_setGregorianChange | |
46f4442e | 840 | * @stable ICU 3.6 |
73c04bcf | 841 | */ |
46f4442e | 842 | U_STABLE UDate U_EXPORT2 |
73c04bcf A |
843 | ucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode); |
844 | ||
b75a7d8f A |
845 | /** |
846 | * Types of UCalendar attributes | |
847 | * @stable ICU 2.0 | |
848 | */ | |
849 | enum UCalendarAttribute { | |
4388f060 A |
850 | /** |
851 | * Lenient parsing | |
852 | * @stable ICU 2.0 | |
853 | */ | |
b75a7d8f | 854 | UCAL_LENIENT, |
4388f060 A |
855 | /** |
856 | * First day of week | |
857 | * @stable ICU 2.0 | |
858 | */ | |
b75a7d8f | 859 | UCAL_FIRST_DAY_OF_WEEK, |
4388f060 A |
860 | /** |
861 | * Minimum number of days in first week | |
862 | * @stable ICU 2.0 | |
863 | */ | |
b75a7d8f | 864 | UCAL_MINIMAL_DAYS_IN_FIRST_WEEK |
4388f060 A |
865 | #ifndef U_HIDE_DRAFT_API |
866 | , | |
867 | /** | |
868 | * The behavior for handling wall time repeating multiple times | |
869 | * at negative time zone offset transitions | |
870 | * @draft ICU 49 | |
871 | */ | |
872 | UCAL_REPEATED_WALL_TIME, | |
873 | /** | |
874 | * The behavior for handling skipped wall time at positive time | |
875 | * zone offset transitions. | |
876 | * @draft ICU 49 | |
877 | */ | |
878 | UCAL_SKIPPED_WALL_TIME | |
879 | #endif /* U_HIDE_DRAFT_API */ | |
b75a7d8f A |
880 | }; |
881 | ||
882 | /** @stable ICU 2.0 */ | |
883 | typedef enum UCalendarAttribute UCalendarAttribute; | |
884 | ||
4388f060 A |
885 | /** |
886 | * Options for handling ambiguous wall time at time zone | |
887 | * offset transitions. | |
888 | * @draft ICU 49 | |
889 | */ | |
890 | enum UCalendarWallTimeOption { | |
891 | /** | |
892 | * An ambiguous wall time to be interpreted as the latest. | |
893 | * This option is valid for UCAL_REPEATED_WALL_TIME and | |
894 | * UCAL_SKIPPED_WALL_TIME. | |
895 | * @draft ICU 49 | |
896 | */ | |
897 | UCAL_WALLTIME_LAST | |
898 | #ifndef U_HIDE_DRAFT_API | |
899 | , | |
900 | /** | |
901 | * An ambiguous wall time to be interpreted as the earliest. | |
902 | * This option is valid for UCAL_REPEATED_WALL_TIME and | |
903 | * UCAL_SKIPPED_WALL_TIME. | |
904 | * @draft ICU 49 | |
905 | */ | |
906 | UCAL_WALLTIME_FIRST, | |
907 | /** | |
908 | * An ambiguous wall time to be interpreted as the next valid | |
909 | * wall time. This option is valid for UCAL_SKIPPED_WALL_TIME. | |
910 | * @draft ICU 49 | |
911 | */ | |
912 | UCAL_WALLTIME_NEXT_VALID | |
913 | #endif /* U_HIDE_DRAFT_API */ | |
914 | }; | |
915 | /** @draft ICU 49 */ | |
916 | typedef enum UCalendarWallTimeOption UCalendarWallTimeOption; | |
917 | ||
b75a7d8f A |
918 | /** |
919 | * Get a numeric attribute associated with a UCalendar. | |
920 | * Numeric attributes include the first day of the week, or the minimal numbers | |
921 | * of days in the first week of the month. | |
922 | * @param cal The UCalendar to query. | |
923 | * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK, | |
4388f060 | 924 | * UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, UCAL_REPEATED_WALL_TIME or UCAL_SKIPPED_WALL_TIME |
b75a7d8f A |
925 | * @return The value of attr. |
926 | * @see ucal_setAttribute | |
927 | * @stable ICU 2.0 | |
928 | */ | |
374ca955 | 929 | U_STABLE int32_t U_EXPORT2 |
b75a7d8f A |
930 | ucal_getAttribute(const UCalendar* cal, |
931 | UCalendarAttribute attr); | |
932 | ||
933 | /** | |
934 | * Set a numeric attribute associated with a UCalendar. | |
935 | * Numeric attributes include the first day of the week, or the minimal numbers | |
936 | * of days in the first week of the month. | |
937 | * @param cal The UCalendar to set. | |
938 | * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK, | |
4388f060 | 939 | * UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, UCAL_REPEATED_WALL_TIME or UCAL_SKIPPED_WALL_TIME |
b75a7d8f A |
940 | * @param newValue The new value of attr. |
941 | * @see ucal_getAttribute | |
942 | * @stable ICU 2.0 | |
943 | */ | |
374ca955 | 944 | U_STABLE void U_EXPORT2 |
b75a7d8f A |
945 | ucal_setAttribute(UCalendar* cal, |
946 | UCalendarAttribute attr, | |
947 | int32_t newValue); | |
948 | ||
949 | /** | |
950 | * Get a locale for which calendars are available. | |
951 | * A UCalendar in a locale returned by this function will contain the correct | |
952 | * day and month names for the locale. | |
729e4ab9 | 953 | * @param localeIndex The index of the desired locale. |
b75a7d8f A |
954 | * @return A locale for which calendars are available, or 0 if none. |
955 | * @see ucal_countAvailable | |
956 | * @stable ICU 2.0 | |
957 | */ | |
374ca955 | 958 | U_STABLE const char* U_EXPORT2 |
729e4ab9 | 959 | ucal_getAvailable(int32_t localeIndex); |
b75a7d8f A |
960 | |
961 | /** | |
962 | * Determine how many locales have calendars available. | |
963 | * This function is most useful as determining the loop ending condition for | |
374ca955 | 964 | * calls to \ref ucal_getAvailable. |
b75a7d8f A |
965 | * @return The number of locales for which calendars are available. |
966 | * @see ucal_getAvailable | |
967 | * @stable ICU 2.0 | |
968 | */ | |
374ca955 | 969 | U_STABLE int32_t U_EXPORT2 |
b75a7d8f A |
970 | ucal_countAvailable(void); |
971 | ||
972 | /** | |
973 | * Get a UCalendar's current time in millis. | |
974 | * The time is represented as milliseconds from the epoch. | |
975 | * @param cal The UCalendar to query. | |
976 | * @param status A pointer to an UErrorCode to receive any errors | |
977 | * @return The calendar's current time in millis. | |
978 | * @see ucal_setMillis | |
979 | * @see ucal_setDate | |
980 | * @see ucal_setDateTime | |
981 | * @stable ICU 2.0 | |
982 | */ | |
374ca955 | 983 | U_STABLE UDate U_EXPORT2 |
b75a7d8f A |
984 | ucal_getMillis(const UCalendar* cal, |
985 | UErrorCode* status); | |
986 | ||
987 | /** | |
988 | * Set a UCalendar's current time in millis. | |
989 | * The time is represented as milliseconds from the epoch. | |
990 | * @param cal The UCalendar to set. | |
991 | * @param dateTime The desired date and time. | |
992 | * @param status A pointer to an UErrorCode to receive any errors | |
993 | * @see ucal_getMillis | |
994 | * @see ucal_setDate | |
995 | * @see ucal_setDateTime | |
996 | * @stable ICU 2.0 | |
997 | */ | |
374ca955 | 998 | U_STABLE void U_EXPORT2 |
b75a7d8f A |
999 | ucal_setMillis(UCalendar* cal, |
1000 | UDate dateTime, | |
1001 | UErrorCode* status ); | |
1002 | ||
1003 | /** | |
1004 | * Set a UCalendar's current date. | |
1005 | * The date is represented as a series of 32-bit integers. | |
1006 | * @param cal The UCalendar to set. | |
1007 | * @param year The desired year. | |
1008 | * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY, | |
1009 | * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER | |
1010 | * @param date The desired day of the month. | |
1011 | * @param status A pointer to an UErrorCode to receive any errors | |
1012 | * @see ucal_getMillis | |
1013 | * @see ucal_setMillis | |
1014 | * @see ucal_setDateTime | |
1015 | * @stable ICU 2.0 | |
1016 | */ | |
374ca955 | 1017 | U_STABLE void U_EXPORT2 |
b75a7d8f A |
1018 | ucal_setDate(UCalendar* cal, |
1019 | int32_t year, | |
1020 | int32_t month, | |
1021 | int32_t date, | |
1022 | UErrorCode* status); | |
1023 | ||
1024 | /** | |
1025 | * Set a UCalendar's current date. | |
1026 | * The date is represented as a series of 32-bit integers. | |
1027 | * @param cal The UCalendar to set. | |
1028 | * @param year The desired year. | |
1029 | * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY, | |
1030 | * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER | |
1031 | * @param date The desired day of the month. | |
1032 | * @param hour The desired hour of day. | |
1033 | * @param minute The desired minute. | |
1034 | * @param second The desirec second. | |
1035 | * @param status A pointer to an UErrorCode to receive any errors | |
1036 | * @see ucal_getMillis | |
1037 | * @see ucal_setMillis | |
1038 | * @see ucal_setDate | |
1039 | * @stable ICU 2.0 | |
1040 | */ | |
374ca955 | 1041 | U_STABLE void U_EXPORT2 |
b75a7d8f A |
1042 | ucal_setDateTime(UCalendar* cal, |
1043 | int32_t year, | |
1044 | int32_t month, | |
1045 | int32_t date, | |
1046 | int32_t hour, | |
1047 | int32_t minute, | |
1048 | int32_t second, | |
1049 | UErrorCode* status); | |
1050 | ||
1051 | /** | |
1052 | * Returns TRUE if two UCalendars are equivalent. Equivalent | |
1053 | * UCalendars will behave identically, but they may be set to | |
1054 | * different times. | |
1055 | * @param cal1 The first of the UCalendars to compare. | |
1056 | * @param cal2 The second of the UCalendars to compare. | |
1057 | * @return TRUE if cal1 and cal2 are equivalent, FALSE otherwise. | |
1058 | * @stable ICU 2.0 | |
1059 | */ | |
374ca955 | 1060 | U_STABLE UBool U_EXPORT2 |
b75a7d8f A |
1061 | ucal_equivalentTo(const UCalendar* cal1, |
1062 | const UCalendar* cal2); | |
1063 | ||
1064 | /** | |
1065 | * Add a specified signed amount to a particular field in a UCalendar. | |
1066 | * This can modify more significant fields in the calendar. | |
1067 | * @param cal The UCalendar to which to add. | |
1068 | * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, | |
1069 | * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, | |
1070 | * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, | |
1071 | * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. | |
1072 | * @param amount The signed amount to add to field. If the amount causes the value | |
1073 | * to exceed to maximum or minimum values for that field, other fields are modified | |
1074 | * to preserve the magnitude of the change. | |
1075 | * @param status A pointer to an UErrorCode to receive any errors | |
1076 | * @see ucal_roll | |
1077 | * @stable ICU 2.0 | |
1078 | */ | |
374ca955 | 1079 | U_STABLE void U_EXPORT2 |
b75a7d8f A |
1080 | ucal_add(UCalendar* cal, |
1081 | UCalendarDateFields field, | |
1082 | int32_t amount, | |
1083 | UErrorCode* status); | |
1084 | ||
1085 | /** | |
1086 | * Add a specified signed amount to a particular field in a UCalendar. | |
1087 | * This will not modify more significant fields in the calendar. | |
1088 | * @param cal The UCalendar to which to add. | |
1089 | * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, | |
1090 | * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, | |
1091 | * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, | |
1092 | * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. | |
1093 | * @param amount The signed amount to add to field. If the amount causes the value | |
1094 | * to exceed to maximum or minimum values for that field, the field is pinned to a permissible | |
1095 | * value. | |
1096 | * @param status A pointer to an UErrorCode to receive any errors | |
1097 | * @see ucal_add | |
1098 | * @stable ICU 2.0 | |
1099 | */ | |
374ca955 | 1100 | U_STABLE void U_EXPORT2 |
b75a7d8f A |
1101 | ucal_roll(UCalendar* cal, |
1102 | UCalendarDateFields field, | |
1103 | int32_t amount, | |
1104 | UErrorCode* status); | |
1105 | ||
1106 | /** | |
1107 | * Get the current value of a field from a UCalendar. | |
1108 | * All fields are represented as 32-bit integers. | |
1109 | * @param cal The UCalendar to query. | |
1110 | * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, | |
1111 | * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, | |
1112 | * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, | |
1113 | * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. | |
1114 | * @param status A pointer to an UErrorCode to receive any errors | |
1115 | * @return The value of the desired field. | |
1116 | * @see ucal_set | |
1117 | * @see ucal_isSet | |
1118 | * @see ucal_clearField | |
1119 | * @see ucal_clear | |
1120 | * @stable ICU 2.0 | |
1121 | */ | |
374ca955 | 1122 | U_STABLE int32_t U_EXPORT2 |
b75a7d8f A |
1123 | ucal_get(const UCalendar* cal, |
1124 | UCalendarDateFields field, | |
1125 | UErrorCode* status ); | |
1126 | ||
1127 | /** | |
1128 | * Set the value of a field in a UCalendar. | |
1129 | * All fields are represented as 32-bit integers. | |
1130 | * @param cal The UCalendar to set. | |
1131 | * @param field The field to set; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, | |
1132 | * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, | |
1133 | * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, | |
1134 | * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. | |
1135 | * @param value The desired value of field. | |
1136 | * @see ucal_get | |
1137 | * @see ucal_isSet | |
1138 | * @see ucal_clearField | |
1139 | * @see ucal_clear | |
1140 | * @stable ICU 2.0 | |
1141 | */ | |
374ca955 | 1142 | U_STABLE void U_EXPORT2 |
b75a7d8f A |
1143 | ucal_set(UCalendar* cal, |
1144 | UCalendarDateFields field, | |
1145 | int32_t value); | |
1146 | ||
1147 | /** | |
1148 | * Determine if a field in a UCalendar is set. | |
1149 | * All fields are represented as 32-bit integers. | |
1150 | * @param cal The UCalendar to query. | |
1151 | * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, | |
1152 | * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, | |
1153 | * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, | |
1154 | * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. | |
1155 | * @return TRUE if field is set, FALSE otherwise. | |
1156 | * @see ucal_get | |
1157 | * @see ucal_set | |
1158 | * @see ucal_clearField | |
1159 | * @see ucal_clear | |
1160 | * @stable ICU 2.0 | |
1161 | */ | |
374ca955 | 1162 | U_STABLE UBool U_EXPORT2 |
b75a7d8f A |
1163 | ucal_isSet(const UCalendar* cal, |
1164 | UCalendarDateFields field); | |
1165 | ||
1166 | /** | |
1167 | * Clear a field in a UCalendar. | |
1168 | * All fields are represented as 32-bit integers. | |
1169 | * @param cal The UCalendar containing the field to clear. | |
1170 | * @param field The field to clear; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, | |
1171 | * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, | |
1172 | * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, | |
1173 | * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. | |
1174 | * @see ucal_get | |
1175 | * @see ucal_set | |
1176 | * @see ucal_isSet | |
1177 | * @see ucal_clear | |
1178 | * @stable ICU 2.0 | |
1179 | */ | |
374ca955 | 1180 | U_STABLE void U_EXPORT2 |
b75a7d8f A |
1181 | ucal_clearField(UCalendar* cal, |
1182 | UCalendarDateFields field); | |
1183 | ||
1184 | /** | |
1185 | * Clear all fields in a UCalendar. | |
1186 | * All fields are represented as 32-bit integers. | |
1187 | * @param calendar The UCalendar to clear. | |
1188 | * @see ucal_get | |
1189 | * @see ucal_set | |
1190 | * @see ucal_isSet | |
1191 | * @see ucal_clearField | |
1192 | * @stable ICU 2.0 | |
1193 | */ | |
374ca955 | 1194 | U_STABLE void U_EXPORT2 |
b75a7d8f A |
1195 | ucal_clear(UCalendar* calendar); |
1196 | ||
1197 | /** | |
1198 | * Possible limit values for a UCalendar | |
1199 | * @stable ICU 2.0 | |
1200 | */ | |
1201 | enum UCalendarLimitType { | |
1202 | /** Minimum value */ | |
1203 | UCAL_MINIMUM, | |
1204 | /** Maximum value */ | |
1205 | UCAL_MAXIMUM, | |
1206 | /** Greatest minimum value */ | |
1207 | UCAL_GREATEST_MINIMUM, | |
1208 | /** Leaest maximum value */ | |
1209 | UCAL_LEAST_MAXIMUM, | |
1210 | /** Actual minimum value */ | |
1211 | UCAL_ACTUAL_MINIMUM, | |
1212 | /** Actual maximum value */ | |
1213 | UCAL_ACTUAL_MAXIMUM | |
1214 | }; | |
1215 | ||
1216 | /** @stable ICU 2.0 */ | |
1217 | typedef enum UCalendarLimitType UCalendarLimitType; | |
1218 | ||
1219 | /** | |
1220 | * Determine a limit for a field in a UCalendar. | |
1221 | * A limit is a maximum or minimum value for a field. | |
1222 | * @param cal The UCalendar to query. | |
1223 | * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, | |
1224 | * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, | |
1225 | * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, | |
1226 | * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. | |
1227 | * @param type The desired critical point; one of UCAL_MINIMUM, UCAL_MAXIMUM, UCAL_GREATEST_MINIMUM, | |
1228 | * UCAL_LEAST_MAXIMUM, UCAL_ACTUAL_MINIMUM, UCAL_ACTUAL_MAXIMUM | |
1229 | * @param status A pointer to an UErrorCode to receive any errors. | |
1230 | * @return The requested value. | |
1231 | * @stable ICU 2.0 | |
1232 | */ | |
374ca955 | 1233 | U_STABLE int32_t U_EXPORT2 |
b75a7d8f A |
1234 | ucal_getLimit(const UCalendar* cal, |
1235 | UCalendarDateFields field, | |
1236 | UCalendarLimitType type, | |
1237 | UErrorCode* status); | |
1238 | ||
374ca955 A |
1239 | /** Get the locale for this calendar object. You can choose between valid and actual locale. |
1240 | * @param cal The calendar object | |
1241 | * @param type type of the locale we're looking for (valid or actual) | |
1242 | * @param status error code for the operation | |
1243 | * @return the locale name | |
73c04bcf | 1244 | * @stable ICU 2.8 |
374ca955 | 1245 | */ |
73c04bcf | 1246 | U_STABLE const char * U_EXPORT2 |
374ca955 | 1247 | ucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode* status); |
b75a7d8f | 1248 | |
46f4442e A |
1249 | /** |
1250 | * Returns the timezone data version currently used by ICU. | |
1251 | * @param status error code for the operation | |
1252 | * @return the version string, such as "2007f" | |
1253 | * @stable ICU 3.8 | |
1254 | */ | |
729e4ab9 | 1255 | U_STABLE const char * U_EXPORT2 |
46f4442e A |
1256 | ucal_getTZDataVersion(UErrorCode* status); |
1257 | ||
1258 | /** | |
1259 | * Returns the canonical system timezone ID or the normalized | |
1260 | * custom time zone ID for the given time zone ID. | |
1261 | * @param id The input timezone ID to be canonicalized. | |
1262 | * @param len The length of id, or -1 if null-terminated. | |
1263 | * @param result The buffer receives the canonical system timezone ID | |
1264 | * or the custom timezone ID in normalized format. | |
1265 | * @param resultCapacity The capacity of the result buffer. | |
1266 | * @param isSystemID Receives if the given ID is a known system | |
1267 | * timezone ID. | |
1268 | * @param status Recevies the status. When the given timezone ID | |
1269 | * is neither a known system time zone ID nor a | |
1270 | * valid custom timezone ID, U_ILLEGAL_ARGUMENT_ERROR | |
1271 | * is set. | |
1272 | * @return The result string length, not including the terminating | |
1273 | * null. | |
729e4ab9 | 1274 | * @stable ICU 4.0 |
46f4442e | 1275 | */ |
729e4ab9 | 1276 | U_STABLE int32_t U_EXPORT2 |
46f4442e A |
1277 | ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len, |
1278 | UChar* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status); | |
1279 | /** | |
1280 | * Get the resource keyword value string designating the calendar type for the UCalendar. | |
1281 | * @param cal The UCalendar to query. | |
1282 | * @param status The error code for the operation. | |
1283 | * @return The resource keyword value string. | |
729e4ab9 | 1284 | * @stable ICU 4.2 |
46f4442e | 1285 | */ |
729e4ab9 | 1286 | U_STABLE const char * U_EXPORT2 |
46f4442e A |
1287 | ucal_getType(const UCalendar *cal, UErrorCode* status); |
1288 | ||
1289 | /** | |
729e4ab9 A |
1290 | * Given a key and a locale, returns an array of string values in a preferred |
1291 | * order that would make a difference. These are all and only those values where | |
1292 | * the open (creation) of the service with the locale formed from the input locale | |
1293 | * plus input keyword and that value has different behavior than creation with the | |
1294 | * input locale alone. | |
1295 | * @param key one of the keys supported by this service. For now, only | |
1296 | * "calendar" is supported. | |
1297 | * @param locale the locale | |
1298 | * @param commonlyUsed if set to true it will return only commonly used values | |
1299 | * with the given locale in preferred order. Otherwise, | |
1300 | * it will return all the available values for the locale. | |
1301 | * @param status error status | |
1302 | * @return a string enumeration over keyword values for the given key and the locale. | |
1303 | * @stable ICU 4.2 | |
1304 | */ | |
1305 | U_STABLE UEnumeration* U_EXPORT2 | |
1306 | ucal_getKeywordValuesForLocale(const char* key, | |
1307 | const char* locale, | |
1308 | UBool commonlyUsed, | |
1309 | UErrorCode* status); | |
1310 | ||
1311 | ||
1312 | /** Weekday types, as returned by ucal_getDayOfWeekType(). | |
1313 | * @stable ICU 4.4 | |
1314 | */ | |
1315 | enum UCalendarWeekdayType { | |
1316 | /** | |
1317 | * Designates a full weekday (no part of the day is included in the weekend). | |
1318 | * @stable ICU 4.4 | |
1319 | */ | |
1320 | UCAL_WEEKDAY, | |
1321 | /** | |
1322 | * Designates a full weekend day (the entire day is included in the weekend). | |
1323 | * @stable ICU 4.4 | |
1324 | */ | |
1325 | UCAL_WEEKEND, | |
1326 | /** | |
1327 | * Designates a day that starts as a weekday and transitions to the weekend. | |
1328 | * Call ucal_getWeekendTransition() to get the time of transition. | |
1329 | * @stable ICU 4.4 | |
1330 | */ | |
1331 | UCAL_WEEKEND_ONSET, | |
1332 | /** | |
1333 | * Designates a day that starts as the weekend and transitions to a weekday. | |
1334 | * Call ucal_getWeekendTransition() to get the time of transition. | |
1335 | * @stable ICU 4.4 | |
1336 | */ | |
1337 | UCAL_WEEKEND_CEASE | |
1338 | }; | |
1339 | ||
1340 | /** @stable ICU 4.4 */ | |
1341 | typedef enum UCalendarWeekdayType UCalendarWeekdayType; | |
1342 | ||
1343 | /** | |
1344 | * Returns whether the given day of the week is a weekday, a | |
1345 | * weekend day, or a day that transitions from one to the other, | |
1346 | * in this calendar system. If a transition occurs at midnight, | |
1347 | * then the days before and after the transition will have the | |
1348 | * type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time | |
1349 | * other than midnight, then the day of the transition will have | |
1350 | * the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the | |
1351 | * method getWeekendTransition() will return the point of | |
1352 | * transition. | |
1353 | * @param cal The UCalendar to query. | |
1354 | * @param dayOfWeek The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY). | |
1355 | * @param status The error code for the operation. | |
1356 | * @return The UCalendarWeekdayType for the day of the week. | |
1357 | * @stable ICU 4.4 | |
1358 | */ | |
1359 | U_STABLE UCalendarWeekdayType U_EXPORT2 | |
1360 | ucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode* status); | |
1361 | ||
1362 | /** | |
1363 | * Returns the time during the day at which the weekend begins or ends in | |
1364 | * this calendar system. If ucal_getDayOfWeekType() rerturns UCAL_WEEKEND_ONSET | |
1365 | * for the specified dayOfWeek, return the time at which the weekend begins. | |
1366 | * If ucal_getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek, | |
1367 | * return the time at which the weekend ends. If ucal_getDayOfWeekType() returns | |
1368 | * some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition | |
1369 | * (U_ILLEGAL_ARGUMENT_ERROR). | |
1370 | * @param cal The UCalendar to query. | |
1371 | * @param dayOfWeek The day of the week for which the weekend transition time is | |
1372 | * desired (UCAL_SUNDAY..UCAL_SATURDAY). | |
1373 | * @param status The error code for the operation. | |
1374 | * @return The milliseconds after midnight at which the weekend begins or ends. | |
1375 | * @stable ICU 4.4 | |
1376 | */ | |
1377 | U_STABLE int32_t U_EXPORT2 | |
1378 | ucal_getWeekendTransition(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode *status); | |
1379 | ||
1380 | /** | |
1381 | * Returns TRUE if the given UDate is in the weekend in | |
1382 | * this calendar system. | |
1383 | * @param cal The UCalendar to query. | |
1384 | * @param date The UDate in question. | |
1385 | * @param status The error code for the operation. | |
1386 | * @return TRUE if the given UDate is in the weekend in | |
1387 | * this calendar system, FALSE otherwise. | |
1388 | * @stable ICU 4.4 | |
46f4442e | 1389 | */ |
729e4ab9 A |
1390 | U_STABLE UBool U_EXPORT2 |
1391 | ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status); | |
1392 | ||
1393 | /** | |
1394 | * Return the difference between the target time and the time this calendar object is currently set to. | |
1395 | * If the target time is after the current calendar setting, the the returned value will be positive. | |
1396 | * The field parameter specifies the units of the return value. For example, if field is UCAL_MONTH | |
1397 | * and ucal_getFieldDifference returns 3, then the target time is 3 to less than 4 months after the | |
1398 | * current calendar setting. | |
1399 | * | |
1400 | * As a side effect of this call, this calendar is advanced toward target by the given amount. That is, | |
1401 | * calling this function has the side effect of calling ucal_add on this calendar with the specified | |
1402 | * field and an amount equal to the return value from this function. | |
1403 | * | |
1404 | * A typical way of using this function is to call it first with the largest field of interest, then | |
1405 | * with progressively smaller fields. | |
1406 | * | |
1407 | * @param cal The UCalendar to compare and update. | |
1408 | * @param target The target date to compare to the current calendar setting. | |
1409 | * @param field The field to compare; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, | |
1410 | * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, | |
1411 | * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, | |
1412 | * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. | |
1413 | * @param status A pointer to an UErrorCode to receive any errors | |
1414 | * @return The date difference for the specified field. | |
4388f060 | 1415 | * @stable ICU 4.8 |
729e4ab9 | 1416 | */ |
4388f060 | 1417 | U_DRAFT int32_t U_EXPORT2 |
729e4ab9 A |
1418 | ucal_getFieldDifference(UCalendar* cal, |
1419 | UDate target, | |
1420 | UCalendarDateFields field, | |
1421 | UErrorCode* status); | |
1422 | ||
b75a7d8f A |
1423 | #endif /* #if !UCONFIG_NO_FORMATTING */ |
1424 | ||
1425 | #endif |