|
||||
Warning, file /include/unicode/ucal.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 < 24:00 on Jan 1, 1970 < 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) < 12:01 am, and 12:00 pm (noon) < 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 #ifndef U_HIDE_DRAFT_API 0446 /** 0447 * Field number indicating the month. This is a calendar-specific value. 0448 * Differ from UCAL_MONTH, this value is continuous and unique within a 0449 * year and range from 0 to 11 or 0 to 12 depending on how many months in a 0450 * year, the calendar system has leap month or not, and in leap year or not. 0451 * It is the ordinal position of that month in the corresponding year of 0452 * the calendar. For Chinese, Dangi, and Hebrew calendar, the range is 0453 * 0 to 11 in non-leap years and 0 to 12 in leap years. For Coptic and Ethiopian 0454 * calendar, the range is always 0 to 12. For other calendars supported by 0455 * ICU now, the range is 0 to 11. When the number of months in a year of the 0456 * identified calendar is variable, a different UCAL_ORDINAL_MONTH value can 0457 * be used for dates that are part of the same named month in different years. 0458 * For example, in the Hebrew calendar, "1 Nisan 5781" is associated with 0459 * UCAL_ORDINAL_MONTH value 6 while "1 Nisan 5782" is associated with 0460 * UCAL_ORDINAL_MONTH value 7 because 5782 is a leap year and Nisan follows 0461 * the insertion of Adar I. In Chinese calendar, "Year 4664 Month 6 Day 2" 0462 * is associated with UCAL_ORDINAL_MONTH value 5 while "Year 4665 Month 6 Day 2" 0463 * is associated with UCAL_ORDINAL_MONTH value 6 because 4665 is a leap year 0464 * and there is an extra "Leap Month 5" which associated with UCAL_ORDINAL_MONTH 0465 * value 5 before "Month 6" of year 4664. 0466 * 0467 * @draft ICU 73 0468 */ 0469 UCAL_ORDINAL_MONTH, 0470 #endif // U_HIDE_DRAFT_API 0471 0472 /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, 0473 * it is needed for layout of Calendar, DateFormat, and other objects */ 0474 #ifndef U_FORCE_HIDE_DEPRECATED_API 0475 /** 0476 * One more than the highest normal UCalendarDateFields value. 0477 * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. 0478 */ 0479 #ifdef U_HIDE_DRAFT_API 0480 // Must include all fields that will be in structs 0481 UCAL_FIELD_COUNT = UCAL_IS_LEAP_MONTH + 2, 0482 #else // U_HIDE_DRAFT_API (for UCAL_ORDINAL_MONTH) 0483 UCAL_FIELD_COUNT = UCAL_ORDINAL_MONTH + 1, 0484 #endif // U_HIDE_DRAFT_API (for UCAL_ORDINAL_MONTH) 0485 0486 #endif // U_FORCE_HIDE_DEPRECATED_API 0487 0488 /** 0489 * Field number indicating the 0490 * day of the month. This is a synonym for <code>UCAL_DATE</code>. 0491 * The first day of the month has value 1. 0492 * @see #UCAL_DATE 0493 * Synonym for UCAL_DATE 0494 * @stable ICU 2.8 0495 **/ 0496 UCAL_DAY_OF_MONTH=UCAL_DATE 0497 }; 0498 0499 /** @stable ICU 2.0 */ 0500 typedef enum UCalendarDateFields UCalendarDateFields; 0501 /** 0502 * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients 0503 * who create locale resources for the field of first-day-of-week should be aware of 0504 * this. For instance, in US locale, first-day-of-week is set to 1, i.e., UCAL_SUNDAY. 0505 */ 0506 /** Possible days of the week in a UCalendar 0507 * @stable ICU 2.0 0508 */ 0509 enum UCalendarDaysOfWeek { 0510 /** Sunday */ 0511 UCAL_SUNDAY = 1, 0512 /** Monday */ 0513 UCAL_MONDAY, 0514 /** Tuesday */ 0515 UCAL_TUESDAY, 0516 /** Wednesday */ 0517 UCAL_WEDNESDAY, 0518 /** Thursday */ 0519 UCAL_THURSDAY, 0520 /** Friday */ 0521 UCAL_FRIDAY, 0522 /** Saturday */ 0523 UCAL_SATURDAY 0524 }; 0525 0526 /** @stable ICU 2.0 */ 0527 typedef enum UCalendarDaysOfWeek UCalendarDaysOfWeek; 0528 0529 /** Possible months in a UCalendar. Note: Calendar month is 0-based. 0530 * @stable ICU 2.0 0531 */ 0532 enum UCalendarMonths { 0533 /** January */ 0534 UCAL_JANUARY, 0535 /** February */ 0536 UCAL_FEBRUARY, 0537 /** March */ 0538 UCAL_MARCH, 0539 /** April */ 0540 UCAL_APRIL, 0541 /** May */ 0542 UCAL_MAY, 0543 /** June */ 0544 UCAL_JUNE, 0545 /** July */ 0546 UCAL_JULY, 0547 /** August */ 0548 UCAL_AUGUST, 0549 /** September */ 0550 UCAL_SEPTEMBER, 0551 /** October */ 0552 UCAL_OCTOBER, 0553 /** November */ 0554 UCAL_NOVEMBER, 0555 /** December */ 0556 UCAL_DECEMBER, 0557 /** Value of the <code>UCAL_MONTH</code> field indicating the 0558 * thirteenth month of the year. Although the Gregorian calendar 0559 * does not use this value, lunar calendars do. 0560 */ 0561 UCAL_UNDECIMBER 0562 }; 0563 0564 /** @stable ICU 2.0 */ 0565 typedef enum UCalendarMonths UCalendarMonths; 0566 0567 /** Possible AM/PM values in a UCalendar 0568 * @stable ICU 2.0 0569 */ 0570 enum UCalendarAMPMs { 0571 /** AM */ 0572 UCAL_AM, 0573 /** PM */ 0574 UCAL_PM 0575 }; 0576 0577 /** @stable ICU 2.0 */ 0578 typedef enum UCalendarAMPMs UCalendarAMPMs; 0579 0580 /** 0581 * System time zone type constants used by filtering zones 0582 * in ucal_openTimeZoneIDEnumeration. 0583 * @see ucal_openTimeZoneIDEnumeration 0584 * @stable ICU 4.8 0585 */ 0586 enum USystemTimeZoneType { 0587 /** 0588 * Any system zones. 0589 * @stable ICU 4.8 0590 */ 0591 UCAL_ZONE_TYPE_ANY, 0592 /** 0593 * Canonical system zones. 0594 * @stable ICU 4.8 0595 */ 0596 UCAL_ZONE_TYPE_CANONICAL, 0597 /** 0598 * Canonical system zones associated with actual locations. 0599 * @stable ICU 4.8 0600 */ 0601 UCAL_ZONE_TYPE_CANONICAL_LOCATION 0602 }; 0603 0604 /** @stable ICU 4.8 */ 0605 typedef enum USystemTimeZoneType USystemTimeZoneType; 0606 0607 /** 0608 * Create an enumeration over system time zone IDs with the given 0609 * filter conditions. 0610 * @param zoneType The system time zone type. 0611 * @param region The ISO 3166 two-letter country code or UN M.49 0612 * three-digit area code. When NULL, no filtering 0613 * done by region. 0614 * @param rawOffset An offset from GMT in milliseconds, ignoring the 0615 * effect of daylight savings time, if any. When NULL, 0616 * no filtering done by zone offset. 0617 * @param ec A pointer to an UErrorCode to receive any errors 0618 * @return an enumeration object that the caller must dispose of 0619 * using enum_close(), or NULL upon failure. In case of failure, 0620 * *ec will indicate the error. 0621 * @stable ICU 4.8 0622 */ 0623 U_CAPI UEnumeration* U_EXPORT2 0624 ucal_openTimeZoneIDEnumeration(USystemTimeZoneType zoneType, const char* region, 0625 const int32_t* rawOffset, UErrorCode* ec); 0626 0627 /** 0628 * Create an enumeration over all time zones. 0629 * 0630 * @param ec input/output error code 0631 * 0632 * @return an enumeration object that the caller must dispose of using 0633 * uenum_close(), or NULL upon failure. In case of failure *ec will 0634 * indicate the error. 0635 * 0636 * @stable ICU 2.6 0637 */ 0638 U_CAPI UEnumeration* U_EXPORT2 0639 ucal_openTimeZones(UErrorCode* ec); 0640 0641 /** 0642 * Create an enumeration over all time zones associated with the given 0643 * country. Some zones are affiliated with no country (e.g., "UTC"); 0644 * these may also be retrieved, as a group. 0645 * 0646 * @param country the ISO 3166 two-letter country code, or NULL to 0647 * retrieve zones not affiliated with any country 0648 * 0649 * @param ec input/output error code 0650 * 0651 * @return an enumeration object that the caller must dispose of using 0652 * uenum_close(), or NULL upon failure. In case of failure *ec will 0653 * indicate the error. 0654 * 0655 * @stable ICU 2.6 0656 */ 0657 U_CAPI UEnumeration* U_EXPORT2 0658 ucal_openCountryTimeZones(const char* country, UErrorCode* ec); 0659 0660 /** 0661 * Return the default time zone. The default is determined initially 0662 * by querying the host operating system. If the host system detection 0663 * routines fail, or if they specify a TimeZone or TimeZone offset 0664 * which is not recognized, then the special TimeZone "Etc/Unknown" 0665 * is returned. 0666 * 0667 * The default may be changed with `ucal_setDefaultTimeZone()` or with 0668 * the C++ TimeZone API, `TimeZone::adoptDefault(TimeZone*)`. 0669 * 0670 * @param result A buffer to receive the result, or NULL 0671 * 0672 * @param resultCapacity The capacity of the result buffer 0673 * 0674 * @param ec input/output error code 0675 * 0676 * @return The result string length, not including the terminating 0677 * null 0678 * 0679 * @see #UCAL_UNKNOWN_ZONE_ID 0680 * 0681 * @stable ICU 2.6 0682 */ 0683 U_CAPI int32_t U_EXPORT2 0684 ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec); 0685 0686 /** 0687 * Set the default time zone. 0688 * 0689 * @param zoneID null-terminated time zone ID 0690 * 0691 * @param ec input/output error code 0692 * 0693 * @stable ICU 2.6 0694 */ 0695 U_CAPI void U_EXPORT2 0696 ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec); 0697 0698 /** 0699 * Return the current host time zone. The host time zone is detected from 0700 * the current host system configuration by querying the host operating 0701 * system. If the host system detection routines fail, or if they specify 0702 * a TimeZone or TimeZone offset which is not recognized, then the special 0703 * TimeZone "Etc/Unknown" is returned. 0704 * 0705 * Note that host time zone and the ICU default time zone can be different. 0706 * 0707 * The ICU default time zone does not change once initialized unless modified 0708 * by calling `ucal_setDefaultTimeZone()` or with the C++ TimeZone API, 0709 * `TimeZone::adoptDefault(TimeZone*)`. 0710 * 0711 * If the host operating system configuration has changed since ICU has 0712 * initialized then the returned value can be different than the ICU default 0713 * time zone, even if the default has not changed. 0714 * 0715 * <p>This function is not thread safe.</p> 0716 * 0717 * @param result A buffer to receive the result, or NULL 0718 * @param resultCapacity The capacity of the result buffer 0719 * @param ec input/output error code 0720 * @return The result string length, not including the terminating 0721 * null 0722 * 0723 * @see #UCAL_UNKNOWN_ZONE_ID 0724 * 0725 * @stable ICU 65 0726 */ 0727 U_CAPI int32_t U_EXPORT2 0728 ucal_getHostTimeZone(UChar *result, int32_t resultCapacity, UErrorCode *ec); 0729 0730 /** 0731 * Return the amount of time in milliseconds that the clock is 0732 * advanced during daylight savings time for the given time zone, or 0733 * zero if the time zone does not observe daylight savings time. 0734 * 0735 * @param zoneID null-terminated time zone ID 0736 * 0737 * @param ec input/output error code 0738 * 0739 * @return the number of milliseconds the time is advanced with 0740 * respect to standard time when the daylight savings rules are in 0741 * effect. This is always a non-negative number, most commonly either 0742 * 3,600,000 (one hour) or zero. 0743 * 0744 * @stable ICU 2.6 0745 */ 0746 U_CAPI int32_t U_EXPORT2 0747 ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec); 0748 0749 /** 0750 * Get the current date and time. 0751 * The value returned is represented as milliseconds from the epoch. 0752 * @return The current date and time. 0753 * @stable ICU 2.0 0754 */ 0755 U_CAPI UDate U_EXPORT2 0756 ucal_getNow(void); 0757 0758 /** 0759 * Open a UCalendar. 0760 * A UCalendar may be used to convert a millisecond value to a year, 0761 * month, and day. 0762 * <p> 0763 * Note: When unknown TimeZone ID is specified or if the TimeZone ID specified is "Etc/Unknown", 0764 * the UCalendar returned by the function is initialized with GMT zone with TimeZone ID 0765 * <code>UCAL_UNKNOWN_ZONE_ID</code> ("Etc/Unknown") without any errors/warnings. If you want 0766 * to check if a TimeZone ID is valid prior to this function, use <code>ucal_getCanonicalTimeZoneID</code>. 0767 * 0768 * @param zoneID The desired TimeZone ID. If 0, use the default time zone. 0769 * @param len The length of zoneID, or -1 if null-terminated. 0770 * @param locale The desired locale 0771 * @param type The type of UCalendar to open. This can be UCAL_GREGORIAN to open the Gregorian 0772 * calendar for the locale, or UCAL_DEFAULT to open the default calendar for the locale (the 0773 * default calendar may also be Gregorian). To open a specific non-Gregorian calendar for the 0774 * locale, use uloc_setKeywordValue to set the value of the calendar keyword for the locale 0775 * and then pass the locale to ucal_open with UCAL_DEFAULT as the type. 0776 * @param status A pointer to an UErrorCode to receive any errors 0777 * @return A pointer to a UCalendar, or 0 if an error occurred. 0778 * @see #UCAL_UNKNOWN_ZONE_ID 0779 * @stable ICU 2.0 0780 */ 0781 U_CAPI UCalendar* U_EXPORT2 0782 ucal_open(const UChar* zoneID, 0783 int32_t len, 0784 const char* locale, 0785 UCalendarType type, 0786 UErrorCode* status); 0787 0788 /** 0789 * Close a UCalendar. 0790 * Once closed, a UCalendar may no longer be used. 0791 * @param cal The UCalendar to close. 0792 * @stable ICU 2.0 0793 */ 0794 U_CAPI void U_EXPORT2 0795 ucal_close(UCalendar *cal); 0796 0797 #if U_SHOW_CPLUSPLUS_API 0798 0799 U_NAMESPACE_BEGIN 0800 0801 /** 0802 * \class LocalUCalendarPointer 0803 * "Smart pointer" class, closes a UCalendar via ucal_close(). 0804 * For most methods see the LocalPointerBase base class. 0805 * 0806 * @see LocalPointerBase 0807 * @see LocalPointer 0808 * @stable ICU 4.4 0809 */ 0810 U_DEFINE_LOCAL_OPEN_POINTER(LocalUCalendarPointer, UCalendar, ucal_close); 0811 0812 U_NAMESPACE_END 0813 0814 #endif 0815 0816 /** 0817 * Open a copy of a UCalendar. 0818 * This function performs a deep copy. 0819 * @param cal The calendar to copy 0820 * @param status A pointer to an UErrorCode to receive any errors. 0821 * @return A pointer to a UCalendar identical to cal. 0822 * @stable ICU 4.0 0823 */ 0824 U_CAPI UCalendar* U_EXPORT2 0825 ucal_clone(const UCalendar* cal, 0826 UErrorCode* status); 0827 0828 /** 0829 * Set the TimeZone used by a UCalendar. 0830 * A UCalendar uses a timezone for converting from Greenwich time to local time. 0831 * @param cal The UCalendar to set. 0832 * @param zoneID The desired TimeZone ID. If 0, use the default time zone. 0833 * @param len The length of zoneID, or -1 if null-terminated. 0834 * @param status A pointer to an UErrorCode to receive any errors. 0835 * @stable ICU 2.0 0836 */ 0837 U_CAPI void U_EXPORT2 0838 ucal_setTimeZone(UCalendar* cal, 0839 const UChar* zoneID, 0840 int32_t len, 0841 UErrorCode* status); 0842 0843 /** 0844 * Get the ID of the UCalendar's time zone. 0845 * 0846 * @param cal The UCalendar to query. 0847 * @param result Receives the UCalendar's time zone ID. 0848 * @param resultLength The maximum size of result. 0849 * @param status Receives the status. 0850 * @return The total buffer size needed; if greater than resultLength, the output was truncated. 0851 * @stable ICU 51 0852 */ 0853 U_CAPI int32_t U_EXPORT2 0854 ucal_getTimeZoneID(const UCalendar *cal, 0855 UChar *result, 0856 int32_t resultLength, 0857 UErrorCode *status); 0858 0859 /** 0860 * Possible formats for a UCalendar's display name 0861 * @stable ICU 2.0 0862 */ 0863 enum UCalendarDisplayNameType { 0864 /** Standard display name */ 0865 UCAL_STANDARD, 0866 /** Short standard display name */ 0867 UCAL_SHORT_STANDARD, 0868 /** Daylight savings display name */ 0869 UCAL_DST, 0870 /** Short daylight savings display name */ 0871 UCAL_SHORT_DST 0872 }; 0873 0874 /** @stable ICU 2.0 */ 0875 typedef enum UCalendarDisplayNameType UCalendarDisplayNameType; 0876 0877 /** 0878 * Get the display name for a UCalendar's TimeZone. 0879 * A display name is suitable for presentation to a user. 0880 * @param cal The UCalendar to query. 0881 * @param type The desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD, 0882 * UCAL_DST, UCAL_SHORT_DST 0883 * @param locale The desired locale for the display name. 0884 * @param result A pointer to a buffer to receive the formatted number. 0885 * @param resultLength The maximum size of result. 0886 * @param status A pointer to an UErrorCode to receive any errors 0887 * @return The total buffer size needed; if greater than resultLength, the output was truncated. 0888 * @stable ICU 2.0 0889 */ 0890 U_CAPI int32_t U_EXPORT2 0891 ucal_getTimeZoneDisplayName(const UCalendar* cal, 0892 UCalendarDisplayNameType type, 0893 const char* locale, 0894 UChar* result, 0895 int32_t resultLength, 0896 UErrorCode* status); 0897 0898 /** 0899 * Determine if a UCalendar is currently in daylight savings time. 0900 * Daylight savings time is not used in all parts of the world. 0901 * @param cal The UCalendar to query. 0902 * @param status A pointer to an UErrorCode to receive any errors 0903 * @return true if cal is currently in daylight savings time, false otherwise 0904 * @stable ICU 2.0 0905 */ 0906 U_CAPI UBool U_EXPORT2 0907 ucal_inDaylightTime(const UCalendar* cal, 0908 UErrorCode* status ); 0909 0910 /** 0911 * Sets the GregorianCalendar change date. This is the point when the switch from 0912 * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October 0913 * 15, 1582. Previous to this time and date will be Julian dates. 0914 * 0915 * This function works only for Gregorian calendars. If the UCalendar is not 0916 * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR 0917 * error code is set. 0918 * 0919 * @param cal The calendar object. 0920 * @param date The given Gregorian cutover date. 0921 * @param pErrorCode Pointer to a standard ICU error code. Its input value must 0922 * pass the U_SUCCESS() test, or else the function returns 0923 * immediately. Check for U_FAILURE() on output or use with 0924 * function chaining. (See User Guide for details.) 0925 * 0926 * @see GregorianCalendar::setGregorianChange 0927 * @see ucal_getGregorianChange 0928 * @stable ICU 3.6 0929 */ 0930 U_CAPI void U_EXPORT2 0931 ucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode); 0932 0933 /** 0934 * Gets the Gregorian Calendar change date. This is the point when the switch from 0935 * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October 0936 * 15, 1582. Previous to this time and date will be Julian dates. 0937 * 0938 * This function works only for Gregorian calendars. If the UCalendar is not 0939 * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR 0940 * error code is set. 0941 * 0942 * @param cal The calendar object. 0943 * @param pErrorCode Pointer to a standard ICU error code. Its input value must 0944 * pass the U_SUCCESS() test, or else the function returns 0945 * immediately. Check for U_FAILURE() on output or use with 0946 * function chaining. (See User Guide for details.) 0947 * @return The Gregorian cutover time for this calendar. 0948 * 0949 * @see GregorianCalendar::getGregorianChange 0950 * @see ucal_setGregorianChange 0951 * @stable ICU 3.6 0952 */ 0953 U_CAPI UDate U_EXPORT2 0954 ucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode); 0955 0956 /** 0957 * Types of UCalendar attributes 0958 * @stable ICU 2.0 0959 */ 0960 enum UCalendarAttribute { 0961 /** 0962 * Lenient parsing 0963 * @stable ICU 2.0 0964 */ 0965 UCAL_LENIENT, 0966 /** 0967 * First day of week 0968 * @stable ICU 2.0 0969 */ 0970 UCAL_FIRST_DAY_OF_WEEK, 0971 /** 0972 * Minimum number of days in first week 0973 * @stable ICU 2.0 0974 */ 0975 UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, 0976 /** 0977 * The behavior for handling wall time repeating multiple times 0978 * at negative time zone offset transitions 0979 * @stable ICU 49 0980 */ 0981 UCAL_REPEATED_WALL_TIME, 0982 /** 0983 * The behavior for handling skipped wall time at positive time 0984 * zone offset transitions. 0985 * @stable ICU 49 0986 */ 0987 UCAL_SKIPPED_WALL_TIME 0988 }; 0989 0990 /** @stable ICU 2.0 */ 0991 typedef enum UCalendarAttribute UCalendarAttribute; 0992 0993 /** 0994 * Options for handling ambiguous wall time at time zone 0995 * offset transitions. 0996 * @stable ICU 49 0997 */ 0998 enum UCalendarWallTimeOption { 0999 /** 1000 * An ambiguous wall time to be interpreted as the latest. 1001 * This option is valid for UCAL_REPEATED_WALL_TIME and 1002 * UCAL_SKIPPED_WALL_TIME. 1003 * @stable ICU 49 1004 */ 1005 UCAL_WALLTIME_LAST, 1006 /** 1007 * An ambiguous wall time to be interpreted as the earliest. 1008 * This option is valid for UCAL_REPEATED_WALL_TIME and 1009 * UCAL_SKIPPED_WALL_TIME. 1010 * @stable ICU 49 1011 */ 1012 UCAL_WALLTIME_FIRST, 1013 /** 1014 * An ambiguous wall time to be interpreted as the next valid 1015 * wall time. This option is valid for UCAL_SKIPPED_WALL_TIME. 1016 * @stable ICU 49 1017 */ 1018 UCAL_WALLTIME_NEXT_VALID 1019 }; 1020 /** @stable ICU 49 */ 1021 typedef enum UCalendarWallTimeOption UCalendarWallTimeOption; 1022 1023 /** 1024 * Get a numeric attribute associated with a UCalendar. 1025 * Numeric attributes include the first day of the week, or the minimal numbers 1026 * of days in the first week of the month. 1027 * @param cal The UCalendar to query. 1028 * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK, 1029 * UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, UCAL_REPEATED_WALL_TIME or UCAL_SKIPPED_WALL_TIME 1030 * @return The value of attr. 1031 * @see ucal_setAttribute 1032 * @stable ICU 2.0 1033 */ 1034 U_CAPI int32_t U_EXPORT2 1035 ucal_getAttribute(const UCalendar* cal, 1036 UCalendarAttribute attr); 1037 1038 /** 1039 * Set a numeric attribute associated with a UCalendar. 1040 * Numeric attributes include the first day of the week, or the minimal numbers 1041 * of days in the first week of the month. 1042 * @param cal The UCalendar to set. 1043 * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK, 1044 * UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, UCAL_REPEATED_WALL_TIME or UCAL_SKIPPED_WALL_TIME 1045 * @param newValue The new value of attr. 1046 * @see ucal_getAttribute 1047 * @stable ICU 2.0 1048 */ 1049 U_CAPI void U_EXPORT2 1050 ucal_setAttribute(UCalendar* cal, 1051 UCalendarAttribute attr, 1052 int32_t newValue); 1053 1054 /** 1055 * Get a locale for which calendars are available. 1056 * A UCalendar in a locale returned by this function will contain the correct 1057 * day and month names for the locale. 1058 * @param localeIndex The index of the desired locale. 1059 * @return A locale for which calendars are available, or 0 if none. 1060 * @see ucal_countAvailable 1061 * @stable ICU 2.0 1062 */ 1063 U_CAPI const char* U_EXPORT2 1064 ucal_getAvailable(int32_t localeIndex); 1065 1066 /** 1067 * Determine how many locales have calendars available. 1068 * This function is most useful as determining the loop ending condition for 1069 * calls to \ref ucal_getAvailable. 1070 * @return The number of locales for which calendars are available. 1071 * @see ucal_getAvailable 1072 * @stable ICU 2.0 1073 */ 1074 U_CAPI int32_t U_EXPORT2 1075 ucal_countAvailable(void); 1076 1077 /** 1078 * Get a UCalendar's current time in millis. 1079 * The time is represented as milliseconds from the epoch. 1080 * @param cal The UCalendar to query. 1081 * @param status A pointer to an UErrorCode to receive any errors 1082 * @return The calendar's current time in millis. 1083 * @see ucal_setMillis 1084 * @see ucal_setDate 1085 * @see ucal_setDateTime 1086 * @stable ICU 2.0 1087 */ 1088 U_CAPI UDate U_EXPORT2 1089 ucal_getMillis(const UCalendar* cal, 1090 UErrorCode* status); 1091 1092 /** 1093 * Set a UCalendar's current time in millis. 1094 * The time is represented as milliseconds from the epoch. 1095 * @param cal The UCalendar to set. 1096 * @param dateTime The desired date and time. 1097 * @param status A pointer to an UErrorCode to receive any errors 1098 * @see ucal_getMillis 1099 * @see ucal_setDate 1100 * @see ucal_setDateTime 1101 * @stable ICU 2.0 1102 */ 1103 U_CAPI void U_EXPORT2 1104 ucal_setMillis(UCalendar* cal, 1105 UDate dateTime, 1106 UErrorCode* status ); 1107 1108 /** 1109 * Set a UCalendar's current date. 1110 * The date is represented as a series of 32-bit integers. 1111 * @param cal The UCalendar to set. 1112 * @param year The desired year. 1113 * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY, 1114 * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER 1115 * @param date The desired day of the month. 1116 * @param status A pointer to an UErrorCode to receive any errors 1117 * @see ucal_getMillis 1118 * @see ucal_setMillis 1119 * @see ucal_setDateTime 1120 * @stable ICU 2.0 1121 */ 1122 U_CAPI void U_EXPORT2 1123 ucal_setDate(UCalendar* cal, 1124 int32_t year, 1125 int32_t month, 1126 int32_t date, 1127 UErrorCode* status); 1128 1129 /** 1130 * Set a UCalendar's current date. 1131 * The date is represented as a series of 32-bit integers. 1132 * @param cal The UCalendar to set. 1133 * @param year The desired year. 1134 * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY, 1135 * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER 1136 * @param date The desired day of the month. 1137 * @param hour The desired hour of day. 1138 * @param minute The desired minute. 1139 * @param second The desirec second. 1140 * @param status A pointer to an UErrorCode to receive any errors 1141 * @see ucal_getMillis 1142 * @see ucal_setMillis 1143 * @see ucal_setDate 1144 * @stable ICU 2.0 1145 */ 1146 U_CAPI void U_EXPORT2 1147 ucal_setDateTime(UCalendar* cal, 1148 int32_t year, 1149 int32_t month, 1150 int32_t date, 1151 int32_t hour, 1152 int32_t minute, 1153 int32_t second, 1154 UErrorCode* status); 1155 1156 /** 1157 * Returns true if two UCalendars are equivalent. Equivalent 1158 * UCalendars will behave identically, but they may be set to 1159 * different times. 1160 * @param cal1 The first of the UCalendars to compare. 1161 * @param cal2 The second of the UCalendars to compare. 1162 * @return true if cal1 and cal2 are equivalent, false otherwise. 1163 * @stable ICU 2.0 1164 */ 1165 U_CAPI UBool U_EXPORT2 1166 ucal_equivalentTo(const UCalendar* cal1, 1167 const UCalendar* cal2); 1168 1169 /** 1170 * Add a specified signed amount to a particular field in a UCalendar. 1171 * This can modify more significant fields in the calendar. 1172 * Adding a positive value always means moving forward in time, so for the Gregorian calendar, 1173 * starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces 1174 * the numeric value of the field itself). 1175 * @param cal The UCalendar to which to add. 1176 * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1177 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1178 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1179 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1180 * @param amount The signed amount to add to field. If the amount causes the value 1181 * to exceed to maximum or minimum values for that field, other fields are modified 1182 * to preserve the magnitude of the change. 1183 * @param status A pointer to an UErrorCode to receive any errors 1184 * @see ucal_roll 1185 * @stable ICU 2.0 1186 */ 1187 U_CAPI void U_EXPORT2 1188 ucal_add(UCalendar* cal, 1189 UCalendarDateFields field, 1190 int32_t amount, 1191 UErrorCode* status); 1192 1193 /** 1194 * Add a specified signed amount to a particular field in a UCalendar. 1195 * This will not modify more significant fields in the calendar. 1196 * Rolling by a positive value always means moving forward in time (unless the limit of the 1197 * field is reached, in which case it may pin or wrap), so for Gregorian calendar, 1198 * starting with 100 BC and rolling the year by +1 results in 99 BC. 1199 * When eras have a definite beginning and end (as in the Chinese calendar, or as in most eras in the 1200 * Japanese calendar) then rolling the year past either limit of the era will cause the year to wrap around. 1201 * When eras only have a limit at one end, then attempting to roll the year past that limit will result in 1202 * pinning the year at that limit. Note that for most calendars in which era 0 years move forward in time 1203 * (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to result in negative years for 1204 * era 0 (that is the only way to represent years before the calendar epoch). 1205 * @param cal The UCalendar to which to add. 1206 * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1207 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1208 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1209 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1210 * @param amount The signed amount to add to field. If the amount causes the value 1211 * to exceed to maximum or minimum values for that field, the field is pinned to a permissible 1212 * value. 1213 * @param status A pointer to an UErrorCode to receive any errors 1214 * @see ucal_add 1215 * @stable ICU 2.0 1216 */ 1217 U_CAPI void U_EXPORT2 1218 ucal_roll(UCalendar* cal, 1219 UCalendarDateFields field, 1220 int32_t amount, 1221 UErrorCode* status); 1222 1223 /** 1224 * Get the current value of a field from a UCalendar. 1225 * All fields are represented as 32-bit integers. 1226 * @param cal The UCalendar to query. 1227 * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1228 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1229 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1230 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1231 * @param status A pointer to an UErrorCode to receive any errors 1232 * @return The value of the desired field. 1233 * @see ucal_set 1234 * @see ucal_isSet 1235 * @see ucal_clearField 1236 * @see ucal_clear 1237 * @stable ICU 2.0 1238 */ 1239 U_CAPI int32_t U_EXPORT2 1240 ucal_get(const UCalendar* cal, 1241 UCalendarDateFields field, 1242 UErrorCode* status ); 1243 1244 /** 1245 * Set the value of a field in a UCalendar. 1246 * All fields are represented as 32-bit integers. 1247 * @param cal The UCalendar to set. 1248 * @param field The field to set; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1249 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1250 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1251 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1252 * @param value The desired value of field. 1253 * @see ucal_get 1254 * @see ucal_isSet 1255 * @see ucal_clearField 1256 * @see ucal_clear 1257 * @stable ICU 2.0 1258 */ 1259 U_CAPI void U_EXPORT2 1260 ucal_set(UCalendar* cal, 1261 UCalendarDateFields field, 1262 int32_t value); 1263 1264 /** 1265 * Determine if a field in a UCalendar is set. 1266 * All fields are represented as 32-bit integers. 1267 * @param cal The UCalendar to query. 1268 * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1269 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1270 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1271 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1272 * @return true if field is set, false otherwise. 1273 * @see ucal_get 1274 * @see ucal_set 1275 * @see ucal_clearField 1276 * @see ucal_clear 1277 * @stable ICU 2.0 1278 */ 1279 U_CAPI UBool U_EXPORT2 1280 ucal_isSet(const UCalendar* cal, 1281 UCalendarDateFields field); 1282 1283 /** 1284 * Clear a field in a UCalendar. 1285 * All fields are represented as 32-bit integers. 1286 * @param cal The UCalendar containing the field to clear. 1287 * @param field The field to clear; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1288 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1289 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1290 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1291 * @see ucal_get 1292 * @see ucal_set 1293 * @see ucal_isSet 1294 * @see ucal_clear 1295 * @stable ICU 2.0 1296 */ 1297 U_CAPI void U_EXPORT2 1298 ucal_clearField(UCalendar* cal, 1299 UCalendarDateFields field); 1300 1301 /** 1302 * Clear all fields in a UCalendar. 1303 * All fields are represented as 32-bit integers. 1304 * @param calendar The UCalendar to clear. 1305 * @see ucal_get 1306 * @see ucal_set 1307 * @see ucal_isSet 1308 * @see ucal_clearField 1309 * @stable ICU 2.0 1310 */ 1311 U_CAPI void U_EXPORT2 1312 ucal_clear(UCalendar* calendar); 1313 1314 /** 1315 * Possible limit values for a UCalendar 1316 * @stable ICU 2.0 1317 */ 1318 enum UCalendarLimitType { 1319 /** Minimum value */ 1320 UCAL_MINIMUM, 1321 /** Maximum value */ 1322 UCAL_MAXIMUM, 1323 /** Greatest minimum value */ 1324 UCAL_GREATEST_MINIMUM, 1325 /** Least maximum value */ 1326 UCAL_LEAST_MAXIMUM, 1327 /** Actual minimum value */ 1328 UCAL_ACTUAL_MINIMUM, 1329 /** Actual maximum value */ 1330 UCAL_ACTUAL_MAXIMUM 1331 }; 1332 1333 /** @stable ICU 2.0 */ 1334 typedef enum UCalendarLimitType UCalendarLimitType; 1335 1336 /** 1337 * Determine a limit for a field in a UCalendar. 1338 * A limit is a maximum or minimum value for a field. 1339 * @param cal The UCalendar to query. 1340 * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1341 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1342 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1343 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1344 * @param type The desired critical point; one of UCAL_MINIMUM, UCAL_MAXIMUM, UCAL_GREATEST_MINIMUM, 1345 * UCAL_LEAST_MAXIMUM, UCAL_ACTUAL_MINIMUM, UCAL_ACTUAL_MAXIMUM 1346 * @param status A pointer to an UErrorCode to receive any errors. 1347 * @return The requested value. 1348 * @stable ICU 2.0 1349 */ 1350 U_CAPI int32_t U_EXPORT2 1351 ucal_getLimit(const UCalendar* cal, 1352 UCalendarDateFields field, 1353 UCalendarLimitType type, 1354 UErrorCode* status); 1355 1356 /** Get the locale for this calendar object. You can choose between valid and actual locale. 1357 * @param cal The calendar object 1358 * @param type type of the locale we're looking for (valid or actual) 1359 * @param status error code for the operation 1360 * @return the locale name 1361 * @stable ICU 2.8 1362 */ 1363 U_CAPI const char * U_EXPORT2 1364 ucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode* status); 1365 1366 /** 1367 * Returns the timezone data version currently used by ICU. 1368 * @param status error code for the operation 1369 * @return the version string, such as "2007f" 1370 * @stable ICU 3.8 1371 */ 1372 U_CAPI const char * U_EXPORT2 1373 ucal_getTZDataVersion(UErrorCode* status); 1374 1375 /** 1376 * Returns the canonical system timezone ID or the normalized 1377 * custom time zone ID for the given time zone ID. 1378 * @param id The input timezone ID to be canonicalized. 1379 * @param len The length of id, or -1 if null-terminated. 1380 * @param result The buffer receives the canonical system timezone ID 1381 * or the custom timezone ID in normalized format. 1382 * @param resultCapacity The capacity of the result buffer. 1383 * @param isSystemID Receives if the given ID is a known system 1384 * timezone ID. 1385 * @param status Receives the status. When the given timezone ID 1386 * is neither a known system time zone ID nor a 1387 * valid custom timezone ID, U_ILLEGAL_ARGUMENT_ERROR 1388 * is set. 1389 * @return The result string length, not including the terminating 1390 * null. 1391 * @stable ICU 4.0 1392 */ 1393 U_CAPI int32_t U_EXPORT2 1394 ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len, 1395 UChar* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status); 1396 1397 #ifndef U_HIDE_DRAFT_API 1398 /** 1399 * Returns the preferred time zone ID in the IANA time zone database for the given time zone ID. 1400 * There are two types of preferred IDs. The first type is the one defined in zone.tab file, 1401 * such as "America/Los_Angeles". The second types is the one defined for zones not associated 1402 * with a specific region, but not defined with "Link" syntax such as "Etc/GMT+10". 1403 * 1404 * <p>Note: For most of valid time zone IDs, this method returns an ID same as ucal_getCanonicalTimeZoneID(). 1405 * ucal_getCanonicalTimeZoneID() is based on canonical time zone IDs defined in Unicode CLDR. 1406 * These canonical time zone IDs in CLDR were based on very old version of the time zone database. 1407 * In the IANA time zone database, some IDs were updated since then. This API returns a newer 1408 * time zone ID. For example, CLDR defines "Asia/Calcutta" as the canonical time zone ID. This 1409 * method returns "Asia/Kolkata" instead. 1410 * <p> "Etc/Unknown" is a special time zone ID defined by CLDR. There are no corresponding zones 1411 * in the IANA time zone database. Therefore, this API returns U_ILLEGAL_ARGUMENT_ERROR when the 1412 * input ID is "Etc/Unknown". 1413 * 1414 * @param id The input time zone ID. 1415 * @param len The length of the input time zone ID. 1416 * @param result The buffer receives the preferred time zone ID in the IANA time zone database. 1417 * @param resultCapacity The capacity of the result buffer. 1418 * @param status Receives the status. When the given time zone ID is not a known system time zone 1419 * ID, U_ILLEGAL_ARGUMENT_ERROR is set. 1420 * @return The result string length, not including the terminating null. 1421 * @draft ICU 74 1422 */ 1423 U_CAPI int32_t U_EXPORT2 1424 ucal_getIanaTimeZoneID(const UChar* id, int32_t len, 1425 UChar* result, int32_t resultCapacity, UErrorCode* status); 1426 #endif // U_HIDE_DRAFT_API 1427 1428 /** 1429 * Get the resource keyword value string designating the calendar type for the UCalendar. 1430 * @param cal The UCalendar to query. 1431 * @param status The error code for the operation. 1432 * @return The resource keyword value string. 1433 * @stable ICU 4.2 1434 */ 1435 U_CAPI const char * U_EXPORT2 1436 ucal_getType(const UCalendar *cal, UErrorCode* status); 1437 1438 /** 1439 * Given a key and a locale, returns an array of string values in a preferred 1440 * order that would make a difference. These are all and only those values where 1441 * the open (creation) of the service with the locale formed from the input locale 1442 * plus input keyword and that value has different behavior than creation with the 1443 * input locale alone. 1444 * @param key one of the keys supported by this service. For now, only 1445 * "calendar" is supported. 1446 * @param locale the locale 1447 * @param commonlyUsed if set to true it will return only commonly used values 1448 * with the given locale in preferred order. Otherwise, 1449 * it will return all the available values for the locale. 1450 * @param status error status 1451 * @return a string enumeration over keyword values for the given key and the locale. 1452 * @stable ICU 4.2 1453 */ 1454 U_CAPI UEnumeration* U_EXPORT2 1455 ucal_getKeywordValuesForLocale(const char* key, 1456 const char* locale, 1457 UBool commonlyUsed, 1458 UErrorCode* status); 1459 1460 1461 /** Weekday types, as returned by ucal_getDayOfWeekType(). 1462 * @stable ICU 4.4 1463 */ 1464 enum UCalendarWeekdayType { 1465 /** 1466 * Designates a full weekday (no part of the day is included in the weekend). 1467 * @stable ICU 4.4 1468 */ 1469 UCAL_WEEKDAY, 1470 /** 1471 * Designates a full weekend day (the entire day is included in the weekend). 1472 * @stable ICU 4.4 1473 */ 1474 UCAL_WEEKEND, 1475 /** 1476 * Designates a day that starts as a weekday and transitions to the weekend. 1477 * Call ucal_getWeekendTransition() to get the time of transition. 1478 * @stable ICU 4.4 1479 */ 1480 UCAL_WEEKEND_ONSET, 1481 /** 1482 * Designates a day that starts as the weekend and transitions to a weekday. 1483 * Call ucal_getWeekendTransition() to get the time of transition. 1484 * @stable ICU 4.4 1485 */ 1486 UCAL_WEEKEND_CEASE 1487 }; 1488 1489 /** @stable ICU 4.4 */ 1490 typedef enum UCalendarWeekdayType UCalendarWeekdayType; 1491 1492 /** 1493 * Returns whether the given day of the week is a weekday, a weekend day, 1494 * or a day that transitions from one to the other, for the locale and 1495 * calendar system associated with this UCalendar (the locale's region is 1496 * often the most determinant factor). If a transition occurs at midnight, 1497 * then the days before and after the transition will have the 1498 * type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time 1499 * other than midnight, then the day of the transition will have 1500 * the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the 1501 * function ucal_getWeekendTransition() will return the point of 1502 * transition. 1503 * @param cal The UCalendar to query. 1504 * @param dayOfWeek The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY). 1505 * @param status The error code for the operation. 1506 * @return The UCalendarWeekdayType for the day of the week. 1507 * @stable ICU 4.4 1508 */ 1509 U_CAPI UCalendarWeekdayType U_EXPORT2 1510 ucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode* status); 1511 1512 /** 1513 * Returns the time during the day at which the weekend begins or ends in 1514 * this calendar system. If ucal_getDayOfWeekType() returns UCAL_WEEKEND_ONSET 1515 * for the specified dayOfWeek, return the time at which the weekend begins. 1516 * If ucal_getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek, 1517 * return the time at which the weekend ends. If ucal_getDayOfWeekType() returns 1518 * some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition 1519 * (U_ILLEGAL_ARGUMENT_ERROR). 1520 * @param cal The UCalendar to query. 1521 * @param dayOfWeek The day of the week for which the weekend transition time is 1522 * desired (UCAL_SUNDAY..UCAL_SATURDAY). 1523 * @param status The error code for the operation. 1524 * @return The milliseconds after midnight at which the weekend begins or ends. 1525 * @stable ICU 4.4 1526 */ 1527 U_CAPI int32_t U_EXPORT2 1528 ucal_getWeekendTransition(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode *status); 1529 1530 /** 1531 * Returns true if the given UDate is in the weekend in 1532 * this calendar system. 1533 * @param cal The UCalendar to query. 1534 * @param date The UDate in question. 1535 * @param status The error code for the operation. 1536 * @return true if the given UDate is in the weekend in 1537 * this calendar system, false otherwise. 1538 * @stable ICU 4.4 1539 */ 1540 U_CAPI UBool U_EXPORT2 1541 ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status); 1542 1543 /** 1544 * Return the difference between the target time and the time this calendar object is currently set to. 1545 * If the target time is after the current calendar setting, the the returned value will be positive. 1546 * The field parameter specifies the units of the return value. For example, if field is UCAL_MONTH 1547 * and ucal_getFieldDifference returns 3, then the target time is 3 to less than 4 months after the 1548 * current calendar setting. 1549 * 1550 * As a side effect of this call, this calendar is advanced toward target by the given amount. That is, 1551 * calling this function has the side effect of calling ucal_add on this calendar with the specified 1552 * field and an amount equal to the return value from this function. 1553 * 1554 * A typical way of using this function is to call it first with the largest field of interest, then 1555 * with progressively smaller fields. 1556 * 1557 * @param cal The UCalendar to compare and update. 1558 * @param target The target date to compare to the current calendar setting. 1559 * @param field The field to compare; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1560 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1561 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1562 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1563 * @param status A pointer to an UErrorCode to receive any errors 1564 * @return The date difference for the specified field. 1565 * @stable ICU 4.8 1566 */ 1567 U_CAPI int32_t U_EXPORT2 1568 ucal_getFieldDifference(UCalendar* cal, 1569 UDate target, 1570 UCalendarDateFields field, 1571 UErrorCode* status); 1572 1573 /** 1574 * Time zone transition types for ucal_getTimeZoneTransitionDate 1575 * @stable ICU 50 1576 */ 1577 enum UTimeZoneTransitionType { 1578 /** 1579 * Get the next transition after the current date, 1580 * i.e. excludes the current date 1581 * @stable ICU 50 1582 */ 1583 UCAL_TZ_TRANSITION_NEXT, 1584 /** 1585 * Get the next transition on or after the current date, 1586 * i.e. may include the current date 1587 * @stable ICU 50 1588 */ 1589 UCAL_TZ_TRANSITION_NEXT_INCLUSIVE, 1590 /** 1591 * Get the previous transition before the current date, 1592 * i.e. excludes the current date 1593 * @stable ICU 50 1594 */ 1595 UCAL_TZ_TRANSITION_PREVIOUS, 1596 /** 1597 * Get the previous transition on or before the current date, 1598 * i.e. may include the current date 1599 * @stable ICU 50 1600 */ 1601 UCAL_TZ_TRANSITION_PREVIOUS_INCLUSIVE 1602 }; 1603 1604 typedef enum UTimeZoneTransitionType UTimeZoneTransitionType; /**< @stable ICU 50 */ 1605 1606 /** 1607 * Get the UDate for the next/previous time zone transition relative to 1608 * the calendar's current date, in the time zone to which the calendar 1609 * is currently set. If there is no known time zone transition of the 1610 * requested type relative to the calendar's date, the function returns 1611 * false. 1612 * @param cal The UCalendar to query. 1613 * @param type The type of transition desired. 1614 * @param transition A pointer to a UDate to be set to the transition time. 1615 * If the function returns false, the value set is unspecified. 1616 * @param status A pointer to a UErrorCode to receive any errors. 1617 * @return true if a valid transition time is set in *transition, false 1618 * otherwise. 1619 * @stable ICU 50 1620 */ 1621 U_CAPI UBool U_EXPORT2 1622 ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType type, 1623 UDate* transition, UErrorCode* status); 1624 1625 /** 1626 * Converts a system time zone ID to an equivalent Windows time zone ID. For example, 1627 * Windows time zone ID "Pacific Standard Time" is returned for input "America/Los_Angeles". 1628 * 1629 * <p>There are system time zones that cannot be mapped to Windows zones. When the input 1630 * system time zone ID is unknown or unmappable to a Windows time zone, then this 1631 * function returns 0 as the result length, but the operation itself remains successful 1632 * (no error status set on return). 1633 * 1634 * <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html"> 1635 * Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes, 1636 * please read the ICU user guide section <a href="https://unicode-org.github.io/icu/userguide/datetime/timezone#updating-the-time-zone-data"> 1637 * Updating the Time Zone Data</a>. 1638 * 1639 * @param id A system time zone ID. 1640 * @param len The length of <code>id</code>, or -1 if null-terminated. 1641 * @param winid A buffer to receive a Windows time zone ID. 1642 * @param winidCapacity The capacity of the result buffer <code>winid</code>. 1643 * @param status Receives the status. 1644 * @return The result string length, not including the terminating null. 1645 * @see ucal_getTimeZoneIDForWindowsID 1646 * 1647 * @stable ICU 52 1648 */ 1649 U_CAPI int32_t U_EXPORT2 1650 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len, 1651 UChar* winid, int32_t winidCapacity, UErrorCode* status); 1652 1653 /** 1654 * Converts a Windows time zone ID to an equivalent system time zone ID 1655 * for a region. For example, system time zone ID "America/Los_Angeles" is returned 1656 * for input Windows ID "Pacific Standard Time" and region "US" (or <code>null</code>), 1657 * "America/Vancouver" is returned for the same Windows ID "Pacific Standard Time" and 1658 * region "CA". 1659 * 1660 * <p>Not all Windows time zones can be mapped to system time zones. When the input 1661 * Windows time zone ID is unknown or unmappable to a system time zone, then this 1662 * function returns 0 as the result length, but the operation itself remains successful 1663 * (no error status set on return). 1664 * 1665 * <p>This implementation utilizes <a href="http://unicode.org/cldr/charts/supplemental/zone_tzid.html"> 1666 * Zone-Tzid mapping data</a>. The mapping data is updated time to time. To get the latest changes, 1667 * please read the ICU user guide section <a href="https://unicode-org.github.io/icu/userguide/datetime/timezone#updating-the-time-zone-data"> 1668 * Updating the Time Zone Data</a>. 1669 * 1670 * @param winid A Windows time zone ID. 1671 * @param len The length of <code>winid</code>, or -1 if null-terminated. 1672 * @param region A null-terminated region code, or <code>NULL</code> if no regional preference. 1673 * @param id A buffer to receive a system time zone ID. 1674 * @param idCapacity The capacity of the result buffer <code>id</code>. 1675 * @param status Receives the status. 1676 * @return The result string length, not including the terminating null. 1677 * @see ucal_getWindowsTimeZoneID 1678 * 1679 * @stable ICU 52 1680 */ 1681 U_CAPI int32_t U_EXPORT2 1682 ucal_getTimeZoneIDForWindowsID(const UChar* winid, int32_t len, const char* region, 1683 UChar* id, int32_t idCapacity, UErrorCode* status); 1684 1685 /** 1686 * Options used by ucal_getTimeZoneOffsetFromLocal and BasicTimeZone::getOffsetFromLocal() 1687 * to specify how to interpret an input time when it does not exist, or when it is ambiguous, 1688 * around a time zone transition. 1689 * @stable ICU 69 1690 */ 1691 enum UTimeZoneLocalOption { 1692 /** 1693 * An input time is always interpreted as local time before 1694 * a time zone transition. 1695 * @stable ICU 69 1696 */ 1697 UCAL_TZ_LOCAL_FORMER = 0x04, 1698 /** 1699 * An input time is always interpreted as local time after 1700 * a time zone transition. 1701 * @stable ICU 69 1702 */ 1703 UCAL_TZ_LOCAL_LATTER = 0x0C, 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 before the 1709 * transition is used. 1710 * @stable ICU 69 1711 */ 1712 UCAL_TZ_LOCAL_STANDARD_FORMER = UCAL_TZ_LOCAL_FORMER | 0x01, 1713 /** 1714 * An input time is interpreted as standard time when local 1715 * time is switched to/from daylight saving time. When both 1716 * sides of a time zone transition are standard time, 1717 * or daylight saving time, the local time after the 1718 * transition is used. 1719 * @stable ICU 69 1720 */ 1721 UCAL_TZ_LOCAL_STANDARD_LATTER = UCAL_TZ_LOCAL_LATTER | 0x01, 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 before the 1727 * transition is used. 1728 * @stable ICU 69 1729 */ 1730 UCAL_TZ_LOCAL_DAYLIGHT_FORMER = UCAL_TZ_LOCAL_FORMER | 0x03, 1731 /** 1732 * An input time is interpreted as daylight saving time when 1733 * local time is switched to/from standard time. When both 1734 * sides of a time zone transition are standard time, 1735 * or daylight saving time, the local time after the 1736 * transition is used. 1737 * @stable ICU 69 1738 */ 1739 UCAL_TZ_LOCAL_DAYLIGHT_LATTER = UCAL_TZ_LOCAL_LATTER | 0x03, 1740 }; 1741 typedef enum UTimeZoneLocalOption UTimeZoneLocalOption; /**< @stable ICU 69 */ 1742 1743 /** 1744 * Returns the time zone raw and GMT offset for the given moment 1745 * in time. Upon return, local-millis = GMT-millis + rawOffset + 1746 * dstOffset. All computations are performed in the proleptic 1747 * Gregorian calendar. 1748 * 1749 * @param cal The UCalendar which specify the local date and time value to query. 1750 * @param nonExistingTimeOpt The option to indicate how to interpret the date and 1751 * time in the calendar represent a local time that skipped at a positive time 1752 * zone transitions (e.g. when the daylight saving time starts or the time zone 1753 * offset is increased due to a time zone rule change). 1754 * @param duplicatedTimeOpt The option to indicate how to interpret the date and 1755 * time in the calendar represent a local time that repeating multiple times at a 1756 * negative time zone transition (e.g. when the daylight saving time ends or the 1757 * time zone offset is decreased due to a time zone rule change) 1758 * @param rawOffset output parameter to receive the raw offset, that 1759 * is, the offset not including DST adjustments. 1760 * If the status is set to one of the error code, the value set is unspecified. 1761 * @param dstOffset output parameter to receive the DST offset, 1762 * that is, the offset to be added to `rawOffset' to obtain the 1763 * total offset between local and GMT time. If DST is not in 1764 * effect, this value is zero; otherwise it is a positive value, 1765 * typically one hour. 1766 * If the status is set to one of the error code, the value set is unspecified. 1767 * @param status A pointer to a UErrorCode to receive any errors. 1768 * @stable ICU 69 1769 */ 1770 U_CAPI void U_EXPORT2 1771 ucal_getTimeZoneOffsetFromLocal( 1772 const UCalendar* cal, 1773 UTimeZoneLocalOption nonExistingTimeOpt, 1774 UTimeZoneLocalOption duplicatedTimeOpt, 1775 int32_t* rawOffset, int32_t* dstOffset, UErrorCode* status); 1776 1777 #endif /* #if !UCONFIG_NO_FORMATTING */ 1778 1779 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |