ucal.h 57 KB

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