Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-17 08:25:14

0001 // © 2016 and later: Unicode, Inc. and others.
0002 // License & terms of use: http://www.unicode.org/copyright.html
0003 /*
0004  *******************************************************************************
0005  * Copyright (C) 1996-2015, International Business Machines Corporation and
0006  * others. All Rights Reserved.
0007  *******************************************************************************
0008  */
0009 
0010 #ifndef UCAL_H
0011 #define UCAL_H
0012 
0013 #include "unicode/utypes.h"
0014 #include "unicode/uenum.h"
0015 #include "unicode/uloc.h"
0016 
0017 #if U_SHOW_CPLUSPLUS_API
0018 #include "unicode/localpointer.h"
0019 #endif   // U_SHOW_CPLUSPLUS_API
0020 
0021 #if !UCONFIG_NO_FORMATTING
0022 
0023 /**
0024  * \file
0025  * \brief C API: Calendar
0026  *
0027  * <h2>Calendar C API</h2>
0028  *
0029  * UCalendar C API is used  for converting between a <code>UDate</code> object
0030  * and a set of integer fields such as <code>UCAL_YEAR</code>, <code>UCAL_MONTH</code>,
0031  * <code>UCAL_DAY</code>, <code>UCAL_HOUR</code>, and so on.
0032  * (A <code>UDate</code> object represents a specific instant in
0033  * time with millisecond precision. See UDate
0034  * for information about the <code>UDate</code> .)
0035  *
0036  * <p>
0037  * Types of <code>UCalendar</code> interpret a <code>UDate</code>
0038  * according to the rules of a specific calendar system. The C API
0039  * provides the enum UCalendarType with UCAL_TRADITIONAL and
0040  * UCAL_GREGORIAN.
0041  * <p>
0042  * Like other locale-sensitive C API, calendar API  provides a
0043  * function, <code>ucal_open()</code>, which returns a pointer to
0044  * <code>UCalendar</code> whose time fields have been initialized
0045  * with the current date and time. We need to specify the type of
0046  * calendar to be opened and the  timezoneId.
0047  * \htmlonly<blockquote>\endhtmlonly
0048  * <pre>
0049  * \code
0050  * UCalendar *caldef;
0051  * UChar *tzId;
0052  * UErrorCode status;
0053  * tzId=(UChar*)malloc(sizeof(UChar) * (strlen("PST") +1) );
0054  * u_uastrcpy(tzId, "PST");
0055  * caldef=ucal_open(tzID, u_strlen(tzID), NULL, UCAL_TRADITIONAL, &status);
0056  * \endcode
0057  * </pre>
0058  * \htmlonly</blockquote>\endhtmlonly
0059  *
0060  * <p>
0061  * A <code>UCalendar</code> object can produce all the time field values
0062  * needed to implement the date-time formatting for a particular language
0063  * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
0064  *
0065  * <p>
0066  * When computing a <code>UDate</code> from time fields, two special circumstances
0067  * may arise: there may be insufficient information to compute the
0068  * <code>UDate</code> (such as only year and month but no day in the month),
0069  * or there may be inconsistent information (such as "Tuesday, July 15, 1996"
0070  * -- July 15, 1996 is actually a Monday).
0071  *
0072  * <p>
0073  * <strong>Insufficient information.</strong> The calendar will use default
0074  * information to specify the missing fields. This may vary by calendar; for
0075  * the Gregorian calendar, the default for a field is the same as that of the
0076  * start of the epoch: i.e., UCAL_YEAR = 1970, UCAL_MONTH = JANUARY, UCAL_DATE = 1, etc.
0077  *
0078  * <p>
0079  * <strong>Inconsistent information.</strong> If fields conflict, the calendar
0080  * will give preference to fields set more recently. For example, when
0081  * determining the day, the calendar will look for one of the following
0082  * combinations of fields.  The most recent combination, as determined by the
0083  * most recently set single field, will be used.
0084  *
0085  * \htmlonly<blockquote>\endhtmlonly
0086  * <pre>
0087  * \code
0088  * UCAL_MONTH + UCAL_DAY_OF_MONTH
0089  * UCAL_MONTH + UCAL_WEEK_OF_MONTH + UCAL_DAY_OF_WEEK
0090  * UCAL_MONTH + UCAL_DAY_OF_WEEK_IN_MONTH + UCAL_DAY_OF_WEEK
0091  * UCAL_DAY_OF_YEAR
0092  * UCAL_DAY_OF_WEEK + UCAL_WEEK_OF_YEAR
0093  * \endcode
0094  * </pre>
0095  * \htmlonly</blockquote>\endhtmlonly
0096  *
0097  * For the time of day:
0098  *
0099  * \htmlonly<blockquote>\endhtmlonly
0100  * <pre>
0101  * \code
0102  * UCAL_HOUR_OF_DAY
0103  * UCAL_AM_PM + UCAL_HOUR
0104  * \endcode
0105  * </pre>
0106  * \htmlonly</blockquote>\endhtmlonly
0107  *
0108  * <p>
0109  * <strong>Note:</strong> for some non-Gregorian calendars, different
0110  * fields may be necessary for complete disambiguation. For example, a full
0111  * specification of the historical Arabic astronomical calendar requires year,
0112  * month, day-of-month <em>and</em> day-of-week in some cases.
0113  *
0114  * <p>
0115  * <strong>Note:</strong> There are certain possible ambiguities in
0116  * interpretation of certain singular times, which are resolved in the
0117  * following ways:
0118  * <ol>
0119  *     <li> 24:00:00 "belongs" to the following day. That is,
0120  *          23:59 on Dec 31, 1969 &lt; 24:00 on Jan 1, 1970 &lt; 24:01:00 on Jan 1, 1970
0121  *
0122  *     <li> Although historically not precise, midnight also belongs to "am",
0123  *          and noon belongs to "pm", so on the same day,
0124  *          12:00 am (midnight) &lt; 12:01 am, and 12:00 pm (noon) &lt; 12:01 pm
0125  * </ol>
0126  *
0127  * <p>
0128  * The date or time format strings are not part of the definition of a
0129  * calendar, as those must be modifiable or overridable by the user at
0130  * runtime. Use {@link icu::DateFormat}
0131  * to format dates.
0132  *
0133  * <p>
0134  * <code>Calendar</code> provides an API for field "rolling", where fields
0135  * can be incremented or decremented, but wrap around. For example, rolling the
0136  * month up in the date <code>December 12, <b>1996</b></code> results in
0137  * <code>January 12, <b>1996</b></code>.
0138  *
0139  * <p>
0140  * <code>Calendar</code> also provides a date arithmetic function for
0141  * adding the specified (signed) amount of time to a particular time field.
0142  * For example, subtracting 5 days from the date <code>September 12, 1996</code>
0143  * results in <code>September 7, 1996</code>.
0144  *
0145  * <p>
0146  * The Japanese calendar uses a combination of era name and year number.
0147  * When an emperor of Japan abdicates and a new emperor ascends the throne,
0148  * a new era is declared and year number is reset to 1. Even if the date of
0149  * abdication is scheduled ahead of time, the new era name might not be
0150  * announced until just before the date. In such case, ICU4C may include
0151  * a start date of future era without actual era name, but not enabled
0152  * by default. ICU4C users who want to test the behavior of the future era
0153  * can enable the tentative era by:
0154  * <ul>
0155  * <li>Environment variable <code>ICU_ENABLE_TENTATIVE_ERA=true</code>.</li>
0156  * </ul>
0157  *
0158  * @stable ICU 2.0
0159  */
0160 
0161 /**
0162  * The time zone ID reserved for unknown time zone.
0163  * It behaves like the GMT/UTC time zone but has the special ID "Etc/Unknown".
0164  * @stable ICU 4.8
0165  */
0166 #define UCAL_UNKNOWN_ZONE_ID "Etc/Unknown"
0167 
0168 /** A calendar.
0169  *  For usage in C programs.
0170  * @stable ICU 2.0
0171  */
0172 typedef void* UCalendar;
0173 
0174 /** Possible types of UCalendars 
0175  * @stable ICU 2.0
0176  */
0177 enum UCalendarType {
0178   /**
0179    * Despite the name, UCAL_TRADITIONAL designates the locale's default calendar,
0180    * which may be the Gregorian calendar or some other calendar.
0181    * @stable ICU 2.0
0182    */
0183   UCAL_TRADITIONAL,
0184   /**
0185    * A better name for UCAL_TRADITIONAL.
0186    * @stable ICU 4.2
0187    */
0188   UCAL_DEFAULT = UCAL_TRADITIONAL,
0189   /**
0190    * Unambiguously designates the Gregorian calendar for the locale.
0191    * @stable ICU 2.0
0192    */
0193   UCAL_GREGORIAN
0194 };
0195 
0196 /** @stable ICU 2.0 */
0197 typedef enum UCalendarType UCalendarType;
0198 
0199 /** Possible fields in a UCalendar 
0200  * @stable ICU 2.0
0201  */
0202 enum UCalendarDateFields {
0203   /** 
0204    * Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar. 
0205    * This is a calendar-specific value.
0206    * @stable ICU 2.6 
0207    */
0208   UCAL_ERA,
0209 
0210   /**
0211    * Field number indicating the year. This is a calendar-specific value.
0212    * @stable ICU 2.6 
0213    */
0214   UCAL_YEAR,
0215 
0216   /**
0217    * Field number indicating the month. This is a calendar-specific value. 
0218    * The first month of the year is
0219    * <code>JANUARY</code>; the last depends on the number of months in a year.
0220    * @see #UCAL_JANUARY
0221    * @see #UCAL_FEBRUARY
0222    * @see #UCAL_MARCH
0223    * @see #UCAL_APRIL
0224    * @see #UCAL_MAY
0225    * @see #UCAL_JUNE
0226    * @see #UCAL_JULY
0227    * @see #UCAL_AUGUST
0228    * @see #UCAL_SEPTEMBER
0229    * @see #UCAL_OCTOBER
0230    * @see #UCAL_NOVEMBER
0231    * @see #UCAL_DECEMBER
0232    * @see #UCAL_UNDECIMBER
0233    * @stable ICU 2.6 
0234    */
0235   UCAL_MONTH,
0236 
0237   /**
0238    * Field number indicating the
0239    * week number within the current year.  The first week of the year, as
0240    * defined by <code>UCAL_FIRST_DAY_OF_WEEK</code> and <code>UCAL_MINIMAL_DAYS_IN_FIRST_WEEK</code>
0241    * attributes, has value 1.  Subclasses define
0242    * the value of <code>UCAL_WEEK_OF_YEAR</code> for days before the first week of
0243    * the year.
0244    * @see ucal_getAttribute
0245    * @see ucal_setAttribute
0246    * @stable ICU 2.6 
0247    */
0248   UCAL_WEEK_OF_YEAR,
0249 
0250  /**
0251    * Field number indicating the
0252    * week number within the current month.  The first week of the month, as
0253    * defined by <code>UCAL_FIRST_DAY_OF_WEEK</code> and <code>UCAL_MINIMAL_DAYS_IN_FIRST_WEEK</code>
0254    * attributes, has value 1.  Subclasses define
0255    * the value of <code>WEEK_OF_MONTH</code> for days before the first week of
0256    * the month.
0257    * @see ucal_getAttribute
0258    * @see ucal_setAttribute
0259    * @see #UCAL_FIRST_DAY_OF_WEEK
0260    * @see #UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
0261    * @stable ICU 2.6 
0262    */
0263   UCAL_WEEK_OF_MONTH,
0264 
0265  /**
0266    * Field number indicating the
0267    * day of the month. This is a synonym for <code>DAY_OF_MONTH</code>.
0268    * The first day of the month has value 1.
0269    * @see #UCAL_DAY_OF_MONTH
0270    * @stable ICU 2.6 
0271    */
0272   UCAL_DATE,
0273 
0274  /**
0275    * Field number indicating the day
0276    * number within the current year.  The first day of the year has value 1.
0277    * @stable ICU 2.6 
0278    */
0279   UCAL_DAY_OF_YEAR,
0280 
0281  /**
0282    * Field number indicating the day
0283    * of the week.  This field takes values <code>SUNDAY</code>,
0284    * <code>MONDAY</code>, <code>TUESDAY</code>, <code>WEDNESDAY</code>,
0285    * <code>THURSDAY</code>, <code>FRIDAY</code>, and <code>SATURDAY</code>.
0286    * @see #UCAL_SUNDAY
0287    * @see #UCAL_MONDAY
0288    * @see #UCAL_TUESDAY
0289    * @see #UCAL_WEDNESDAY
0290    * @see #UCAL_THURSDAY
0291    * @see #UCAL_FRIDAY
0292    * @see #UCAL_SATURDAY
0293    * @stable ICU 2.6 
0294    */
0295   UCAL_DAY_OF_WEEK,
0296 
0297  /**
0298    * Field number indicating the
0299    * ordinal number of the day of the week within the current month. Together
0300    * with the <code>DAY_OF_WEEK</code> field, this uniquely specifies a day
0301    * within a month.  Unlike <code>WEEK_OF_MONTH</code> and
0302    * <code>WEEK_OF_YEAR</code>, this field's value does <em>not</em> depend on
0303    * <code>getFirstDayOfWeek()</code> or
0304    * <code>getMinimalDaysInFirstWeek()</code>.  <code>DAY_OF_MONTH 1</code>
0305    * through <code>7</code> always correspond to <code>DAY_OF_WEEK_IN_MONTH
0306    * 1</code>; <code>8</code> through <code>15</code> correspond to
0307    * <code>DAY_OF_WEEK_IN_MONTH 2</code>, and so on.
0308    * <code>DAY_OF_WEEK_IN_MONTH 0</code> indicates the week before
0309    * <code>DAY_OF_WEEK_IN_MONTH 1</code>.  Negative values count back from the
0310    * end of the month, so the last Sunday of a month is specified as
0311    * <code>DAY_OF_WEEK = SUNDAY, DAY_OF_WEEK_IN_MONTH = -1</code>.  Because
0312    * negative values count backward they will usually be aligned differently
0313    * within the month than positive values.  For example, if a month has 31
0314    * days, <code>DAY_OF_WEEK_IN_MONTH -1</code> will overlap
0315    * <code>DAY_OF_WEEK_IN_MONTH 5</code> and the end of <code>4</code>.
0316    * @see #UCAL_DAY_OF_WEEK
0317    * @see #UCAL_WEEK_OF_MONTH
0318    * @stable ICU 2.6 
0319    */
0320   UCAL_DAY_OF_WEEK_IN_MONTH,
0321 
0322  /**
0323    * Field number indicating
0324    * whether the <code>HOUR</code> is before or after noon.
0325    * E.g., at 10:04:15.250 PM the <code>AM_PM</code> is <code>PM</code>.
0326    * @see #UCAL_AM
0327    * @see #UCAL_PM
0328    * @see #UCAL_HOUR
0329    * @stable ICU 2.6 
0330    */
0331   UCAL_AM_PM,
0332 
0333  /**
0334    * Field number indicating the
0335    * hour of the morning or afternoon. <code>HOUR</code> is used for the 12-hour
0336    * clock.
0337    * E.g., at 10:04:15.250 PM the <code>HOUR</code> is 10.
0338    * @see #UCAL_AM_PM
0339    * @see #UCAL_HOUR_OF_DAY
0340    * @stable ICU 2.6 
0341    */
0342   UCAL_HOUR,
0343 
0344  /**
0345    * Field number indicating the
0346    * hour of the day. <code>HOUR_OF_DAY</code> is used for the 24-hour clock.
0347    * E.g., at 10:04:15.250 PM the <code>HOUR_OF_DAY</code> is 22.
0348    * @see #UCAL_HOUR
0349    * @stable ICU 2.6 
0350    */
0351   UCAL_HOUR_OF_DAY,
0352 
0353  /**
0354    * Field number indicating the
0355    * minute within the hour.
0356    * E.g., at 10:04:15.250 PM the <code>UCAL_MINUTE</code> is 4.
0357    * @stable ICU 2.6 
0358    */
0359   UCAL_MINUTE,
0360 
0361  /**
0362    * Field number indicating the
0363    * second within the minute.
0364    * E.g., at 10:04:15.250 PM the <code>UCAL_SECOND</code> is 15.
0365    * @stable ICU 2.6 
0366    */
0367   UCAL_SECOND,
0368 
0369  /**
0370    * Field number indicating the
0371    * millisecond within the second.
0372    * E.g., at 10:04:15.250 PM the <code>UCAL_MILLISECOND</code> is 250.
0373    * @stable ICU 2.6 
0374    */
0375   UCAL_MILLISECOND,
0376 
0377  /**
0378    * Field number indicating the
0379    * raw offset from GMT in milliseconds.
0380    * @stable ICU 2.6 
0381    */
0382   UCAL_ZONE_OFFSET,
0383 
0384  /**
0385    * Field number indicating the
0386    * daylight savings offset in milliseconds.
0387    * @stable ICU 2.6 
0388    */
0389   UCAL_DST_OFFSET,
0390   
0391  /**
0392    * Field number 
0393    * indicating the extended year corresponding to the
0394    * <code>UCAL_WEEK_OF_YEAR</code> field.  This may be one greater or less
0395    * than the value of <code>UCAL_EXTENDED_YEAR</code>.
0396    * @stable ICU 2.6
0397    */
0398   UCAL_YEAR_WOY,
0399 
0400  /**
0401    * Field number 
0402    * indicating the localized day of week.  This will be a value from 1
0403    * to 7 inclusive, with 1 being the localized first day of the week.
0404    * @stable ICU 2.6
0405    */
0406   UCAL_DOW_LOCAL,
0407 
0408   /**
0409    * Year of this calendar system, encompassing all supra-year fields. For example, 
0410    * in Gregorian/Julian calendars, positive Extended Year values indicate years AD,
0411    *  1 BC = 0 extended, 2 BC = -1 extended, and so on. 
0412    * @stable ICU 2.8 
0413    */
0414   UCAL_EXTENDED_YEAR,
0415 
0416  /**
0417    * Field number 
0418    * indicating the modified Julian day number.  This is different from
0419    * the conventional Julian day number in two regards.  First, it
0420    * demarcates days at local zone midnight, rather than noon GMT.
0421    * Second, it is a local number; that is, it depends on the local time
0422    * zone.  It can be thought of as a single number that encompasses all
0423    * the date-related fields.
0424    * @stable ICU 2.8
0425    */
0426   UCAL_JULIAN_DAY, 
0427 
0428   /**
0429    * Ranges from 0 to 23:59:59.999 (regardless of DST).  This field behaves <em>exactly</em> 
0430    * like a composite of all time-related fields, not including the zone fields.  As such, 
0431    * it also reflects discontinuities of those fields on DST transition days.  On a day
0432    * of DST onset, it will jump forward.  On a day of DST cessation, it will jump 
0433    * backward.  This reflects the fact that it must be combined with the DST_OFFSET field
0434    * to obtain a unique local time value.
0435    * @stable ICU 2.8
0436    */
0437   UCAL_MILLISECONDS_IN_DAY,
0438 
0439   /**
0440    * Whether or not the current month is a leap month (0 or 1). See the Chinese calendar for
0441    * an example of this.
0442    */
0443   UCAL_IS_LEAP_MONTH,
0444 
0445   /**
0446    * Field number indicating the month. This is a calendar-specific value.
0447    * Differ from UCAL_MONTH, this value is continuous and unique within a
0448    * year and range from 0 to 11 or 0 to 12 depending on how many months in a
0449    * year, the calendar system has leap month or not, and in leap year or not.
0450    * It is the ordinal position of that month in the corresponding year of
0451    * the calendar. For Chinese, Dangi, and Hebrew calendar, the range is
0452    * 0 to 11 in non-leap years and 0 to 12 in leap years. For Coptic and Ethiopian
0453    * calendar, the range is always 0 to 12. For other calendars supported by
0454    * ICU now, the range is 0 to 11. When the number of months in a year of the
0455    * identified calendar is variable, a different UCAL_ORDINAL_MONTH value can
0456    * be used for dates that are part of the same named month in different years.
0457    * For example, in the Hebrew calendar, "1 Nisan 5781" is associated with
0458    * UCAL_ORDINAL_MONTH value 6 while "1 Nisan 5782" is associated with
0459    * UCAL_ORDINAL_MONTH value 7 because 5782 is a leap year and Nisan follows
0460    * the insertion of Adar I. In Chinese calendar, "Year 4664 Month 6 Day 2"
0461    * is associated with UCAL_ORDINAL_MONTH value 5 while "Year 4665 Month 6 Day 2"
0462    * is associated with UCAL_ORDINAL_MONTH value 6 because 4665 is a leap year
0463    * and there is an extra "Leap Month 5" which associated with UCAL_ORDINAL_MONTH
0464    * value 5 before "Month 6" of year 4664.
0465    *
0466    * @stable ICU 73
0467    */
0468   UCAL_ORDINAL_MONTH,
0469 
0470     /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
0471      * it is needed for layout of Calendar, DateFormat, and other objects */
0472 #ifndef U_FORCE_HIDE_DEPRECATED_API
0473     /**
0474      * One more than the highest normal UCalendarDateFields value.
0475      * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420.
0476      */
0477     UCAL_FIELD_COUNT = UCAL_ORDINAL_MONTH + 1,
0478 
0479 #endif  // U_FORCE_HIDE_DEPRECATED_API
0480 
0481  /**
0482    * Field number indicating the
0483    * day of the month. This is a synonym for <code>UCAL_DATE</code>.
0484    * The first day of the month has value 1.
0485    * @see #UCAL_DATE
0486    * Synonym for UCAL_DATE
0487    * @stable ICU 2.8
0488    **/
0489   UCAL_DAY_OF_MONTH=UCAL_DATE
0490 };
0491 
0492 /** @stable ICU 2.0 */
0493 typedef enum UCalendarDateFields UCalendarDateFields;
0494     /**
0495      * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients
0496      * who create locale resources for the field of first-day-of-week should be aware of
0497      * this. For instance, in US locale, first-day-of-week is set to 1, i.e., UCAL_SUNDAY.
0498      */
0499 /** Possible days of the week in a UCalendar 
0500  * @stable ICU 2.0
0501  */
0502 enum UCalendarDaysOfWeek {
0503   /** Sunday */
0504   UCAL_SUNDAY = 1,
0505   /** Monday */
0506   UCAL_MONDAY,
0507   /** Tuesday */
0508   UCAL_TUESDAY,
0509   /** Wednesday */
0510   UCAL_WEDNESDAY,
0511   /** Thursday */
0512   UCAL_THURSDAY,
0513   /** Friday */
0514   UCAL_FRIDAY,
0515   /** Saturday */
0516   UCAL_SATURDAY
0517 };
0518 
0519 /** @stable ICU 2.0 */
0520 typedef enum UCalendarDaysOfWeek UCalendarDaysOfWeek;
0521 
0522 /** Possible months in a UCalendar. Note: Calendar month is 0-based.
0523  * @stable ICU 2.0
0524  */
0525 enum UCalendarMonths {
0526   /** January */
0527   UCAL_JANUARY,
0528   /** February */
0529   UCAL_FEBRUARY,
0530   /** March */
0531   UCAL_MARCH,
0532   /** April */
0533   UCAL_APRIL,
0534   /** May */
0535   UCAL_MAY,
0536   /** June */
0537   UCAL_JUNE,
0538   /** July */
0539   UCAL_JULY,
0540   /** August */
0541   UCAL_AUGUST,
0542   /** September */
0543   UCAL_SEPTEMBER,
0544   /** October */
0545   UCAL_OCTOBER,
0546   /** November */
0547   UCAL_NOVEMBER,
0548   /** December */
0549   UCAL_DECEMBER,
0550   /** Value of the <code>UCAL_MONTH</code> field indicating the
0551     * thirteenth month of the year. Although the Gregorian calendar
0552     * does not use this value, lunar calendars do.
0553     */
0554   UCAL_UNDECIMBER
0555 };
0556 
0557 /** @stable ICU 2.0 */
0558 typedef enum UCalendarMonths UCalendarMonths;
0559 
0560 /** Possible AM/PM values in a UCalendar 
0561  * @stable ICU 2.0
0562  */
0563 enum UCalendarAMPMs {
0564     /** AM */
0565   UCAL_AM,
0566   /** PM */
0567   UCAL_PM
0568 };
0569 
0570 /** @stable ICU 2.0 */
0571 typedef enum UCalendarAMPMs UCalendarAMPMs;
0572 
0573 /**
0574  * System time zone type constants used by filtering zones
0575  * in ucal_openTimeZoneIDEnumeration.
0576  * @see ucal_openTimeZoneIDEnumeration
0577  * @stable ICU 4.8
0578  */
0579 enum USystemTimeZoneType {
0580     /**
0581      * Any system zones.
0582      * @stable ICU 4.8
0583      */
0584     UCAL_ZONE_TYPE_ANY,
0585     /**
0586      * Canonical system zones.
0587      * @stable ICU 4.8
0588      */
0589     UCAL_ZONE_TYPE_CANONICAL,
0590     /**
0591      * Canonical system zones associated with actual locations.
0592      * @stable ICU 4.8
0593      */
0594     UCAL_ZONE_TYPE_CANONICAL_LOCATION
0595 };
0596 
0597 /** @stable ICU 4.8 */
0598 typedef enum USystemTimeZoneType USystemTimeZoneType;
0599 
0600 /** 
0601  * Create an enumeration over system time zone IDs with the given
0602  * filter conditions. 
0603  * @param zoneType  The system time zone type.
0604  * @param region    The ISO 3166 two-letter country code or UN M.49
0605  *                  three-digit area code.  When NULL, no filtering
0606  *                  done by region. 
0607  * @param rawOffset An offset from GMT in milliseconds, ignoring the
0608  *                  effect of daylight savings time, if any. When NULL,
0609  *                  no filtering done by zone offset.
0610  * @param ec        A pointer to an UErrorCode to receive any errors
0611  * @return  an enumeration object that the caller must dispose of
0612  *          using enum_close(), or NULL upon failure. In case of failure,
0613  *          *ec will indicate the error.
0614  * @stable ICU 4.8
0615  */ 
0616 U_CAPI UEnumeration* U_EXPORT2
0617 ucal_openTimeZoneIDEnumeration(USystemTimeZoneType zoneType, const char* region,
0618                                 const int32_t* rawOffset, UErrorCode* ec);
0619 
0620 /**
0621  * Create an enumeration over all time zones.
0622  *
0623  * @param ec input/output error code
0624  *
0625  * @return an enumeration object that the caller must dispose of using
0626  * uenum_close(), or NULL upon failure. In case of failure *ec will
0627  * indicate the error.
0628  *
0629  * @stable ICU 2.6
0630  */
0631 U_CAPI UEnumeration* U_EXPORT2
0632 ucal_openTimeZones(UErrorCode* ec);
0633 
0634 /**
0635  * Create an enumeration over all time zones associated with the given
0636  * country. Some zones are affiliated with no country (e.g., "UTC");
0637  * these may also be retrieved, as a group.
0638  *
0639  * @param country the ISO 3166 two-letter country code, or NULL to
0640  * retrieve zones not affiliated with any country
0641  *
0642  * @param ec input/output error code
0643  *
0644  * @return an enumeration object that the caller must dispose of using
0645  * uenum_close(), or NULL upon failure. In case of failure *ec will
0646  * indicate the error.
0647  *
0648  * @stable ICU 2.6
0649  */
0650 U_CAPI UEnumeration* U_EXPORT2
0651 ucal_openCountryTimeZones(const char* country, UErrorCode* ec);
0652 
0653 /**
0654  * Return the default time zone. The default is determined initially
0655  * by querying the host operating system. If the host system detection
0656  * routines fail, or if they specify a TimeZone or TimeZone offset
0657  * which is not recognized, then the special TimeZone "Etc/Unknown"
0658  * is returned.
0659  * 
0660  * The default may be changed with `ucal_setDefaultTimeZone()` or with
0661  * the C++ TimeZone API, `TimeZone::adoptDefault(TimeZone*)`.
0662  *
0663  * @param result A buffer to receive the result, or NULL
0664  *
0665  * @param resultCapacity The capacity of the result buffer
0666  *
0667  * @param ec input/output error code
0668  *
0669  * @return The result string length, not including the terminating
0670  * null
0671  * 
0672  * @see #UCAL_UNKNOWN_ZONE_ID
0673  * 
0674  * @stable ICU 2.6
0675  */
0676 U_CAPI int32_t U_EXPORT2
0677 ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec);
0678 
0679 /**
0680  * Set the default time zone.
0681  *
0682  * @param zoneID null-terminated time zone ID
0683  *
0684  * @param ec input/output error code
0685  *
0686  * @stable ICU 2.6
0687  */
0688 U_CAPI void U_EXPORT2
0689 ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec);
0690 
0691 /**
0692  * Return the current host time zone. The host time zone is detected from
0693  * the current host system configuration by querying the host operating
0694  * system. If the host system detection routines fail, or if they specify
0695  * a TimeZone or TimeZone offset which is not recognized, then the special
0696  * TimeZone "Etc/Unknown" is returned.
0697  * 
0698  * Note that host time zone and the ICU default time zone can be different.
0699  * 
0700  * The ICU default time zone does not change once initialized unless modified
0701  * by calling `ucal_setDefaultTimeZone()` or with the C++ TimeZone API,
0702  * `TimeZone::adoptDefault(TimeZone*)`.
0703  * 
0704  * If the host operating system configuration has changed since ICU has
0705  * initialized then the returned value can be different than the ICU default
0706  * time zone, even if the default has not changed.
0707  *
0708  * <p>This function is not thread safe.</p>
0709  * 
0710  * @param result A buffer to receive the result, or NULL
0711  * @param resultCapacity The capacity of the result buffer
0712  * @param ec input/output error code
0713  * @return The result string length, not including the terminating
0714  * null
0715  * 
0716  * @see #UCAL_UNKNOWN_ZONE_ID
0717  * 
0718  * @stable ICU 65
0719  */
0720 U_CAPI int32_t U_EXPORT2
0721 ucal_getHostTimeZone(UChar *result, int32_t resultCapacity, UErrorCode *ec);
0722 
0723 /**
0724  * Return the amount of time in milliseconds that the clock is
0725  * advanced during daylight savings time for the given time zone, or
0726  * zero if the time zone does not observe daylight savings time.
0727  *
0728  * @param zoneID null-terminated time zone ID
0729  *
0730  * @param ec input/output error code
0731  *
0732  * @return the number of milliseconds the time is advanced with
0733  * respect to standard time when the daylight savings rules are in
0734  * effect. This is always a non-negative number, most commonly either
0735  * 3,600,000 (one hour) or zero.
0736  *
0737  * @stable ICU 2.6
0738  */
0739 U_CAPI int32_t U_EXPORT2
0740 ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec);
0741 
0742 /**
0743  * Get the current date and time.
0744  * The value returned is represented as milliseconds from the epoch.
0745  * @return The current date and time.
0746  * @stable ICU 2.0
0747  */
0748 U_CAPI UDate U_EXPORT2 
0749 ucal_getNow(void);
0750 
0751 /**
0752  * Open a UCalendar.
0753  * A UCalendar may be used to convert a millisecond value to a year,
0754  * month, and day.
0755  * <p>
0756  * Note: When unknown TimeZone ID is specified or if the TimeZone ID specified is "Etc/Unknown",
0757  * the UCalendar returned by the function is initialized with GMT zone with TimeZone ID
0758  * <code>UCAL_UNKNOWN_ZONE_ID</code> ("Etc/Unknown") without any errors/warnings.  If you want
0759  * to check if a TimeZone ID is valid prior to this function, use <code>ucal_getCanonicalTimeZoneID</code>.
0760  * 
0761  * @param zoneID The desired TimeZone ID.  If 0, use the default time zone.
0762  * @param len The length of zoneID, or -1 if null-terminated.
0763  * @param locale The desired locale
0764  * @param type The type of UCalendar to open. This can be UCAL_GREGORIAN to open the Gregorian
0765  * calendar for the locale, or UCAL_DEFAULT to open the default calendar for the locale (the
0766  * default calendar may also be Gregorian). To open a specific non-Gregorian calendar for the
0767  * locale, use uloc_setKeywordValue to set the value of the calendar keyword for the locale
0768  * and then pass the locale to ucal_open with UCAL_DEFAULT as the type.
0769  * @param status A pointer to an UErrorCode to receive any errors
0770  * @return A pointer to a UCalendar, or 0 if an error occurred.
0771  * @see #UCAL_UNKNOWN_ZONE_ID
0772  * @stable ICU 2.0
0773  */
0774 U_CAPI UCalendar* U_EXPORT2 
0775 ucal_open(const UChar*   zoneID,
0776           int32_t        len,
0777           const char*    locale,
0778           UCalendarType  type,
0779           UErrorCode*    status);
0780 
0781 /**
0782  * Close a UCalendar.
0783  * Once closed, a UCalendar may no longer be used.
0784  * @param cal The UCalendar to close.
0785  * @stable ICU 2.0
0786  */
0787 U_CAPI void U_EXPORT2 
0788 ucal_close(UCalendar *cal);
0789 
0790 #if U_SHOW_CPLUSPLUS_API
0791 
0792 U_NAMESPACE_BEGIN
0793 
0794 /**
0795  * \class LocalUCalendarPointer
0796  * "Smart pointer" class, closes a UCalendar via ucal_close().
0797  * For most methods see the LocalPointerBase base class.
0798  *
0799  * @see LocalPointerBase
0800  * @see LocalPointer
0801  * @stable ICU 4.4
0802  */
0803 U_DEFINE_LOCAL_OPEN_POINTER(LocalUCalendarPointer, UCalendar, ucal_close);
0804 
0805 U_NAMESPACE_END
0806 
0807 #endif
0808 
0809 /**
0810  * Open a copy of a UCalendar.
0811  * This function performs a deep copy.
0812  * @param cal The calendar to copy
0813  * @param status A pointer to an UErrorCode to receive any errors.
0814  * @return A pointer to a UCalendar identical to cal.
0815  * @stable ICU 4.0
0816  */
0817 U_CAPI UCalendar* U_EXPORT2 
0818 ucal_clone(const UCalendar* cal,
0819            UErrorCode*      status);
0820 
0821 /**
0822  * Set the TimeZone used by a UCalendar.
0823  * A UCalendar uses a timezone for converting from Greenwich time to local time.
0824  * @param cal The UCalendar to set.
0825  * @param zoneID The desired TimeZone ID.  If 0, use the default time zone.
0826  * @param len The length of zoneID, or -1 if null-terminated.
0827  * @param status A pointer to an UErrorCode to receive any errors.
0828  * @stable ICU 2.0
0829  */
0830 U_CAPI void U_EXPORT2 
0831 ucal_setTimeZone(UCalendar*    cal,
0832                  const UChar*  zoneID,
0833                  int32_t       len,
0834                  UErrorCode*   status);
0835 
0836 /** 
0837  * Get the ID of the UCalendar's time zone. 
0838  * 
0839  * @param cal           The UCalendar to query. 
0840  * @param result        Receives the UCalendar's time zone ID. 
0841  * @param resultLength  The maximum size of result. 
0842  * @param status        Receives the status. 
0843  * @return              The total buffer size needed; if greater than resultLength, the output was truncated. 
0844  * @stable ICU 51 
0845  */ 
0846 U_CAPI int32_t U_EXPORT2 
0847 ucal_getTimeZoneID(const UCalendar *cal,
0848                    UChar *result,
0849                    int32_t resultLength,
0850                    UErrorCode *status);
0851 
0852 /**
0853  * Possible formats for a UCalendar's display name 
0854  * @stable ICU 2.0
0855  */
0856 enum UCalendarDisplayNameType {
0857   /** Standard display name */
0858   UCAL_STANDARD,
0859   /** Short standard display name */
0860   UCAL_SHORT_STANDARD,
0861   /** Daylight savings display name */
0862   UCAL_DST,
0863   /** Short daylight savings display name */
0864   UCAL_SHORT_DST
0865 };
0866 
0867 /** @stable ICU 2.0 */
0868 typedef enum UCalendarDisplayNameType UCalendarDisplayNameType;
0869 
0870 /**
0871  * Get the display name for a UCalendar's TimeZone.
0872  * A display name is suitable for presentation to a user.
0873  * @param cal          The UCalendar to query.
0874  * @param type         The desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD,
0875  *                     UCAL_DST, UCAL_SHORT_DST
0876  * @param locale       The desired locale for the display name.
0877  * @param result       A pointer to a buffer to receive the formatted number.
0878  * @param resultLength The maximum size of result.
0879  * @param status       A pointer to an UErrorCode to receive any errors
0880  * @return             The total buffer size needed; if greater than resultLength, the output was truncated.
0881  * @stable ICU 2.0
0882  */
0883 U_CAPI int32_t U_EXPORT2 
0884 ucal_getTimeZoneDisplayName(const UCalendar*          cal,
0885                             UCalendarDisplayNameType  type,
0886                             const char*               locale,
0887                             UChar*                    result,
0888                             int32_t                   resultLength,
0889                             UErrorCode*               status);
0890 
0891 /**
0892  * Determine if a UCalendar is currently in daylight savings time.
0893  * Daylight savings time is not used in all parts of the world.
0894  * @param cal The UCalendar to query.
0895  * @param status A pointer to an UErrorCode to receive any errors
0896  * @return true if cal is currently in daylight savings time, false otherwise
0897  * @stable ICU 2.0
0898  */
0899 U_CAPI UBool U_EXPORT2 
0900 ucal_inDaylightTime(const UCalendar*  cal,
0901                     UErrorCode*       status );
0902 
0903 /**
0904  * Sets the GregorianCalendar change date. This is the point when the switch from
0905  * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October
0906  * 15, 1582. Previous to this time and date will be Julian dates.
0907  *
0908  * This function works only for Gregorian calendars. If the UCalendar is not
0909  * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR
0910  * error code is set.
0911  *
0912  * @param cal        The calendar object.
0913  * @param date       The given Gregorian cutover date.
0914  * @param pErrorCode Pointer to a standard ICU error code. Its input value must
0915  *                   pass the U_SUCCESS() test, or else the function returns
0916  *                   immediately. Check for U_FAILURE() on output or use with
0917  *                   function chaining. (See User Guide for details.)
0918  *
0919  * @see GregorianCalendar::setGregorianChange
0920  * @see ucal_getGregorianChange
0921  * @stable ICU 3.6
0922  */
0923 U_CAPI void U_EXPORT2
0924 ucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode);
0925 
0926 /**
0927  * Gets the Gregorian Calendar change date. This is the point when the switch from
0928  * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October
0929  * 15, 1582. Previous to this time and date will be Julian dates.
0930  *
0931  * This function works only for Gregorian calendars. If the UCalendar is not
0932  * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR
0933  * error code is set.
0934  *
0935  * @param cal        The calendar object.
0936  * @param pErrorCode Pointer to a standard ICU error code. Its input value must
0937  *                   pass the U_SUCCESS() test, or else the function returns
0938  *                   immediately. Check for U_FAILURE() on output or use with
0939  *                   function chaining. (See User Guide for details.)
0940  * @return   The Gregorian cutover time for this calendar.
0941  *
0942  * @see GregorianCalendar::getGregorianChange
0943  * @see ucal_setGregorianChange
0944  * @stable ICU 3.6
0945  */
0946 U_CAPI UDate U_EXPORT2
0947 ucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode);
0948 
0949 /**
0950  * Types of UCalendar attributes 
0951  * @stable ICU 2.0
0952  */
0953 enum UCalendarAttribute {
0954   /**
0955    * Lenient parsing
0956    * @stable ICU 2.0
0957    */
0958   UCAL_LENIENT,
0959   /**
0960    * First day of week
0961    * @stable ICU 2.0
0962    */
0963   UCAL_FIRST_DAY_OF_WEEK,
0964   /**
0965    * Minimum number of days in first week
0966    * @stable ICU 2.0
0967    */
0968   UCAL_MINIMAL_DAYS_IN_FIRST_WEEK,
0969   /**
0970    * The behavior for handling wall time repeating multiple times
0971    * at negative time zone offset transitions
0972    * @stable ICU 49
0973    */
0974   UCAL_REPEATED_WALL_TIME,
0975   /**
0976    * The behavior for handling skipped wall time at positive time
0977    * zone offset transitions.
0978    * @stable ICU 49
0979    */
0980   UCAL_SKIPPED_WALL_TIME
0981 };
0982 
0983 /** @stable ICU 2.0 */
0984 typedef enum UCalendarAttribute UCalendarAttribute;
0985 
0986 /**
0987  * Options for handling ambiguous wall time at time zone
0988  * offset transitions.
0989  * @stable ICU 49
0990  */
0991 enum UCalendarWallTimeOption {
0992     /**
0993      * An ambiguous wall time to be interpreted as the latest.
0994      * This option is valid for UCAL_REPEATED_WALL_TIME and
0995      * UCAL_SKIPPED_WALL_TIME.
0996      * @stable ICU 49
0997      */
0998     UCAL_WALLTIME_LAST,
0999     /**
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 /**
1391  * Returns the preferred time zone ID in the IANA time zone database for the given time zone ID.
1392  * There are two types of preferred IDs. The first type is the one defined in zone.tab file,
1393  * such as "America/Los_Angeles". The second types is the one defined for zones not associated
1394  * with a specific region, but not defined with "Link" syntax such as "Etc/GMT+10".
1395  *
1396  * <p>Note: For most of valid time zone IDs, this method returns an ID same as ucal_getCanonicalTimeZoneID().
1397  * ucal_getCanonicalTimeZoneID() is based on canonical time zone IDs defined in Unicode CLDR.
1398  * These canonical time zone IDs in CLDR were based on very old version of the time zone database.
1399  * In the IANA time zone database, some IDs were updated since then. This API returns a newer
1400  * time zone ID. For example, CLDR defines "Asia/Calcutta" as the canonical time zone ID. This
1401  * method returns "Asia/Kolkata" instead.
1402  * <p> "Etc/Unknown" is a special time zone ID defined by CLDR. There are no corresponding zones
1403  * in the IANA time zone database. Therefore, this API returns U_ILLEGAL_ARGUMENT_ERROR when the
1404  * input ID is "Etc/Unknown".
1405  *
1406  * @param id        The input time zone ID.
1407  * @param len       The length of the input time zone ID.
1408  * @param result    The buffer receives the preferred time zone ID in the IANA time zone database.
1409  * @param resultCapacity  The capacity of the result buffer.
1410  * @param status    Receives the status.  When the given time zone ID is not a known system time zone
1411  *                  ID, U_ILLEGAL_ARGUMENT_ERROR is set.
1412  * @return          The result string length, not including the terminating null.
1413  * @stable ICU 74
1414  */
1415 U_CAPI int32_t U_EXPORT2
1416 ucal_getIanaTimeZoneID(const UChar* id, int32_t len,
1417                         UChar* result, int32_t resultCapacity, UErrorCode* status);
1418 
1419 /**
1420  * Get the resource keyword value string designating the calendar type for the UCalendar.
1421  * @param cal The UCalendar to query.
1422  * @param status The error code for the operation.
1423  * @return The resource keyword value string.
1424  * @stable ICU 4.2
1425  */
1426 U_CAPI const char * U_EXPORT2
1427 ucal_getType(const UCalendar *cal, UErrorCode* status);
1428 
1429 /**
1430  * Given a key and a locale, returns an array of string values in a preferred
1431  * order that would make a difference. These are all and only those values where
1432  * the open (creation) of the service with the locale formed from the input locale
1433  * plus input keyword and that value has different behavior than creation with the
1434  * input locale alone.
1435  * @param key           one of the keys supported by this service.  For now, only
1436  *                      "calendar" is supported.
1437  * @param locale        the locale
1438  * @param commonlyUsed  if set to true it will return only commonly used values
1439  *                      with the given locale in preferred order.  Otherwise,
1440  *                      it will return all the available values for the locale.
1441  * @param status error status
1442  * @return a string enumeration over keyword values for the given key and the locale.
1443  * @stable ICU 4.2
1444  */
1445 U_CAPI UEnumeration* U_EXPORT2
1446 ucal_getKeywordValuesForLocale(const char* key,
1447                                const char* locale,
1448                                UBool commonlyUsed,
1449                                UErrorCode* status);
1450 
1451 
1452 /** Weekday types, as returned by ucal_getDayOfWeekType().
1453  * @stable ICU 4.4
1454  */
1455 enum UCalendarWeekdayType {
1456   /**
1457    * Designates a full weekday (no part of the day is included in the weekend).
1458    * @stable ICU 4.4 
1459    */
1460   UCAL_WEEKDAY,
1461   /**
1462    * Designates a full weekend day (the entire day is included in the weekend).
1463    * @stable ICU 4.4 
1464    */
1465   UCAL_WEEKEND,
1466   /**
1467    * Designates a day that starts as a weekday and transitions to the weekend.
1468    * Call ucal_getWeekendTransition() to get the time of transition.
1469    * @stable ICU 4.4 
1470    */
1471   UCAL_WEEKEND_ONSET,
1472   /**
1473    * Designates a day that starts as the weekend and transitions to a weekday.
1474    * Call ucal_getWeekendTransition() to get the time of transition.
1475    * @stable ICU 4.4 
1476    */
1477   UCAL_WEEKEND_CEASE
1478 };
1479 
1480 /** @stable ICU 4.4 */
1481 typedef enum UCalendarWeekdayType UCalendarWeekdayType;
1482 
1483 /**
1484  * Returns whether the given day of the week is a weekday, a weekend day,
1485  * or a day that transitions from one to the other, for the locale and
1486  * calendar system associated with this UCalendar (the locale's region is
1487  * often the most determinant factor). If a transition occurs at midnight,
1488  * then the days before and after the transition will have the
1489  * type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time
1490  * other than midnight, then the day of the transition will have
1491  * the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the
1492  * function ucal_getWeekendTransition() will return the point of
1493  * transition.
1494  * @param cal The UCalendar to query.
1495  * @param dayOfWeek The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY).
1496  * @param status The error code for the operation.
1497  * @return The UCalendarWeekdayType for the day of the week.
1498  * @stable ICU 4.4
1499  */
1500 U_CAPI UCalendarWeekdayType U_EXPORT2
1501 ucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode* status);
1502 
1503 /**
1504  * Returns the time during the day at which the weekend begins or ends in
1505  * this calendar system.  If ucal_getDayOfWeekType() returns UCAL_WEEKEND_ONSET
1506  * for the specified dayOfWeek, return the time at which the weekend begins.
1507  * If ucal_getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek,
1508  * return the time at which the weekend ends. If ucal_getDayOfWeekType() returns
1509  * some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition
1510  * (U_ILLEGAL_ARGUMENT_ERROR).
1511  * @param cal The UCalendar to query.
1512  * @param dayOfWeek The day of the week for which the weekend transition time is
1513  * desired (UCAL_SUNDAY..UCAL_SATURDAY).
1514  * @param status The error code for the operation.
1515  * @return The milliseconds after midnight at which the weekend begins or ends.
1516  * @stable ICU 4.4
1517  */
1518 U_CAPI int32_t U_EXPORT2
1519 ucal_getWeekendTransition(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode *status);
1520 
1521 /**
1522  * Returns true if the given UDate is in the weekend in
1523  * this calendar system.
1524  * @param cal The UCalendar to query.
1525  * @param date The UDate in question.
1526  * @param status The error code for the operation.
1527  * @return true if the given UDate is in the weekend in
1528  * this calendar system, false otherwise.
1529  * @stable ICU 4.4
1530  */
1531 U_CAPI UBool U_EXPORT2
1532 ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status);
1533 
1534 /**
1535  * Return the difference between the target time and the time this calendar object is currently set to.
1536  * If the target time is after the current calendar setting, the the returned value will be positive.
1537  * The field parameter specifies the units of the return value. For example, if field is UCAL_MONTH
1538  * and ucal_getFieldDifference returns 3, then the target time is 3 to less than 4 months after the
1539  * current calendar setting.
1540  *
1541  * As a side effect of this call, this calendar is advanced toward target by the given amount. That is,
1542  * calling this function has the side effect of calling ucal_add on this calendar with the specified
1543  * field and an amount equal to the return value from this function.
1544  *
1545  * A typical way of using this function is to call it first with the largest field of interest, then
1546  * with progressively smaller fields.
1547  * 
1548  * @param cal The UCalendar to compare and update.
1549  * @param target The target date to compare to the current calendar setting.
1550  * @param field The field to compare; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
1551  * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
1552  * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
1553  * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
1554  * @param status A pointer to an UErrorCode to receive any errors
1555  * @return The date difference for the specified field.
1556  * @stable ICU 4.8
1557  */
1558 U_CAPI int32_t U_EXPORT2 
1559 ucal_getFieldDifference(UCalendar* cal,
1560                         UDate target,
1561                         UCalendarDateFields field,
1562                         UErrorCode* status);
1563 
1564 /**
1565  * Time zone transition types for ucal_getTimeZoneTransitionDate
1566  * @stable ICU 50
1567  */
1568 enum UTimeZoneTransitionType {
1569     /**
1570      * Get the next transition after the current date,
1571      * i.e. excludes the current date
1572      * @stable ICU 50
1573      */
1574     UCAL_TZ_TRANSITION_NEXT,
1575     /**
1576      * Get the next transition on or after the current date,
1577      * i.e. may include the current date
1578      * @stable ICU 50
1579      */
1580     UCAL_TZ_TRANSITION_NEXT_INCLUSIVE,
1581     /**
1582      * Get the previous transition before the current date,
1583      * i.e. excludes the current date
1584      * @stable ICU 50
1585      */
1586     UCAL_TZ_TRANSITION_PREVIOUS,
1587     /**
1588      * Get the previous transition on or before the current date,
1589      * i.e. may include the current date
1590      * @stable ICU 50
1591      */
1592     UCAL_TZ_TRANSITION_PREVIOUS_INCLUSIVE
1593 };
1594 
1595 typedef enum UTimeZoneTransitionType UTimeZoneTransitionType; /**< @stable ICU 50 */
1596 
1597 /**
1598 * Get the UDate for the next/previous time zone transition relative to
1599 * the calendar's current date, in the time zone to which the calendar
1600 * is currently set. If there is no known time zone transition of the
1601 * requested type relative to the calendar's date, the function returns
1602 * false.
1603 * @param cal The UCalendar to query.
1604 * @param type The type of transition desired.
1605 * @param transition A pointer to a UDate to be set to the transition time.
1606 *         If the function returns false, the value set is unspecified.
1607 * @param status A pointer to a UErrorCode to receive any errors.
1608 * @return true if a valid transition time is set in *transition, false
1609 *         otherwise.
1610 * @stable ICU 50
1611 */
1612 U_CAPI UBool U_EXPORT2 
1613 ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType type,
1614                                UDate* transition, UErrorCode* status);
1615 
1616 /**
1617 * Converts a system time zone ID to an equivalent Windows time zone ID. For example,
1618 * Windows time zone ID "Pacific Standard Time" is returned for input "America/Los_Angeles".
1619 *
1620 * <p>There are system time zones that cannot be mapped to Windows zones. When the input
1621 * system time zone ID is unknown or unmappable to a Windows time zone, then this
1622 * function returns 0 as the result length, but the operation itself remains successful
1623 * (no error status set on return).
1624 *
1625 * <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html">
1626 * Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes,
1627 * please read the ICU user guide section <a href="https://unicode-org.github.io/icu/userguide/datetime/timezone#updating-the-time-zone-data">
1628 * Updating the Time Zone Data</a>.
1629 *
1630 * @param id            A system time zone ID.
1631 * @param len           The length of <code>id</code>, or -1 if null-terminated.
1632 * @param winid         A buffer to receive a Windows time zone ID.
1633 * @param winidCapacity The capacity of the result buffer <code>winid</code>.
1634 * @param status        Receives the status.
1635 * @return              The result string length, not including the terminating null.
1636 * @see ucal_getTimeZoneIDForWindowsID
1637 *
1638 * @stable ICU 52
1639 */
1640 U_CAPI int32_t U_EXPORT2
1641 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len,
1642                             UChar* winid, int32_t winidCapacity, UErrorCode* status);
1643 
1644 /**
1645 * Converts a Windows time zone ID to an equivalent system time zone ID
1646 * for a region. For example, system time zone ID "America/Los_Angeles" is returned
1647 * for input Windows ID "Pacific Standard Time" and region "US" (or <code>null</code>),
1648 * "America/Vancouver" is returned for the same Windows ID "Pacific Standard Time" and
1649 * region "CA".
1650 *
1651 * <p>Not all Windows time zones can be mapped to system time zones. When the input
1652 * Windows time zone ID is unknown or unmappable to a system time zone, then this
1653 * function returns 0 as the result length, but the operation itself remains successful
1654 * (no error status set on return).
1655 *
1656 * <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html">
1657 * Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes,
1658 * please read the ICU user guide section <a href="https://unicode-org.github.io/icu/userguide/datetime/timezone#updating-the-time-zone-data">
1659 * Updating the Time Zone Data</a>.
1660 *
1661 * @param winid         A Windows time zone ID.
1662 * @param len           The length of <code>winid</code>, or -1 if null-terminated.
1663 * @param region        A null-terminated region code, or <code>NULL</code> if no regional preference.
1664 * @param id            A buffer to receive a system time zone ID.
1665 * @param idCapacity    The capacity of the result buffer <code>id</code>.
1666 * @param status        Receives the status.
1667 * @return              The result string length, not including the terminating null.
1668 * @see ucal_getWindowsTimeZoneID
1669 *
1670 * @stable ICU 52
1671 */
1672 U_CAPI int32_t U_EXPORT2
1673 ucal_getTimeZoneIDForWindowsID(const UChar* winid, int32_t len, const char* region,
1674                                 UChar* id, int32_t idCapacity, UErrorCode* status);
1675 
1676 /**
1677  * Options used by ucal_getTimeZoneOffsetFromLocal and BasicTimeZone::getOffsetFromLocal()
1678  * to specify how to interpret an input time when it does not exist, or when it is ambiguous,
1679  * around a time zone transition.
1680  * @stable ICU 69
1681  */
1682 enum UTimeZoneLocalOption {
1683     /**
1684      * An input time is always interpreted as local time before
1685      * a time zone transition.
1686      * @stable ICU 69
1687      */
1688     UCAL_TZ_LOCAL_FORMER = 0x04,
1689     /**
1690      * An input time is always interpreted as local time after
1691      * a time zone transition.
1692      * @stable ICU 69
1693      */
1694     UCAL_TZ_LOCAL_LATTER = 0x0C,
1695     /**
1696      * An input time is interpreted as standard time when local
1697      * time is switched to/from daylight saving time. When both
1698      * sides of a time zone transition are standard time,
1699      * or daylight saving time, the local time before the
1700      * transition is used.
1701      * @stable ICU 69
1702      */
1703     UCAL_TZ_LOCAL_STANDARD_FORMER = UCAL_TZ_LOCAL_FORMER | 0x01,
1704     /**
1705      * An input time is interpreted as standard time when local
1706      * time is switched to/from daylight saving time. When both
1707      * sides of a time zone transition are standard time,
1708      * or daylight saving time, the local time after the
1709      * transition is used.
1710      * @stable ICU 69
1711      */
1712     UCAL_TZ_LOCAL_STANDARD_LATTER = UCAL_TZ_LOCAL_LATTER | 0x01,
1713     /**
1714      * An input time is interpreted as daylight saving time when
1715      * local time is switched to/from standard time. When both
1716      * sides of a time zone transition are standard time,
1717      * or daylight saving time, the local time before the
1718      * transition is used.
1719      * @stable ICU 69
1720      */
1721     UCAL_TZ_LOCAL_DAYLIGHT_FORMER = UCAL_TZ_LOCAL_FORMER | 0x03,
1722     /**
1723      * An input time is interpreted as daylight saving time when
1724      * local time is switched to/from standard time. When both
1725      * sides of a time zone transition are standard time,
1726      * or daylight saving time, the local time after the
1727      * transition is used.
1728      * @stable ICU 69
1729      */
1730     UCAL_TZ_LOCAL_DAYLIGHT_LATTER = UCAL_TZ_LOCAL_LATTER | 0x03,
1731 };
1732 typedef enum UTimeZoneLocalOption UTimeZoneLocalOption; /**< @stable ICU 69 */
1733 
1734 /**
1735 * Returns the time zone raw and GMT offset for the given moment
1736 * in time.  Upon return, local-millis = GMT-millis + rawOffset +
1737 * dstOffset.  All computations are performed in the proleptic
1738 * Gregorian calendar.
1739 *
1740 * @param cal The UCalendar which specify the local date and time value to query.
1741 * @param nonExistingTimeOpt The option to indicate how to interpret the date and
1742 * time in the calendar represent a local time that skipped at a positive time
1743 * zone transitions (e.g. when the daylight saving time starts or the time zone
1744 * offset is increased due to a time zone rule change).
1745 * @param duplicatedTimeOpt The option to indicate how to interpret the date and
1746 * time in the calendar represent a local time that repeating multiple times at a
1747 * negative time zone transition (e.g. when the daylight saving time ends or the
1748 * time zone offset is decreased due to a time zone rule change)
1749 * @param rawOffset output parameter to receive the raw offset, that
1750 * is, the offset not including DST adjustments.
1751 * If the status is set to one of the error code, the value set is unspecified.
1752 * @param dstOffset output parameter to receive the DST offset,
1753 * that is, the offset to be added to `rawOffset' to obtain the
1754 * total offset between local and GMT time. If DST is not in
1755 * effect, this value is zero; otherwise it is a positive value,
1756 * typically one hour.
1757 * If the status is set to one of the error code, the value set is unspecified.
1758 * @param status A pointer to a UErrorCode to receive any errors.
1759 * @stable ICU 69
1760 */
1761 U_CAPI void U_EXPORT2
1762 ucal_getTimeZoneOffsetFromLocal(
1763     const UCalendar* cal,
1764     UTimeZoneLocalOption nonExistingTimeOpt,
1765     UTimeZoneLocalOption duplicatedTimeOpt,
1766     int32_t* rawOffset, int32_t* dstOffset, UErrorCode* status);
1767 
1768 #endif /* #if !UCONFIG_NO_FORMATTING */
1769 
1770 #endif