intl/icu/source/i18n/unicode/ucal.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial