xref: /aosp_15_r20/external/icu/libandroidicu/include/unicode/ucal.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4  *******************************************************************************
5  * Copyright (C) 1996-2015, International Business Machines Corporation and
6  * others. All Rights Reserved.
7  *******************************************************************************
8  */
9 
10 #ifndef UCAL_H
11 #define UCAL_H
12 
13 #include "unicode/utypes.h"
14 #include "unicode/uenum.h"
15 #include "unicode/uloc.h"
16 
17 #if U_SHOW_CPLUSPLUS_API
18 #include "unicode/localpointer.h"
19 #endif   // U_SHOW_CPLUSPLUS_API
20 
21 #if !UCONFIG_NO_FORMATTING
22 
23 /**
24  * \file
25  * \brief C API: Calendar
26  *
27  * <h2>Calendar C API</h2>
28  *
29  * UCalendar C API is used  for converting between a <code>UDate</code> object
30  * and a set of integer fields such as <code>UCAL_YEAR</code>, <code>UCAL_MONTH</code>,
31  * <code>UCAL_DAY</code>, <code>UCAL_HOUR</code>, and so on.
32  * (A <code>UDate</code> object represents a specific instant in
33  * time with millisecond precision. See UDate
34  * for information about the <code>UDate</code> .)
35  *
36  * <p>
37  * Types of <code>UCalendar</code> interpret a <code>UDate</code>
38  * according to the rules of a specific calendar system. The C API
39  * provides the enum UCalendarType with UCAL_TRADITIONAL and
40  * UCAL_GREGORIAN.
41  * <p>
42  * Like other locale-sensitive C API, calendar API  provides a
43  * function, <code>ucal_open()</code>, which returns a pointer to
44  * <code>UCalendar</code> whose time fields have been initialized
45  * with the current date and time. We need to specify the type of
46  * calendar to be opened and the  timezoneId.
47  * \htmlonly<blockquote>\endhtmlonly
48  * <pre>
49  * \code
50  * UCalendar *caldef;
51  * UChar *tzId;
52  * UErrorCode status;
53  * tzId=(UChar*)malloc(sizeof(UChar) * (strlen("PST") +1) );
54  * u_uastrcpy(tzId, "PST");
55  * caldef=ucal_open(tzID, u_strlen(tzID), NULL, UCAL_TRADITIONAL, &status);
56  * \endcode
57  * </pre>
58  * \htmlonly</blockquote>\endhtmlonly
59  *
60  * <p>
61  * A <code>UCalendar</code> object can produce all the time field values
62  * needed to implement the date-time formatting for a particular language
63  * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
64  *
65  * <p>
66  * When computing a <code>UDate</code> from time fields, two special circumstances
67  * may arise: there may be insufficient information to compute the
68  * <code>UDate</code> (such as only year and month but no day in the month),
69  * or there may be inconsistent information (such as "Tuesday, July 15, 1996"
70  * -- July 15, 1996 is actually a Monday).
71  *
72  * <p>
73  * <strong>Insufficient information.</strong> The calendar will use default
74  * information to specify the missing fields. This may vary by calendar; for
75  * the Gregorian calendar, the default for a field is the same as that of the
76  * start of the epoch: i.e., UCAL_YEAR = 1970, UCAL_MONTH = JANUARY, UCAL_DATE = 1, etc.
77  *
78  * <p>
79  * <strong>Inconsistent information.</strong> If fields conflict, the calendar
80  * will give preference to fields set more recently. For example, when
81  * determining the day, the calendar will look for one of the following
82  * combinations of fields.  The most recent combination, as determined by the
83  * most recently set single field, will be used.
84  *
85  * \htmlonly<blockquote>\endhtmlonly
86  * <pre>
87  * \code
88  * UCAL_MONTH + UCAL_DAY_OF_MONTH
89  * UCAL_MONTH + UCAL_WEEK_OF_MONTH + UCAL_DAY_OF_WEEK
90  * UCAL_MONTH + UCAL_DAY_OF_WEEK_IN_MONTH + UCAL_DAY_OF_WEEK
91  * UCAL_DAY_OF_YEAR
92  * UCAL_DAY_OF_WEEK + UCAL_WEEK_OF_YEAR
93  * \endcode
94  * </pre>
95  * \htmlonly</blockquote>\endhtmlonly
96  *
97  * For the time of day:
98  *
99  * \htmlonly<blockquote>\endhtmlonly
100  * <pre>
101  * \code
102  * UCAL_HOUR_OF_DAY
103  * UCAL_AM_PM + UCAL_HOUR
104  * \endcode
105  * </pre>
106  * \htmlonly</blockquote>\endhtmlonly
107  *
108  * <p>
109  * <strong>Note:</strong> for some non-Gregorian calendars, different
110  * fields may be necessary for complete disambiguation. For example, a full
111  * specification of the historical Arabic astronomical calendar requires year,
112  * month, day-of-month <em>and</em> day-of-week in some cases.
113  *
114  * <p>
115  * <strong>Note:</strong> There are certain possible ambiguities in
116  * interpretation of certain singular times, which are resolved in the
117  * following ways:
118  * <ol>
119  *     <li> 24:00:00 "belongs" to the following day. That is,
120  *          23:59 on Dec 31, 1969 &lt; 24:00 on Jan 1, 1970 &lt; 24:01:00 on Jan 1, 1970
121  *
122  *     <li> Although historically not precise, midnight also belongs to "am",
123  *          and noon belongs to "pm", so on the same day,
124  *          12:00 am (midnight) &lt; 12:01 am, and 12:00 pm (noon) &lt; 12:01 pm
125  * </ol>
126  *
127  * <p>
128  * The date or time format strings are not part of the definition of a
129  * calendar, as those must be modifiable or overridable by the user at
130  * runtime. Use {@link icu::DateFormat}
131  * to format dates.
132  *
133  * <p>
134  * <code>Calendar</code> provides an API for field "rolling", where fields
135  * can be incremented or decremented, but wrap around. For example, rolling the
136  * month up in the date <code>December 12, <b>1996</b></code> results in
137  * <code>January 12, <b>1996</b></code>.
138  *
139  * <p>
140  * <code>Calendar</code> also provides a date arithmetic function for
141  * adding the specified (signed) amount of time to a particular time field.
142  * For example, subtracting 5 days from the date <code>September 12, 1996</code>
143  * results in <code>September 7, 1996</code>.
144  *
145  * <p>
146  * The Japanese calendar uses a combination of era name and year number.
147  * When an emperor of Japan abdicates and a new emperor ascends the throne,
148  * a new era is declared and year number is reset to 1. Even if the date of
149  * abdication is scheduled ahead of time, the new era name might not be
150  * announced until just before the date. In such case, ICU4C may include
151  * a start date of future era without actual era name, but not enabled
152  * by default. ICU4C users who want to test the behavior of the future era
153  * can enable the tentative era by:
154  * <ul>
155  * <li>Environment variable <code>ICU_ENABLE_TENTATIVE_ERA=true</code>.</li>
156  * </ul>
157  *
158  * @stable ICU 2.0
159  */
160 
161 /**
162  * The time zone ID reserved for unknown time zone.
163  * It behaves like the GMT/UTC time zone but has the special ID "Etc/Unknown".
164  * @stable ICU 4.8
165  */
166 #define UCAL_UNKNOWN_ZONE_ID "Etc/Unknown"
167 
168 /** A calendar.
169  *  For usage in C programs.
170  * @stable ICU 2.0
171  */
172 typedef void* UCalendar;
173 
174 /** Possible types of UCalendars
175  * @stable ICU 2.0
176  */
177 enum UCalendarType {
178   /**
179    * Despite the name, UCAL_TRADITIONAL designates the locale's default calendar,
180    * which may be the Gregorian calendar or some other calendar.
181    * @stable ICU 2.0
182    */
183   UCAL_TRADITIONAL,
184   /**
185    * A better name for UCAL_TRADITIONAL.
186    * @stable ICU 4.2
187    */
188   UCAL_DEFAULT = UCAL_TRADITIONAL,
189   /**
190    * Unambiguously designates the Gregorian calendar for the locale.
191    * @stable ICU 2.0
192    */
193   UCAL_GREGORIAN
194 };
195 
196 /** @stable ICU 2.0 */
197 typedef enum UCalendarType UCalendarType;
198 
199 /** Possible fields in a UCalendar
200  * @stable ICU 2.0
201  */
202 enum UCalendarDateFields {
203   /**
204    * Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar.
205    * This is a calendar-specific value.
206    * @stable ICU 2.6
207    */
208   UCAL_ERA,
209 
210   /**
211    * Field number indicating the year. This is a calendar-specific value.
212    * @stable ICU 2.6
213    */
214   UCAL_YEAR,
215 
216   /**
217    * Field number indicating the month. This is a calendar-specific value.
218    * The first month of the year is
219    * <code>JANUARY</code>; the last depends on the number of months in a year.
220    * @see #UCAL_JANUARY
221    * @see #UCAL_FEBRUARY
222    * @see #UCAL_MARCH
223    * @see #UCAL_APRIL
224    * @see #UCAL_MAY
225    * @see #UCAL_JUNE
226    * @see #UCAL_JULY
227    * @see #UCAL_AUGUST
228    * @see #UCAL_SEPTEMBER
229    * @see #UCAL_OCTOBER
230    * @see #UCAL_NOVEMBER
231    * @see #UCAL_DECEMBER
232    * @see #UCAL_UNDECIMBER
233    * @stable ICU 2.6
234    */
235   UCAL_MONTH,
236 
237   /**
238    * Field number indicating the
239    * week number within the current year.  The first week of the year, as
240    * defined by <code>UCAL_FIRST_DAY_OF_WEEK</code> and <code>UCAL_MINIMAL_DAYS_IN_FIRST_WEEK</code>
241    * attributes, has value 1.  Subclasses define
242    * the value of <code>UCAL_WEEK_OF_YEAR</code> for days before the first week of
243    * the year.
244    * @see ucal_getAttribute
245    * @see ucal_setAttribute
246    * @stable ICU 2.6
247    */
248   UCAL_WEEK_OF_YEAR,
249 
250  /**
251    * Field number indicating the
252    * week number within the current month.  The first week of the month, as
253    * defined by <code>UCAL_FIRST_DAY_OF_WEEK</code> and <code>UCAL_MINIMAL_DAYS_IN_FIRST_WEEK</code>
254    * attributes, has value 1.  Subclasses define
255    * the value of <code>WEEK_OF_MONTH</code> for days before the first week of
256    * the month.
257    * @see ucal_getAttribute
258    * @see ucal_setAttribute
259    * @see #UCAL_FIRST_DAY_OF_WEEK
260    * @see #UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
261    * @stable ICU 2.6
262    */
263   UCAL_WEEK_OF_MONTH,
264 
265  /**
266    * Field number indicating the
267    * day of the month. This is a synonym for <code>DAY_OF_MONTH</code>.
268    * The first day of the month has value 1.
269    * @see #UCAL_DAY_OF_MONTH
270    * @stable ICU 2.6
271    */
272   UCAL_DATE,
273 
274  /**
275    * Field number indicating the day
276    * number within the current year.  The first day of the year has value 1.
277    * @stable ICU 2.6
278    */
279   UCAL_DAY_OF_YEAR,
280 
281  /**
282    * Field number indicating the day
283    * of the week.  This field takes values <code>SUNDAY</code>,
284    * <code>MONDAY</code>, <code>TUESDAY</code>, <code>WEDNESDAY</code>,
285    * <code>THURSDAY</code>, <code>FRIDAY</code>, and <code>SATURDAY</code>.
286    * @see #UCAL_SUNDAY
287    * @see #UCAL_MONDAY
288    * @see #UCAL_TUESDAY
289    * @see #UCAL_WEDNESDAY
290    * @see #UCAL_THURSDAY
291    * @see #UCAL_FRIDAY
292    * @see #UCAL_SATURDAY
293    * @stable ICU 2.6
294    */
295   UCAL_DAY_OF_WEEK,
296 
297  /**
298    * Field number indicating the
299    * ordinal number of the day of the week within the current month. Together
300    * with the <code>DAY_OF_WEEK</code> field, this uniquely specifies a day
301    * within a month.  Unlike <code>WEEK_OF_MONTH</code> and
302    * <code>WEEK_OF_YEAR</code>, this field's value does <em>not</em> depend on
303    * <code>getFirstDayOfWeek()</code> or
304    * <code>getMinimalDaysInFirstWeek()</code>.  <code>DAY_OF_MONTH 1</code>
305    * through <code>7</code> always correspond to <code>DAY_OF_WEEK_IN_MONTH
306    * 1</code>; <code>8</code> through <code>15</code> correspond to
307    * <code>DAY_OF_WEEK_IN_MONTH 2</code>, and so on.
308    * <code>DAY_OF_WEEK_IN_MONTH 0</code> indicates the week before
309    * <code>DAY_OF_WEEK_IN_MONTH 1</code>.  Negative values count back from the
310    * end of the month, so the last Sunday of a month is specified as
311    * <code>DAY_OF_WEEK = SUNDAY, DAY_OF_WEEK_IN_MONTH = -1</code>.  Because
312    * negative values count backward they will usually be aligned differently
313    * within the month than positive values.  For example, if a month has 31
314    * days, <code>DAY_OF_WEEK_IN_MONTH -1</code> will overlap
315    * <code>DAY_OF_WEEK_IN_MONTH 5</code> and the end of <code>4</code>.
316    * @see #UCAL_DAY_OF_WEEK
317    * @see #UCAL_WEEK_OF_MONTH
318    * @stable ICU 2.6
319    */
320   UCAL_DAY_OF_WEEK_IN_MONTH,
321 
322  /**
323    * Field number indicating
324    * whether the <code>HOUR</code> is before or after noon.
325    * E.g., at 10:04:15.250 PM the <code>AM_PM</code> is <code>PM</code>.
326    * @see #UCAL_AM
327    * @see #UCAL_PM
328    * @see #UCAL_HOUR
329    * @stable ICU 2.6
330    */
331   UCAL_AM_PM,
332 
333  /**
334    * Field number indicating the
335    * hour of the morning or afternoon. <code>HOUR</code> is used for the 12-hour
336    * clock.
337    * E.g., at 10:04:15.250 PM the <code>HOUR</code> is 10.
338    * @see #UCAL_AM_PM
339    * @see #UCAL_HOUR_OF_DAY
340    * @stable ICU 2.6
341    */
342   UCAL_HOUR,
343 
344  /**
345    * Field number indicating the
346    * hour of the day. <code>HOUR_OF_DAY</code> is used for the 24-hour clock.
347    * E.g., at 10:04:15.250 PM the <code>HOUR_OF_DAY</code> is 22.
348    * @see #UCAL_HOUR
349    * @stable ICU 2.6
350    */
351   UCAL_HOUR_OF_DAY,
352 
353  /**
354    * Field number indicating the
355    * minute within the hour.
356    * E.g., at 10:04:15.250 PM the <code>UCAL_MINUTE</code> is 4.
357    * @stable ICU 2.6
358    */
359   UCAL_MINUTE,
360 
361  /**
362    * Field number indicating the
363    * second within the minute.
364    * E.g., at 10:04:15.250 PM the <code>UCAL_SECOND</code> is 15.
365    * @stable ICU 2.6
366    */
367   UCAL_SECOND,
368 
369  /**
370    * Field number indicating the
371    * millisecond within the second.
372    * E.g., at 10:04:15.250 PM the <code>UCAL_MILLISECOND</code> is 250.
373    * @stable ICU 2.6
374    */
375   UCAL_MILLISECOND,
376 
377  /**
378    * Field number indicating the
379    * raw offset from GMT in milliseconds.
380    * @stable ICU 2.6
381    */
382   UCAL_ZONE_OFFSET,
383 
384  /**
385    * Field number indicating the
386    * daylight savings offset in milliseconds.
387    * @stable ICU 2.6
388    */
389   UCAL_DST_OFFSET,
390 
391  /**
392    * Field number
393    * indicating the extended year corresponding to the
394    * <code>UCAL_WEEK_OF_YEAR</code> field.  This may be one greater or less
395    * than the value of <code>UCAL_EXTENDED_YEAR</code>.
396    * @stable ICU 2.6
397    */
398   UCAL_YEAR_WOY,
399 
400  /**
401    * Field number
402    * indicating the localized day of week.  This will be a value from 1
403    * to 7 inclusive, with 1 being the localized first day of the week.
404    * @stable ICU 2.6
405    */
406   UCAL_DOW_LOCAL,
407 
408   /**
409    * Year of this calendar system, encompassing all supra-year fields. For example,
410    * in Gregorian/Julian calendars, positive Extended Year values indicate years AD,
411    *  1 BC = 0 extended, 2 BC = -1 extended, and so on.
412    * @stable ICU 2.8
413    */
414   UCAL_EXTENDED_YEAR,
415 
416  /**
417    * Field number
418    * indicating the modified Julian day number.  This is different from
419    * the conventional Julian day number in two regards.  First, it
420    * demarcates days at local zone midnight, rather than noon GMT.
421    * Second, it is a local number; that is, it depends on the local time
422    * zone.  It can be thought of as a single number that encompasses all
423    * the date-related fields.
424    * @stable ICU 2.8
425    */
426   UCAL_JULIAN_DAY,
427 
428   /**
429    * Ranges from 0 to 23:59:59.999 (regardless of DST).  This field behaves <em>exactly</em>
430    * like a composite of all time-related fields, not including the zone fields.  As such,
431    * it also reflects discontinuities of those fields on DST transition days.  On a day
432    * of DST onset, it will jump forward.  On a day of DST cessation, it will jump
433    * backward.  This reflects the fact that it must be combined with the DST_OFFSET field
434    * to obtain a unique local time value.
435    * @stable ICU 2.8
436    */
437   UCAL_MILLISECONDS_IN_DAY,
438 
439   /**
440    * Whether or not the current month is a leap month (0 or 1). See the Chinese calendar for
441    * an example of this.
442    */
443   UCAL_IS_LEAP_MONTH,
444 
445   /**
446    * Field number indicating the month. This is a calendar-specific value.
447    * Differ from UCAL_MONTH, this value is continuous and unique within a
448    * year and range from 0 to 11 or 0 to 12 depending on how many months in a
449    * year, the calendar system has leap month or not, and in leap year or not.
450    * It is the ordinal position of that month in the corresponding year of
451    * the calendar. For Chinese, Dangi, and Hebrew calendar, the range is
452    * 0 to 11 in non-leap years and 0 to 12 in leap years. For Coptic and Ethiopian
453    * calendar, the range is always 0 to 12. For other calendars supported by
454    * ICU now, the range is 0 to 11. When the number of months in a year of the
455    * identified calendar is variable, a different UCAL_ORDINAL_MONTH value can
456    * be used for dates that are part of the same named month in different years.
457    * For example, in the Hebrew calendar, "1 Nisan 5781" is associated with
458    * UCAL_ORDINAL_MONTH value 6 while "1 Nisan 5782" is associated with
459    * UCAL_ORDINAL_MONTH value 7 because 5782 is a leap year and Nisan follows
460    * the insertion of Adar I. In Chinese calendar, "Year 4664 Month 6 Day 2"
461    * is associated with UCAL_ORDINAL_MONTH value 5 while "Year 4665 Month 6 Day 2"
462    * is associated with UCAL_ORDINAL_MONTH value 6 because 4665 is a leap year
463    * and there is an extra "Leap Month 5" which associated with UCAL_ORDINAL_MONTH
464    * value 5 before "Month 6" of year 4664.
465    *
466    * @stable ICU 73
467    */
468   UCAL_ORDINAL_MONTH,
469 
470     /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
471      * it is needed for layout of Calendar, DateFormat, and other objects */
472 #ifndef U_FORCE_HIDE_DEPRECATED_API
473     /**
474      * One more than the highest normal UCalendarDateFields value.
475      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
476      */
477     UCAL_FIELD_COUNT = UCAL_ORDINAL_MONTH + 1,
478 
479 #endif  // U_FORCE_HIDE_DEPRECATED_API
480 
481  /**
482    * Field number indicating the
483    * day of the month. This is a synonym for <code>UCAL_DATE</code>.
484    * The first day of the month has value 1.
485    * @see #UCAL_DATE
486    * Synonym for UCAL_DATE
487    * @stable ICU 2.8
488    **/
489   UCAL_DAY_OF_MONTH=UCAL_DATE
490 };
491 
492 /** @stable ICU 2.0 */
493 typedef enum UCalendarDateFields UCalendarDateFields;
494     /**
495      * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients
496      * who create locale resources for the field of first-day-of-week should be aware of
497      * this. For instance, in US locale, first-day-of-week is set to 1, i.e., UCAL_SUNDAY.
498      */
499 /** Possible days of the week in a UCalendar
500  * @stable ICU 2.0
501  */
502 enum UCalendarDaysOfWeek {
503   /** Sunday */
504   UCAL_SUNDAY = 1,
505   /** Monday */
506   UCAL_MONDAY,
507   /** Tuesday */
508   UCAL_TUESDAY,
509   /** Wednesday */
510   UCAL_WEDNESDAY,
511   /** Thursday */
512   UCAL_THURSDAY,
513   /** Friday */
514   UCAL_FRIDAY,
515   /** Saturday */
516   UCAL_SATURDAY
517 };
518 
519 /** @stable ICU 2.0 */
520 typedef enum UCalendarDaysOfWeek UCalendarDaysOfWeek;
521 
522 /** Possible months in a UCalendar. Note: Calendar month is 0-based.
523  * @stable ICU 2.0
524  */
525 enum UCalendarMonths {
526   /** January */
527   UCAL_JANUARY,
528   /** February */
529   UCAL_FEBRUARY,
530   /** March */
531   UCAL_MARCH,
532   /** April */
533   UCAL_APRIL,
534   /** May */
535   UCAL_MAY,
536   /** June */
537   UCAL_JUNE,
538   /** July */
539   UCAL_JULY,
540   /** August */
541   UCAL_AUGUST,
542   /** September */
543   UCAL_SEPTEMBER,
544   /** October */
545   UCAL_OCTOBER,
546   /** November */
547   UCAL_NOVEMBER,
548   /** December */
549   UCAL_DECEMBER,
550   /** Value of the <code>UCAL_MONTH</code> field indicating the
551     * thirteenth month of the year. Although the Gregorian calendar
552     * does not use this value, lunar calendars do.
553     */
554   UCAL_UNDECIMBER
555 };
556 
557 /** @stable ICU 2.0 */
558 typedef enum UCalendarMonths UCalendarMonths;
559 
560 /** Possible AM/PM values in a UCalendar
561  * @stable ICU 2.0
562  */
563 enum UCalendarAMPMs {
564     /** AM */
565   UCAL_AM,
566   /** PM */
567   UCAL_PM
568 };
569 
570 /** @stable ICU 2.0 */
571 typedef enum UCalendarAMPMs UCalendarAMPMs;
572 
573 /**
574  * System time zone type constants used by filtering zones
575  * in ucal_openTimeZoneIDEnumeration.
576  * @see ucal_openTimeZoneIDEnumeration
577  * @stable ICU 4.8
578  */
579 enum USystemTimeZoneType {
580     /**
581      * Any system zones.
582      * @stable ICU 4.8
583      */
584     UCAL_ZONE_TYPE_ANY,
585     /**
586      * Canonical system zones.
587      * @stable ICU 4.8
588      */
589     UCAL_ZONE_TYPE_CANONICAL,
590     /**
591      * Canonical system zones associated with actual locations.
592      * @stable ICU 4.8
593      */
594     UCAL_ZONE_TYPE_CANONICAL_LOCATION
595 };
596 
597 /** @stable ICU 4.8 */
598 typedef enum USystemTimeZoneType USystemTimeZoneType;
599 
600 /**
601  * Create an enumeration over system time zone IDs with the given
602  * filter conditions.
603  * @param zoneType  The system time zone type.
604  * @param region    The ISO 3166 two-letter country code or UN M.49
605  *                  three-digit area code.  When NULL, no filtering
606  *                  done by region.
607  * @param rawOffset An offset from GMT in milliseconds, ignoring the
608  *                  effect of daylight savings time, if any. When NULL,
609  *                  no filtering done by zone offset.
610  * @param ec        A pointer to an UErrorCode to receive any errors
611  * @return  an enumeration object that the caller must dispose of
612  *          using enum_close(), or NULL upon failure. In case of failure,
613  *          *ec will indicate the error.
614  * @stable ICU 4.8
615  */
616 U_CAPI UEnumeration* U_EXPORT2
617 ucal_openTimeZoneIDEnumeration(USystemTimeZoneType zoneType, const char* region,
618                                 const int32_t* rawOffset, UErrorCode* ec);
619 
620 /**
621  * Create an enumeration over all time zones.
622  *
623  * @param ec input/output error code
624  *
625  * @return an enumeration object that the caller must dispose of using
626  * uenum_close(), or NULL upon failure. In case of failure *ec will
627  * indicate the error.
628  *
629  * @stable ICU 2.6
630  */
631 U_CAPI UEnumeration* U_EXPORT2
632 ucal_openTimeZones(UErrorCode* ec);
633 
634 /**
635  * Create an enumeration over all time zones associated with the given
636  * country. Some zones are affiliated with no country (e.g., "UTC");
637  * these may also be retrieved, as a group.
638  *
639  * @param country the ISO 3166 two-letter country code, or NULL to
640  * retrieve zones not affiliated with any country
641  *
642  * @param ec input/output error code
643  *
644  * @return an enumeration object that the caller must dispose of using
645  * uenum_close(), or NULL upon failure. In case of failure *ec will
646  * indicate the error.
647  *
648  * @stable ICU 2.6
649  */
650 U_CAPI UEnumeration* U_EXPORT2
651 ucal_openCountryTimeZones(const char* country, UErrorCode* ec);
652 
653 /**
654  * Return the default time zone. The default is determined initially
655  * by querying the host operating system. If the host system detection
656  * routines fail, or if they specify a TimeZone or TimeZone offset
657  * which is not recognized, then the special TimeZone "Etc/Unknown"
658  * is returned.
659  *
660  * The default may be changed with `ucal_setDefaultTimeZone()` or with
661  * the C++ TimeZone API, `TimeZone::adoptDefault(TimeZone*)`.
662  *
663  * @param result A buffer to receive the result, or NULL
664  *
665  * @param resultCapacity The capacity of the result buffer
666  *
667  * @param ec input/output error code
668  *
669  * @return The result string length, not including the terminating
670  * null
671  *
672  * @see #UCAL_UNKNOWN_ZONE_ID
673  *
674  * @stable ICU 2.6
675  */
676 U_CAPI int32_t U_EXPORT2
677 ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec);
678 
679 /**
680  * Set the default time zone.
681  *
682  * @param zoneID null-terminated time zone ID
683  *
684  * @param ec input/output error code
685  *
686  * @stable ICU 2.6
687  */
688 U_CAPI void U_EXPORT2
689 ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec);
690 
691 /**
692  * Return the current host time zone. The host time zone is detected from
693  * the current host system configuration by querying the host operating
694  * system. If the host system detection routines fail, or if they specify
695  * a TimeZone or TimeZone offset which is not recognized, then the special
696  * TimeZone "Etc/Unknown" is returned.
697  *
698  * Note that host time zone and the ICU default time zone can be different.
699  *
700  * The ICU default time zone does not change once initialized unless modified
701  * by calling `ucal_setDefaultTimeZone()` or with the C++ TimeZone API,
702  * `TimeZone::adoptDefault(TimeZone*)`.
703  *
704  * If the host operating system configuration has changed since ICU has
705  * initialized then the returned value can be different than the ICU default
706  * time zone, even if the default has not changed.
707  *
708  * <p>This function is not thread safe.</p>
709  *
710  * @param result A buffer to receive the result, or NULL
711  * @param resultCapacity The capacity of the result buffer
712  * @param ec input/output error code
713  * @return The result string length, not including the terminating
714  * null
715  *
716  * @see #UCAL_UNKNOWN_ZONE_ID
717  *
718  * @stable ICU 65
719  */
720 U_CAPI int32_t U_EXPORT2
721 ucal_getHostTimeZone(UChar *result, int32_t resultCapacity, UErrorCode *ec);
722 
723 /**
724  * Return the amount of time in milliseconds that the clock is
725  * advanced during daylight savings time for the given time zone, or
726  * zero if the time zone does not observe daylight savings time.
727  *
728  * @param zoneID null-terminated time zone ID
729  *
730  * @param ec input/output error code
731  *
732  * @return the number of milliseconds the time is advanced with
733  * respect to standard time when the daylight savings rules are in
734  * effect. This is always a non-negative number, most commonly either
735  * 3,600,000 (one hour) or zero.
736  *
737  * @stable ICU 2.6
738  */
739 U_CAPI int32_t U_EXPORT2
740 ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec);
741 
742 /**
743  * Get the current date and time.
744  * The value returned is represented as milliseconds from the epoch.
745  * @return The current date and time.
746  * @stable ICU 2.0
747  */
748 U_CAPI UDate U_EXPORT2
749 ucal_getNow(void);
750 
751 /**
752  * Open a UCalendar.
753  * A UCalendar may be used to convert a millisecond value to a year,
754  * month, and day.
755  * <p>
756  * Note: When unknown TimeZone ID is specified or if the TimeZone ID specified is "Etc/Unknown",
757  * the UCalendar returned by the function is initialized with GMT zone with TimeZone ID
758  * <code>UCAL_UNKNOWN_ZONE_ID</code> ("Etc/Unknown") without any errors/warnings.  If you want
759  * to check if a TimeZone ID is valid prior to this function, use <code>ucal_getCanonicalTimeZoneID</code>.
760  *
761  * @param zoneID The desired TimeZone ID.  If 0, use the default time zone.
762  * @param len The length of zoneID, or -1 if null-terminated.
763  * @param locale The desired locale
764  * @param type The type of UCalendar to open. This can be UCAL_GREGORIAN to open the Gregorian
765  * calendar for the locale, or UCAL_DEFAULT to open the default calendar for the locale (the
766  * default calendar may also be Gregorian). To open a specific non-Gregorian calendar for the
767  * locale, use uloc_setKeywordValue to set the value of the calendar keyword for the locale
768  * and then pass the locale to ucal_open with UCAL_DEFAULT as the type.
769  * @param status A pointer to an UErrorCode to receive any errors
770  * @return A pointer to a UCalendar, or 0 if an error occurred.
771  * @see #UCAL_UNKNOWN_ZONE_ID
772  * @stable ICU 2.0
773  */
774 U_CAPI UCalendar* U_EXPORT2
775 ucal_open(const UChar*   zoneID,
776           int32_t        len,
777           const char*    locale,
778           UCalendarType  type,
779           UErrorCode*    status);
780 
781 /**
782  * Close a UCalendar.
783  * Once closed, a UCalendar may no longer be used.
784  * @param cal The UCalendar to close.
785  * @stable ICU 2.0
786  */
787 U_CAPI void U_EXPORT2
788 ucal_close(UCalendar *cal);
789 
790 #if U_SHOW_CPLUSPLUS_API
791 
792 U_NAMESPACE_BEGIN
793 
794 /**
795  * \class LocalUCalendarPointer
796  * "Smart pointer" class, closes a UCalendar via ucal_close().
797  * For most methods see the LocalPointerBase base class.
798  *
799  * @see LocalPointerBase
800  * @see LocalPointer
801  * @stable ICU 4.4
802  */
803 U_DEFINE_LOCAL_OPEN_POINTER(LocalUCalendarPointer, UCalendar, ucal_close);
804 
805 U_NAMESPACE_END
806 
807 #endif
808 
809 /**
810  * Open a copy of a UCalendar.
811  * This function performs a deep copy.
812  * @param cal The calendar to copy
813  * @param status A pointer to an UErrorCode to receive any errors.
814  * @return A pointer to a UCalendar identical to cal.
815  * @stable ICU 4.0
816  */
817 U_CAPI UCalendar* U_EXPORT2
818 ucal_clone(const UCalendar* cal,
819            UErrorCode*      status);
820 
821 /**
822  * Set the TimeZone used by a UCalendar.
823  * A UCalendar uses a timezone for converting from Greenwich time to local time.
824  * @param cal The UCalendar to set.
825  * @param zoneID The desired TimeZone ID.  If 0, use the default time zone.
826  * @param len The length of zoneID, or -1 if null-terminated.
827  * @param status A pointer to an UErrorCode to receive any errors.
828  * @stable ICU 2.0
829  */
830 U_CAPI void U_EXPORT2
831 ucal_setTimeZone(UCalendar*    cal,
832                  const UChar*  zoneID,
833                  int32_t       len,
834                  UErrorCode*   status);
835 
836 /**
837  * Get the ID of the UCalendar's time zone.
838  *
839  * @param cal           The UCalendar to query.
840  * @param result        Receives the UCalendar's time zone ID.
841  * @param resultLength  The maximum size of result.
842  * @param status        Receives the status.
843  * @return              The total buffer size needed; if greater than resultLength, the output was truncated.
844  * @stable ICU 51
845  */
846 U_CAPI int32_t U_EXPORT2
847 ucal_getTimeZoneID(const UCalendar *cal,
848                    UChar *result,
849                    int32_t resultLength,
850                    UErrorCode *status);
851 
852 /**
853  * Possible formats for a UCalendar's display name
854  * @stable ICU 2.0
855  */
856 enum UCalendarDisplayNameType {
857   /** Standard display name */
858   UCAL_STANDARD,
859   /** Short standard display name */
860   UCAL_SHORT_STANDARD,
861   /** Daylight savings display name */
862   UCAL_DST,
863   /** Short daylight savings display name */
864   UCAL_SHORT_DST
865 };
866 
867 /** @stable ICU 2.0 */
868 typedef enum UCalendarDisplayNameType UCalendarDisplayNameType;
869 
870 /**
871  * Get the display name for a UCalendar's TimeZone.
872  * A display name is suitable for presentation to a user.
873  * @param cal          The UCalendar to query.
874  * @param type         The desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD,
875  *                     UCAL_DST, UCAL_SHORT_DST
876  * @param locale       The desired locale for the display name.
877  * @param result       A pointer to a buffer to receive the formatted number.
878  * @param resultLength The maximum size of result.
879  * @param status       A pointer to an UErrorCode to receive any errors
880  * @return             The total buffer size needed; if greater than resultLength, the output was truncated.
881  * @stable ICU 2.0
882  */
883 U_CAPI int32_t U_EXPORT2
884 ucal_getTimeZoneDisplayName(const UCalendar*          cal,
885                             UCalendarDisplayNameType  type,
886                             const char*               locale,
887                             UChar*                    result,
888                             int32_t                   resultLength,
889                             UErrorCode*               status);
890 
891 /**
892  * Determine if a UCalendar is currently in daylight savings time.
893  * Daylight savings time is not used in all parts of the world.
894  * @param cal The UCalendar to query.
895  * @param status A pointer to an UErrorCode to receive any errors
896  * @return true if cal is currently in daylight savings time, false otherwise
897  * @stable ICU 2.0
898  */
899 U_CAPI UBool U_EXPORT2
900 ucal_inDaylightTime(const UCalendar*  cal,
901                     UErrorCode*       status );
902 
903 /**
904  * Sets the GregorianCalendar change date. This is the point when the switch from
905  * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October
906  * 15, 1582. Previous to this time and date will be Julian dates.
907  *
908  * This function works only for Gregorian calendars. If the UCalendar is not
909  * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR
910  * error code is set.
911  *
912  * @param cal        The calendar object.
913  * @param date       The given Gregorian cutover date.
914  * @param pErrorCode Pointer to a standard ICU error code. Its input value must
915  *                   pass the U_SUCCESS() test, or else the function returns
916  *                   immediately. Check for U_FAILURE() on output or use with
917  *                   function chaining. (See User Guide for details.)
918  *
919  * @see GregorianCalendar::setGregorianChange
920  * @see ucal_getGregorianChange
921  * @stable ICU 3.6
922  */
923 U_CAPI void U_EXPORT2
924 ucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode);
925 
926 /**
927  * Gets the Gregorian Calendar change date. This is the point when the switch from
928  * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October
929  * 15, 1582. Previous to this time and date will be Julian dates.
930  *
931  * This function works only for Gregorian calendars. If the UCalendar is not
932  * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR
933  * error code is set.
934  *
935  * @param cal        The calendar object.
936  * @param pErrorCode Pointer to a standard ICU error code. Its input value must
937  *                   pass the U_SUCCESS() test, or else the function returns
938  *                   immediately. Check for U_FAILURE() on output or use with
939  *                   function chaining. (See User Guide for details.)
940  * @return   The Gregorian cutover time for this calendar.
941  *
942  * @see GregorianCalendar::getGregorianChange
943  * @see ucal_setGregorianChange
944  * @stable ICU 3.6
945  */
946 U_CAPI UDate U_EXPORT2
947 ucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode);
948 
949 /**
950  * Types of UCalendar attributes
951  * @stable ICU 2.0
952  */
953 enum UCalendarAttribute {
954   /**
955    * Lenient parsing
956    * @stable ICU 2.0
957    */
958   UCAL_LENIENT,
959   /**
960    * First day of week
961    * @stable ICU 2.0
962    */
963   UCAL_FIRST_DAY_OF_WEEK,
964   /**
965    * Minimum number of days in first week
966    * @stable ICU 2.0
967    */
968   UCAL_MINIMAL_DAYS_IN_FIRST_WEEK,
969   /**
970    * The behavior for handling wall time repeating multiple times
971    * at negative time zone offset transitions
972    * @stable ICU 49
973    */
974   UCAL_REPEATED_WALL_TIME,
975   /**
976    * The behavior for handling skipped wall time at positive time
977    * zone offset transitions.
978    * @stable ICU 49
979    */
980   UCAL_SKIPPED_WALL_TIME
981 };
982 
983 /** @stable ICU 2.0 */
984 typedef enum UCalendarAttribute UCalendarAttribute;
985 
986 /**
987  * Options for handling ambiguous wall time at time zone
988  * offset transitions.
989  * @stable ICU 49
990  */
991 enum UCalendarWallTimeOption {
992     /**
993      * An ambiguous wall time to be interpreted as the latest.
994      * This option is valid for UCAL_REPEATED_WALL_TIME and
995      * UCAL_SKIPPED_WALL_TIME.
996      * @stable ICU 49
997      */
998     UCAL_WALLTIME_LAST,
999     /**
1000      * An ambiguous wall time to be interpreted as the earliest.
1001      * This option is valid for UCAL_REPEATED_WALL_TIME and
1002      * UCAL_SKIPPED_WALL_TIME.
1003      * @stable ICU 49
1004      */
1005     UCAL_WALLTIME_FIRST,
1006     /**
1007      * An ambiguous wall time to be interpreted as the next valid
1008      * wall time. This option is valid for UCAL_SKIPPED_WALL_TIME.
1009      * @stable ICU 49
1010      */
1011     UCAL_WALLTIME_NEXT_VALID
1012 };
1013 /** @stable ICU 49 */
1014 typedef enum UCalendarWallTimeOption UCalendarWallTimeOption;
1015 
1016 /**
1017  * Get a numeric attribute associated with a UCalendar.
1018  * Numeric attributes include the first day of the week, or the minimal numbers
1019  * of days in the first week of the month.
1020  * @param cal The UCalendar to query.
1021  * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK,
1022  * UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, UCAL_REPEATED_WALL_TIME or UCAL_SKIPPED_WALL_TIME
1023  * @return The value of attr.
1024  * @see ucal_setAttribute
1025  * @stable ICU 2.0
1026  */
1027 U_CAPI int32_t U_EXPORT2
1028 ucal_getAttribute(const UCalendar*    cal,
1029                   UCalendarAttribute  attr);
1030 
1031 /**
1032  * Set a numeric attribute associated with a UCalendar.
1033  * Numeric attributes include the first day of the week, or the minimal numbers
1034  * of days in the first week of the month.
1035  * @param cal The UCalendar to set.
1036  * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK,
1037  * UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, UCAL_REPEATED_WALL_TIME or UCAL_SKIPPED_WALL_TIME
1038  * @param newValue The new value of attr.
1039  * @see ucal_getAttribute
1040  * @stable ICU 2.0
1041  */
1042 U_CAPI void U_EXPORT2
1043 ucal_setAttribute(UCalendar*          cal,
1044                   UCalendarAttribute  attr,
1045                   int32_t             newValue);
1046 
1047 /**
1048  * Get a locale for which calendars are available.
1049  * A UCalendar in a locale returned by this function will contain the correct
1050  * day and month names for the locale.
1051  * @param localeIndex The index of the desired locale.
1052  * @return A locale for which calendars are available, or 0 if none.
1053  * @see ucal_countAvailable
1054  * @stable ICU 2.0
1055  */
1056 U_CAPI const char* U_EXPORT2
1057 ucal_getAvailable(int32_t localeIndex);
1058 
1059 /**
1060  * Determine how many locales have calendars available.
1061  * This function is most useful as determining the loop ending condition for
1062  * calls to \ref ucal_getAvailable.
1063  * @return The number of locales for which calendars are available.
1064  * @see ucal_getAvailable
1065  * @stable ICU 2.0
1066  */
1067 U_CAPI int32_t U_EXPORT2
1068 ucal_countAvailable(void);
1069 
1070 /**
1071  * Get a UCalendar's current time in millis.
1072  * The time is represented as milliseconds from the epoch.
1073  * @param cal The UCalendar to query.
1074  * @param status A pointer to an UErrorCode to receive any errors
1075  * @return The calendar's current time in millis.
1076  * @see ucal_setMillis
1077  * @see ucal_setDate
1078  * @see ucal_setDateTime
1079  * @stable ICU 2.0
1080  */
1081 U_CAPI UDate U_EXPORT2
1082 ucal_getMillis(const UCalendar*  cal,
1083                UErrorCode*       status);
1084 
1085 /**
1086  * Set a UCalendar's current time in millis.
1087  * The time is represented as milliseconds from the epoch.
1088  * @param cal The UCalendar to set.
1089  * @param dateTime The desired date and time.
1090  * @param status A pointer to an UErrorCode to receive any errors
1091  * @see ucal_getMillis
1092  * @see ucal_setDate
1093  * @see ucal_setDateTime
1094  * @stable ICU 2.0
1095  */
1096 U_CAPI void U_EXPORT2
1097 ucal_setMillis(UCalendar*   cal,
1098                UDate        dateTime,
1099                UErrorCode*  status );
1100 
1101 /**
1102  * Set a UCalendar's current date.
1103  * The date is represented as a series of 32-bit integers.
1104  * @param cal The UCalendar to set.
1105  * @param year The desired year.
1106  * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY,
1107  * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER
1108  * @param date The desired day of the month.
1109  * @param status A pointer to an UErrorCode to receive any errors
1110  * @see ucal_getMillis
1111  * @see ucal_setMillis
1112  * @see ucal_setDateTime
1113  * @stable ICU 2.0
1114  */
1115 U_CAPI void U_EXPORT2
1116 ucal_setDate(UCalendar*   cal,
1117              int32_t      year,
1118              int32_t      month,
1119              int32_t      date,
1120              UErrorCode*  status);
1121 
1122 /**
1123  * Set a UCalendar's current date.
1124  * The date is represented as a series of 32-bit integers.
1125  * @param cal The UCalendar to set.
1126  * @param year The desired year.
1127  * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY,
1128  * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER
1129  * @param date The desired day of the month.
1130  * @param hour The desired hour of day.
1131  * @param minute The desired minute.
1132  * @param second The desirec second.
1133  * @param status A pointer to an UErrorCode to receive any errors
1134  * @see ucal_getMillis
1135  * @see ucal_setMillis
1136  * @see ucal_setDate
1137  * @stable ICU 2.0
1138  */
1139 U_CAPI void U_EXPORT2
1140 ucal_setDateTime(UCalendar*   cal,
1141                  int32_t      year,
1142                  int32_t      month,
1143                  int32_t      date,
1144                  int32_t      hour,
1145                  int32_t      minute,
1146                  int32_t      second,
1147                  UErrorCode*  status);
1148 
1149 /**
1150  * Returns true if two UCalendars are equivalent.  Equivalent
1151  * UCalendars will behave identically, but they may be set to
1152  * different times.
1153  * @param cal1 The first of the UCalendars to compare.
1154  * @param cal2 The second of the UCalendars to compare.
1155  * @return true if cal1 and cal2 are equivalent, false otherwise.
1156  * @stable ICU 2.0
1157  */
1158 U_CAPI UBool U_EXPORT2
1159 ucal_equivalentTo(const UCalendar*  cal1,
1160                   const UCalendar*  cal2);
1161 
1162 /**
1163  * Add a specified signed amount to a particular field in a UCalendar.
1164  * This can modify more significant fields in the calendar.
1165  * Adding a positive value always means moving forward in time, so for the Gregorian calendar,
1166  * starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces
1167  * the numeric value of the field itself).
1168  * @param cal The UCalendar to which to add.
1169  * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
1170  * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
1171  * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
1172  * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
1173  * @param amount The signed amount to add to field. If the amount causes the value
1174  * to exceed to maximum or minimum values for that field, other fields are modified
1175  * to preserve the magnitude of the change.
1176  * @param status A pointer to an UErrorCode to receive any errors
1177  * @see ucal_roll
1178  * @stable ICU 2.0
1179  */
1180 U_CAPI void U_EXPORT2
1181 ucal_add(UCalendar*           cal,
1182          UCalendarDateFields  field,
1183          int32_t              amount,
1184          UErrorCode*          status);
1185 
1186 /**
1187  * Add a specified signed amount to a particular field in a UCalendar.
1188  * This will not modify more significant fields in the calendar.
1189  * Rolling by a positive value always means moving forward in time (unless the limit of the
1190  * field is reached, in which case it may pin or wrap), so for Gregorian calendar,
1191  * starting with 100 BC and rolling the year by +1 results in 99 BC.
1192  * When eras have a definite beginning and end (as in the Chinese calendar, or as in most eras in the
1193  * Japanese calendar) then rolling the year past either limit of the era will cause the year to wrap around.
1194  * When eras only have a limit at one end, then attempting to roll the year past that limit will result in
1195  * pinning the year at that limit. Note that for most calendars in which era 0 years move forward in time
1196  * (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to result in negative years for
1197  * era 0 (that is the only way to represent years before the calendar epoch).
1198  * @param cal The UCalendar to which to add.
1199  * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
1200  * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
1201  * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
1202  * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
1203  * @param amount The signed amount to add to field. If the amount causes the value
1204  * to exceed to maximum or minimum values for that field, the field is pinned to a permissible
1205  * value.
1206  * @param status A pointer to an UErrorCode to receive any errors
1207  * @see ucal_add
1208  * @stable ICU 2.0
1209  */
1210 U_CAPI void U_EXPORT2
1211 ucal_roll(UCalendar*           cal,
1212           UCalendarDateFields  field,
1213           int32_t              amount,
1214           UErrorCode*          status);
1215 
1216 /**
1217  * Get the current value of a field from a UCalendar.
1218  * All fields are represented as 32-bit integers.
1219  * @param cal The UCalendar to query.
1220  * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
1221  * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
1222  * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
1223  * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
1224  * @param status A pointer to an UErrorCode to receive any errors
1225  * @return The value of the desired field.
1226  * @see ucal_set
1227  * @see ucal_isSet
1228  * @see ucal_clearField
1229  * @see ucal_clear
1230  * @stable ICU 2.0
1231  */
1232 U_CAPI int32_t U_EXPORT2
1233 ucal_get(const UCalendar*     cal,
1234          UCalendarDateFields  field,
1235          UErrorCode*          status );
1236 
1237 /**
1238  * Set the value of a field in a UCalendar.
1239  * All fields are represented as 32-bit integers.
1240  * @param cal The UCalendar to set.
1241  * @param field The field to set; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
1242  * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
1243  * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
1244  * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
1245  * @param value The desired value of field.
1246  * @see ucal_get
1247  * @see ucal_isSet
1248  * @see ucal_clearField
1249  * @see ucal_clear
1250  * @stable ICU 2.0
1251  */
1252 U_CAPI void U_EXPORT2
1253 ucal_set(UCalendar*           cal,
1254          UCalendarDateFields  field,
1255          int32_t              value);
1256 
1257 /**
1258  * Determine if a field in a UCalendar is set.
1259  * All fields are represented as 32-bit integers.
1260  * @param cal The UCalendar to query.
1261  * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
1262  * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
1263  * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
1264  * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
1265  * @return true if field is set, false otherwise.
1266  * @see ucal_get
1267  * @see ucal_set
1268  * @see ucal_clearField
1269  * @see ucal_clear
1270  * @stable ICU 2.0
1271  */
1272 U_CAPI UBool U_EXPORT2
1273 ucal_isSet(const UCalendar*     cal,
1274            UCalendarDateFields  field);
1275 
1276 /**
1277  * Clear a field in a UCalendar.
1278  * All fields are represented as 32-bit integers.
1279  * @param cal The UCalendar containing the field to clear.
1280  * @param field The field to clear; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
1281  * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
1282  * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
1283  * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
1284  * @see ucal_get
1285  * @see ucal_set
1286  * @see ucal_isSet
1287  * @see ucal_clear
1288  * @stable ICU 2.0
1289  */
1290 U_CAPI void U_EXPORT2
1291 ucal_clearField(UCalendar*           cal,
1292                 UCalendarDateFields  field);
1293 
1294 /**
1295  * Clear all fields in a UCalendar.
1296  * All fields are represented as 32-bit integers.
1297  * @param calendar The UCalendar to clear.
1298  * @see ucal_get
1299  * @see ucal_set
1300  * @see ucal_isSet
1301  * @see ucal_clearField
1302  * @stable ICU 2.0
1303  */
1304 U_CAPI void U_EXPORT2
1305 ucal_clear(UCalendar* calendar);
1306 
1307 /**
1308  * Possible limit values for a UCalendar
1309  * @stable ICU 2.0
1310  */
1311 enum UCalendarLimitType {
1312   /** Minimum value */
1313   UCAL_MINIMUM,
1314   /** Maximum value */
1315   UCAL_MAXIMUM,
1316   /** Greatest minimum value */
1317   UCAL_GREATEST_MINIMUM,
1318   /** Least maximum value */
1319   UCAL_LEAST_MAXIMUM,
1320   /** Actual minimum value */
1321   UCAL_ACTUAL_MINIMUM,
1322   /** Actual maximum value */
1323   UCAL_ACTUAL_MAXIMUM
1324 };
1325 
1326 /** @stable ICU 2.0 */
1327 typedef enum UCalendarLimitType UCalendarLimitType;
1328 
1329 /**
1330  * Determine a limit for a field in a UCalendar.
1331  * A limit is a maximum or minimum value for a field.
1332  * @param cal The UCalendar to query.
1333  * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
1334  * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
1335  * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
1336  * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
1337  * @param type The desired critical point; one of UCAL_MINIMUM, UCAL_MAXIMUM, UCAL_GREATEST_MINIMUM,
1338  * UCAL_LEAST_MAXIMUM, UCAL_ACTUAL_MINIMUM, UCAL_ACTUAL_MAXIMUM
1339  * @param status A pointer to an UErrorCode to receive any errors.
1340  * @return The requested value.
1341  * @stable ICU 2.0
1342  */
1343 U_CAPI int32_t U_EXPORT2
1344 ucal_getLimit(const UCalendar*     cal,
1345               UCalendarDateFields  field,
1346               UCalendarLimitType   type,
1347               UErrorCode*          status);
1348 
1349 /** Get the locale for this calendar object. You can choose between valid and actual locale.
1350  *  @param cal The calendar object
1351  *  @param type type of the locale we're looking for (valid or actual)
1352  *  @param status error code for the operation
1353  *  @return the locale name
1354  *  @stable ICU 2.8
1355  */
1356 U_CAPI const char * U_EXPORT2
1357 ucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode* status);
1358 
1359 /**
1360  * Returns the timezone data version currently used by ICU.
1361  * @param status error code for the operation
1362  * @return the version string, such as "2007f"
1363  * @stable ICU 3.8
1364  */
1365 U_CAPI const char * U_EXPORT2
1366 ucal_getTZDataVersion(UErrorCode* status);
1367 
1368 /**
1369  * Returns the canonical system timezone ID or the normalized
1370  * custom time zone ID for the given time zone ID.
1371  * @param id        The input timezone ID to be canonicalized.
1372  * @param len       The length of id, or -1 if null-terminated.
1373  * @param result    The buffer receives the canonical system timezone ID
1374  *                  or the custom timezone ID in normalized format.
1375  * @param resultCapacity    The capacity of the result buffer.
1376  * @param isSystemID        Receives if the given ID is a known system
1377      *                      timezone ID.
1378  * @param status    Receives the status.  When the given timezone ID
1379  *                  is neither a known system time zone ID nor a
1380  *                  valid custom timezone ID, U_ILLEGAL_ARGUMENT_ERROR
1381  *                  is set.
1382  * @return          The result string length, not including the terminating
1383  *                  null.
1384  * @stable ICU 4.0
1385  */
1386 U_CAPI int32_t U_EXPORT2
1387 ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len,
1388                             UChar* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status);
1389 
1390 #ifndef U_HIDE_DRAFT_API
1391 /**
1392  * Returns the preferred time zone ID in the IANA time zone database for the given time zone ID.
1393  * There are two types of preferred IDs. The first type is the one defined in zone.tab file,
1394  * such as "America/Los_Angeles". The second types is the one defined for zones not associated
1395  * with a specific region, but not defined with "Link" syntax such as "Etc/GMT+10".
1396  *
1397  * <p>Note: For most of valid time zone IDs, this method returns an ID same as ucal_getCanonicalTimeZoneID().
1398  * ucal_getCanonicalTimeZoneID() is based on canonical time zone IDs defined in Unicode CLDR.
1399  * These canonical time zone IDs in CLDR were based on very old version of the time zone database.
1400  * In the IANA time zone database, some IDs were updated since then. This API returns a newer
1401  * time zone ID. For example, CLDR defines "Asia/Calcutta" as the canonical time zone ID. This
1402  * method returns "Asia/Kolkata" instead.
1403  * <p> "Etc/Unknown" is a special time zone ID defined by CLDR. There are no corresponding zones
1404  * in the IANA time zone database. Therefore, this API returns U_ILLEGAL_ARGUMENT_ERROR when the
1405  * input ID is "Etc/Unknown".
1406  *
1407  * @param id        The input time zone ID.
1408  * @param len       The length of the input time zone ID.
1409  * @param result    The buffer receives the preferred time zone ID in the IANA time zone database.
1410  * @param resultCapacity  The capacity of the result buffer.
1411  * @param status    Receives the status.  When the given time zone ID is not a known system time zone
1412  *                  ID, U_ILLEGAL_ARGUMENT_ERROR is set.
1413  * @return          The result string length, not including the terminating null.
1414  * @draft ICU 74
1415  */
1416 U_CAPI int32_t U_EXPORT2
1417 ucal_getIanaTimeZoneID(const UChar* id, int32_t len,
1418                         UChar* result, int32_t resultCapacity, UErrorCode* status);
1419 #endif // U_HIDE_DRAFT_API
1420 
1421 /**
1422  * Get the resource keyword value string designating the calendar type for the UCalendar.
1423  * @param cal The UCalendar to query.
1424  * @param status The error code for the operation.
1425  * @return The resource keyword value string.
1426  * @stable ICU 4.2
1427  */
1428 U_CAPI const char * U_EXPORT2
1429 ucal_getType(const UCalendar *cal, UErrorCode* status);
1430 
1431 /**
1432  * Given a key and a locale, returns an array of string values in a preferred
1433  * order that would make a difference. These are all and only those values where
1434  * the open (creation) of the service with the locale formed from the input locale
1435  * plus input keyword and that value has different behavior than creation with the
1436  * input locale alone.
1437  * @param key           one of the keys supported by this service.  For now, only
1438  *                      "calendar" is supported.
1439  * @param locale        the locale
1440  * @param commonlyUsed  if set to true it will return only commonly used values
1441  *                      with the given locale in preferred order.  Otherwise,
1442  *                      it will return all the available values for the locale.
1443  * @param status error status
1444  * @return a string enumeration over keyword values for the given key and the locale.
1445  * @stable ICU 4.2
1446  */
1447 U_CAPI UEnumeration* U_EXPORT2
1448 ucal_getKeywordValuesForLocale(const char* key,
1449                                const char* locale,
1450                                UBool commonlyUsed,
1451                                UErrorCode* status);
1452 
1453 
1454 /** Weekday types, as returned by ucal_getDayOfWeekType().
1455  * @stable ICU 4.4
1456  */
1457 enum UCalendarWeekdayType {
1458   /**
1459    * Designates a full weekday (no part of the day is included in the weekend).
1460    * @stable ICU 4.4
1461    */
1462   UCAL_WEEKDAY,
1463   /**
1464    * Designates a full weekend day (the entire day is included in the weekend).
1465    * @stable ICU 4.4
1466    */
1467   UCAL_WEEKEND,
1468   /**
1469    * Designates a day that starts as a weekday and transitions to the weekend.
1470    * Call ucal_getWeekendTransition() to get the time of transition.
1471    * @stable ICU 4.4
1472    */
1473   UCAL_WEEKEND_ONSET,
1474   /**
1475    * Designates a day that starts as the weekend and transitions to a weekday.
1476    * Call ucal_getWeekendTransition() to get the time of transition.
1477    * @stable ICU 4.4
1478    */
1479   UCAL_WEEKEND_CEASE
1480 };
1481 
1482 /** @stable ICU 4.4 */
1483 typedef enum UCalendarWeekdayType UCalendarWeekdayType;
1484 
1485 /**
1486  * Returns whether the given day of the week is a weekday, a weekend day,
1487  * or a day that transitions from one to the other, for the locale and
1488  * calendar system associated with this UCalendar (the locale's region is
1489  * often the most determinant factor). If a transition occurs at midnight,
1490  * then the days before and after the transition will have the
1491  * type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time
1492  * other than midnight, then the day of the transition will have
1493  * the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the
1494  * function ucal_getWeekendTransition() will return the point of
1495  * transition.
1496  * @param cal The UCalendar to query.
1497  * @param dayOfWeek The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY).
1498  * @param status The error code for the operation.
1499  * @return The UCalendarWeekdayType for the day of the week.
1500  * @stable ICU 4.4
1501  */
1502 U_CAPI UCalendarWeekdayType U_EXPORT2
1503 ucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode* status);
1504 
1505 /**
1506  * Returns the time during the day at which the weekend begins or ends in
1507  * this calendar system.  If ucal_getDayOfWeekType() returns UCAL_WEEKEND_ONSET
1508  * for the specified dayOfWeek, return the time at which the weekend begins.
1509  * If ucal_getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek,
1510  * return the time at which the weekend ends. If ucal_getDayOfWeekType() returns
1511  * some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition
1512  * (U_ILLEGAL_ARGUMENT_ERROR).
1513  * @param cal The UCalendar to query.
1514  * @param dayOfWeek The day of the week for which the weekend transition time is
1515  * desired (UCAL_SUNDAY..UCAL_SATURDAY).
1516  * @param status The error code for the operation.
1517  * @return The milliseconds after midnight at which the weekend begins or ends.
1518  * @stable ICU 4.4
1519  */
1520 U_CAPI int32_t U_EXPORT2
1521 ucal_getWeekendTransition(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode *status);
1522 
1523 /**
1524  * Returns true if the given UDate is in the weekend in
1525  * this calendar system.
1526  * @param cal The UCalendar to query.
1527  * @param date The UDate in question.
1528  * @param status The error code for the operation.
1529  * @return true if the given UDate is in the weekend in
1530  * this calendar system, false otherwise.
1531  * @stable ICU 4.4
1532  */
1533 U_CAPI UBool U_EXPORT2
1534 ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status);
1535 
1536 /**
1537  * Return the difference between the target time and the time this calendar object is currently set to.
1538  * If the target time is after the current calendar setting, the the returned value will be positive.
1539  * The field parameter specifies the units of the return value. For example, if field is UCAL_MONTH
1540  * and ucal_getFieldDifference returns 3, then the target time is 3 to less than 4 months after the
1541  * current calendar setting.
1542  *
1543  * As a side effect of this call, this calendar is advanced toward target by the given amount. That is,
1544  * calling this function has the side effect of calling ucal_add on this calendar with the specified
1545  * field and an amount equal to the return value from this function.
1546  *
1547  * A typical way of using this function is to call it first with the largest field of interest, then
1548  * with progressively smaller fields.
1549  *
1550  * @param cal The UCalendar to compare and update.
1551  * @param target The target date to compare to the current calendar setting.
1552  * @param field The field to compare; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
1553  * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
1554  * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
1555  * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
1556  * @param status A pointer to an UErrorCode to receive any errors
1557  * @return The date difference for the specified field.
1558  * @stable ICU 4.8
1559  */
1560 U_CAPI int32_t U_EXPORT2
1561 ucal_getFieldDifference(UCalendar* cal,
1562                         UDate target,
1563                         UCalendarDateFields field,
1564                         UErrorCode* status);
1565 
1566 /**
1567  * Time zone transition types for ucal_getTimeZoneTransitionDate
1568  * @stable ICU 50
1569  */
1570 enum UTimeZoneTransitionType {
1571     /**
1572      * Get the next transition after the current date,
1573      * i.e. excludes the current date
1574      * @stable ICU 50
1575      */
1576     UCAL_TZ_TRANSITION_NEXT,
1577     /**
1578      * Get the next transition on or after the current date,
1579      * i.e. may include the current date
1580      * @stable ICU 50
1581      */
1582     UCAL_TZ_TRANSITION_NEXT_INCLUSIVE,
1583     /**
1584      * Get the previous transition before the current date,
1585      * i.e. excludes the current date
1586      * @stable ICU 50
1587      */
1588     UCAL_TZ_TRANSITION_PREVIOUS,
1589     /**
1590      * Get the previous transition on or before the current date,
1591      * i.e. may include the current date
1592      * @stable ICU 50
1593      */
1594     UCAL_TZ_TRANSITION_PREVIOUS_INCLUSIVE
1595 };
1596 
1597 typedef enum UTimeZoneTransitionType UTimeZoneTransitionType; /**< @stable ICU 50 */
1598 
1599 /**
1600 * Get the UDate for the next/previous time zone transition relative to
1601 * the calendar's current date, in the time zone to which the calendar
1602 * is currently set. If there is no known time zone transition of the
1603 * requested type relative to the calendar's date, the function returns
1604 * false.
1605 * @param cal The UCalendar to query.
1606 * @param type The type of transition desired.
1607 * @param transition A pointer to a UDate to be set to the transition time.
1608 *         If the function returns false, the value set is unspecified.
1609 * @param status A pointer to a UErrorCode to receive any errors.
1610 * @return true if a valid transition time is set in *transition, false
1611 *         otherwise.
1612 * @stable ICU 50
1613 */
1614 U_CAPI UBool U_EXPORT2
1615 ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType type,
1616                                UDate* transition, UErrorCode* status);
1617 
1618 /**
1619 * Converts a system time zone ID to an equivalent Windows time zone ID. For example,
1620 * Windows time zone ID "Pacific Standard Time" is returned for input "America/Los_Angeles".
1621 *
1622 * <p>There are system time zones that cannot be mapped to Windows zones. When the input
1623 * system time zone ID is unknown or unmappable to a Windows time zone, then this
1624 * function returns 0 as the result length, but the operation itself remains successful
1625 * (no error status set on return).
1626 *
1627 * <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html">
1628 * Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes,
1629 * please read the ICU user guide section <a href="https://unicode-org.github.io/icu/userguide/datetime/timezone#updating-the-time-zone-data">
1630 * Updating the Time Zone Data</a>.
1631 *
1632 * @param id            A system time zone ID.
1633 * @param len           The length of <code>id</code>, or -1 if null-terminated.
1634 * @param winid         A buffer to receive a Windows time zone ID.
1635 * @param winidCapacity The capacity of the result buffer <code>winid</code>.
1636 * @param status        Receives the status.
1637 * @return              The result string length, not including the terminating null.
1638 * @see ucal_getTimeZoneIDForWindowsID
1639 *
1640 * @stable ICU 52
1641 */
1642 U_CAPI int32_t U_EXPORT2
1643 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len,
1644                             UChar* winid, int32_t winidCapacity, UErrorCode* status);
1645 
1646 /**
1647 * Converts a Windows time zone ID to an equivalent system time zone ID
1648 * for a region. For example, system time zone ID "America/Los_Angeles" is returned
1649 * for input Windows ID "Pacific Standard Time" and region "US" (or <code>null</code>),
1650 * "America/Vancouver" is returned for the same Windows ID "Pacific Standard Time" and
1651 * region "CA".
1652 *
1653 * <p>Not all Windows time zones can be mapped to system time zones. When the input
1654 * Windows time zone ID is unknown or unmappable to a system time zone, then this
1655 * function returns 0 as the result length, but the operation itself remains successful
1656 * (no error status set on return).
1657 *
1658 * <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html">
1659 * Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes,
1660 * please read the ICU user guide section <a href="https://unicode-org.github.io/icu/userguide/datetime/timezone#updating-the-time-zone-data">
1661 * Updating the Time Zone Data</a>.
1662 *
1663 * @param winid         A Windows time zone ID.
1664 * @param len           The length of <code>winid</code>, or -1 if null-terminated.
1665 * @param region        A null-terminated region code, or <code>NULL</code> if no regional preference.
1666 * @param id            A buffer to receive a system time zone ID.
1667 * @param idCapacity    The capacity of the result buffer <code>id</code>.
1668 * @param status        Receives the status.
1669 * @return              The result string length, not including the terminating null.
1670 * @see ucal_getWindowsTimeZoneID
1671 *
1672 * @stable ICU 52
1673 */
1674 U_CAPI int32_t U_EXPORT2
1675 ucal_getTimeZoneIDForWindowsID(const UChar* winid, int32_t len, const char* region,
1676                                 UChar* id, int32_t idCapacity, UErrorCode* status);
1677 
1678 /**
1679  * Options used by ucal_getTimeZoneOffsetFromLocal and BasicTimeZone::getOffsetFromLocal()
1680  * to specify how to interpret an input time when it does not exist, or when it is ambiguous,
1681  * around a time zone transition.
1682  * @stable ICU 69
1683  */
1684 enum UTimeZoneLocalOption {
1685     /**
1686      * An input time is always interpreted as local time before
1687      * a time zone transition.
1688      * @stable ICU 69
1689      */
1690     UCAL_TZ_LOCAL_FORMER = 0x04,
1691     /**
1692      * An input time is always interpreted as local time after
1693      * a time zone transition.
1694      * @stable ICU 69
1695      */
1696     UCAL_TZ_LOCAL_LATTER = 0x0C,
1697     /**
1698      * An input time is interpreted as standard time when local
1699      * time is switched to/from daylight saving time. When both
1700      * sides of a time zone transition are standard time,
1701      * or daylight saving time, the local time before the
1702      * transition is used.
1703      * @stable ICU 69
1704      */
1705     UCAL_TZ_LOCAL_STANDARD_FORMER = UCAL_TZ_LOCAL_FORMER | 0x01,
1706     /**
1707      * An input time is interpreted as standard time when local
1708      * time is switched to/from daylight saving time. When both
1709      * sides of a time zone transition are standard time,
1710      * or daylight saving time, the local time after the
1711      * transition is used.
1712      * @stable ICU 69
1713      */
1714     UCAL_TZ_LOCAL_STANDARD_LATTER = UCAL_TZ_LOCAL_LATTER | 0x01,
1715     /**
1716      * An input time is interpreted as daylight saving time when
1717      * local time is switched to/from standard time. When both
1718      * sides of a time zone transition are standard time,
1719      * or daylight saving time, the local time before the
1720      * transition is used.
1721      * @stable ICU 69
1722      */
1723     UCAL_TZ_LOCAL_DAYLIGHT_FORMER = UCAL_TZ_LOCAL_FORMER | 0x03,
1724     /**
1725      * An input time is interpreted as daylight saving time when
1726      * local time is switched to/from standard time. When both
1727      * sides of a time zone transition are standard time,
1728      * or daylight saving time, the local time after the
1729      * transition is used.
1730      * @stable ICU 69
1731      */
1732     UCAL_TZ_LOCAL_DAYLIGHT_LATTER = UCAL_TZ_LOCAL_LATTER | 0x03,
1733 };
1734 typedef enum UTimeZoneLocalOption UTimeZoneLocalOption; /**< @stable ICU 69 */
1735 
1736 /**
1737 * Returns the time zone raw and GMT offset for the given moment
1738 * in time.  Upon return, local-millis = GMT-millis + rawOffset +
1739 * dstOffset.  All computations are performed in the proleptic
1740 * Gregorian calendar.
1741 *
1742 * @param cal The UCalendar which specify the local date and time value to query.
1743 * @param nonExistingTimeOpt The option to indicate how to interpret the date and
1744 * time in the calendar represent a local time that skipped at a positive time
1745 * zone transitions (e.g. when the daylight saving time starts or the time zone
1746 * offset is increased due to a time zone rule change).
1747 * @param duplicatedTimeOpt The option to indicate how to interpret the date and
1748 * time in the calendar represent a local time that repeating multiple times at a
1749 * negative time zone transition (e.g. when the daylight saving time ends or the
1750 * time zone offset is decreased due to a time zone rule change)
1751 * @param rawOffset output parameter to receive the raw offset, that
1752 * is, the offset not including DST adjustments.
1753 * If the status is set to one of the error code, the value set is unspecified.
1754 * @param dstOffset output parameter to receive the DST offset,
1755 * that is, the offset to be added to `rawOffset' to obtain the
1756 * total offset between local and GMT time. If DST is not in
1757 * effect, this value is zero; otherwise it is a positive value,
1758 * typically one hour.
1759 * If the status is set to one of the error code, the value set is unspecified.
1760 * @param status A pointer to a UErrorCode to receive any errors.
1761 * @stable ICU 69
1762 */
1763 U_CAPI void U_EXPORT2
1764 ucal_getTimeZoneOffsetFromLocal(
1765     const UCalendar* cal,
1766     UTimeZoneLocalOption nonExistingTimeOpt,
1767     UTimeZoneLocalOption duplicatedTimeOpt,
1768     int32_t* rawOffset, int32_t* dstOffset, UErrorCode* status);
1769 
1770 #endif /* #if !UCONFIG_NO_FORMATTING */
1771 
1772 #endif
1773