2 * Copyright (C) 1996-2004, International Business Machines Corporation and others. All Rights Reserved.
3 *******************************************************************************
9 #include "unicode/utypes.h"
10 #include "unicode/uenum.h"
11 #include "unicode/uloc.h"
13 #if !UCONFIG_NO_FORMATTING
17 * \brief C API: Calendar
19 * <h2>Calendar C API</h2>
21 * UCalendar C API is used for converting between a <code>UDate</code> object
22 * and a set of integer fields such as <code>UCAL_YEAR</code>, <code>UCAL_MONTH</code>,
23 * <code>UCAL_DAY</code>, <code>UCAL_HOUR</code>, and so on.
24 * (A <code>UDate</code> object represents a specific instant in
25 * time with millisecond precision. See UDate
26 * for information about the <code>UDate</code> .)
29 * Types of <code>UCalendar</code> interpret a <code>UDate</code>
30 * according to the rules of a specific calendar system. The U_STABLE
31 * provides the enum UCalendarType with UCAL_TRADITIONAL and
34 * Like other locale-sensitive C API, calendar API provides a
35 * function, <code>ucal_open()</code>, which returns a pointer to
36 * <code>UCalendar</code> whose time fields have been initialized
37 * with the current date and time. We need to specify the type of
38 * calendar to be opened and the timezoneId.
39 * \htmlonly<blockquote>\endhtmlonly
45 * tzId=(UChar*)malloc(sizeof(UChar) * (strlen("PST") +1) );
46 * u_uastrcpy(tzId, "PST");
47 * caldef=ucal_open(tzID, u_strlen(tzID), NULL, UCAL_TRADITIONAL, &status);
50 * \htmlonly</blockquote>\endhtmlonly
53 * A <code>UCalendar</code> object can produce all the time field values
54 * needed to implement the date-time formatting for a particular language
55 * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
58 * When computing a <code>UDate</code> from time fields, two special circumstances
59 * may arise: there may be insufficient information to compute the
60 * <code>UDate</code> (such as only year and month but no day in the month),
61 * or there may be inconsistent information (such as "Tuesday, July 15, 1996"
62 * -- July 15, 1996 is actually a Monday).
65 * <strong>Insufficient information.</strong> The calendar will use default
66 * information to specify the missing fields. This may vary by calendar; for
67 * the Gregorian calendar, the default for a field is the same as that of the
68 * start of the epoch: i.e., UCAL_YEAR = 1970, UCAL_MONTH = JANUARY, UCAL_DATE = 1, etc.
71 * <strong>Inconsistent information.</strong> If fields conflict, the calendar
72 * will give preference to fields set more recently. For example, when
73 * determining the day, the calendar will look for one of the following
74 * combinations of fields. The most recent combination, as determined by the
75 * most recently set single field, will be used.
77 * \htmlonly<blockquote>\endhtmlonly
80 * UCAL_MONTH + UCAL_DAY_OF_MONTH
81 * UCAL_MONTH + UCAL_WEEK_OF_MONTH + UCAL_DAY_OF_WEEK
82 * UCAL_MONTH + UCAL_DAY_OF_WEEK_IN_MONTH + UCAL_DAY_OF_WEEK
84 * UCAL_DAY_OF_WEEK + UCAL_WEEK_OF_YEAR
87 * \htmlonly</blockquote>\endhtmlonly
89 * For the time of day:
91 * \htmlonly<blockquote>\endhtmlonly
95 * UCAL_AM_PM + UCAL_HOUR
98 * \htmlonly</blockquote>\endhtmlonly
101 * <strong>Note:</strong> for some non-Gregorian calendars, different
102 * fields may be necessary for complete disambiguation. For example, a full
103 * specification of the historial Arabic astronomical calendar requires year,
104 * month, day-of-month <em>and</em> day-of-week in some cases.
107 * <strong>Note:</strong> There are certain possible ambiguities in
108 * interpretation of certain singular times, which are resolved in the
111 * <li> 24:00:00 "belongs" to the following day. That is,
112 * 23:59 on Dec 31, 1969 < 24:00 on Jan 1, 1970 < 24:01:00 on Jan 1, 1970
114 * <li> Although historically not precise, midnight also belongs to "am",
115 * and noon belongs to "pm", so on the same day,
116 * 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm
120 * The date or time format strings are not part of the definition of a
121 * calendar, as those must be modifiable or overridable by the user at
122 * runtime. Use {@link DateFormat}
126 * <code>Calendar</code> provides an API for field "rolling", where fields
127 * can be incremented or decremented, but wrap around. For example, rolling the
128 * month up in the date <code>December 12, <b>1996</b></code> results in
129 * <code>January 12, <b>1996</b></code>.
132 * <code>Calendar</code> also provides a date arithmetic function for
133 * adding the specified (signed) amount of time to a particular time field.
134 * For example, subtracting 5 days from the date <code>September 12, 1996</code>
135 * results in <code>September 7, 1996</code>.
141 * For usage in C programs.
144 typedef void* UCalendar
;
146 /** Possible types of UCalendars
150 /** A traditional calendar for the locale */
152 /** The Gregorian calendar */
156 /** @stable ICU 2.0 */
157 typedef enum UCalendarType UCalendarType
;
159 /** Possible fields in a UCalendar
162 enum UCalendarDateFields
{
184 * Week of month field
204 * Day of week in month field
207 UCAL_DAY_OF_WEEK_IN_MONTH
,
249 * Year / week of year
254 * Day of week, localized (1..7)
257 #ifndef U_HIDE_DRAFT_API
261 * Year of this calendar system, encompassing all supra-year fields. For example, in Gregorian/Julian calendars, positive Extended Year values indicate years AD, 1 BC = 0 extended, 2 BC = -1 extended, and so on.
266 * Modified Julian day number, encompassing all date-related fields. Demarcates at local midnight.
271 * Ranges from 0 to 23:59:59.999 (regardless of DST). This field behaves <em>exactly</em> like a composite of all time-related fields, not including the zone fields. As such, it also reflects discontinuities of those fields on DST transition days. On a day of DST onset, it will jump forward. On a day of DST cessation, it will jump backward. This reflects the fact that is must be combined with the DST_OFFSET field to obtain a unique local time value.
274 UCAL_MILLISECONDS_IN_DAY
,
276 #endif /* U_HIDE_DRAFT_API */
284 #ifndef U_HIDE_DRAFT_API
287 * Synonym for UCAL_DATE
290 UCAL_DAY_OF_MONTH
=UCAL_DATE
292 #endif /*U_HIDE_DRAFT_API*/
295 /** @stable ICU 2.0 */
296 typedef enum UCalendarDateFields UCalendarDateFields
;
298 * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients
299 * who create locale resources for the field of first-day-of-week should be aware of
300 * this. For instance, in US locale, first-day-of-week is set to 1, i.e., UCAL_SUNDAY.
302 /** Possible days of the week in a UCalendar
305 enum UCalendarDaysOfWeek
{
322 /** @stable ICU 2.0 */
323 typedef enum UCalendarDaysOfWeek UCalendarDaysOfWeek
;
325 /** Possible months in a UCalendar. Note: Calendar month is 0-based.
328 enum UCalendarMonths
{
357 /** @stable ICU 2.0 */
358 typedef enum UCalendarMonths UCalendarMonths
;
360 /** Possible AM/PM values in a UCalendar
363 enum UCalendarAMPMs
{
370 /** @stable ICU 2.0 */
371 typedef enum UCalendarAMPMs UCalendarAMPMs
;
374 * Create an enumeration over all time zones.
376 * @param ec input/output error code
378 * @return an enumeration object that the caller must dispose of using
379 * uenum_close(), or NULL upon failure. In case of failure *ec will
380 * indicate the error.
384 U_DRAFT UEnumeration
* U_EXPORT2
385 ucal_openTimeZones(UErrorCode
* ec
);
388 * Create an enumeration over all time zones associated with the given
389 * country. Some zones are affiliated with no country (e.g., "UTC");
390 * these may also be retrieved, as a group.
392 * @param country the ISO 3166 two-letter country code, or NULL to
393 * retrieve zones not affiliated with any country
395 * @param ec input/output error code
397 * @return an enumeration object that the caller must dispose of using
398 * uenum_close(), or NULL upon failure. In case of failure *ec will
399 * indicate the error.
403 U_DRAFT UEnumeration
* U_EXPORT2
404 ucal_openCountryTimeZones(const char* country
, UErrorCode
* ec
);
407 * Return the default time zone. The default is determined initially
408 * by querying the host operating system. It may be changed with
409 * ucal_setDefaultTimeZone() or with the C++ TimeZone API.
411 * @param result A buffer to receive the result, or NULL
413 * @param resultCapacity The capacity of the result buffer
415 * @param ec input/output error code
417 * @return The result string length, not including the terminating
422 U_DRAFT
int32_t U_EXPORT2
423 ucal_getDefaultTimeZone(UChar
* result
, int32_t resultCapacity
, UErrorCode
* ec
);
426 * Set the default time zone.
428 * @param zoneID null-terminated time zone ID
430 * @param ec input/output error code
434 U_DRAFT
void U_EXPORT2
435 ucal_setDefaultTimeZone(const UChar
* zoneID
, UErrorCode
* ec
);
438 * Return the amount of time in milliseconds that the clock is
439 * advanced during daylight savings time for the given time zone, or
440 * zero if the time zone does not observe daylight savings time.
442 * @param zoneID null-terminated time zone ID
444 * @param ec input/output error code
446 * @return the number of milliseconds the time is advanced with
447 * respect to standard time when the daylight savings rules are in
448 * effect. This is always a non-negative number, most commonly either
449 * 3,600,000 (one hour) or zero.
453 U_DRAFT
int32_t U_EXPORT2
454 ucal_getDSTSavings(const UChar
* zoneID
, UErrorCode
* ec
);
457 * Get the current date and time.
458 * The value returned is represented as milliseconds from the epoch.
459 * @return The current date and time.
462 U_STABLE UDate U_EXPORT2
467 * A UCalendar may be used to convert a millisecond value to a year,
469 * @param zoneID The desired TimeZone ID. If 0, use the default time zone.
470 * @param len The length of zoneID, or -1 if null-terminated.
471 * @param locale The desired locale
472 * @param type The type of UCalendar to open.
473 * @param status A pointer to an UErrorCode to receive any errors
474 * @return A pointer to a UCalendar, or 0 if an error occurred.
477 U_STABLE UCalendar
* U_EXPORT2
478 ucal_open(const UChar
* zoneID
,
486 * Once closed, a UCalendar may no longer be used.
487 * @param cal The UCalendar to close.
490 U_STABLE
void U_EXPORT2
491 ucal_close(UCalendar
*cal
);
494 * Set the TimeZone used by a UCalendar.
495 * A UCalendar uses a timezone for converting from Greenwich time to local time.
496 * @param cal The UCalendar to set.
497 * @param zoneID The desired TimeZone ID. If 0, use the default time zone.
498 * @param len The length of zoneID, or -1 if null-terminated.
499 * @param status A pointer to an UErrorCode to receive any errors.
502 U_STABLE
void U_EXPORT2
503 ucal_setTimeZone(UCalendar
* cal
,
509 * Possible formats for a UCalendar's display name
512 enum UCalendarDisplayNameType
{
513 /** Standard display name */
515 /** Short standard display name */
517 /** Daylight savings display name */
519 /** Short daylight savings display name */
523 /** @stable ICU 2.0 */
524 typedef enum UCalendarDisplayNameType UCalendarDisplayNameType
;
527 * Get the display name for a UCalendar's TimeZone.
528 * A display name is suitable for presentation to a user.
529 * @param cal The UCalendar to query.
530 * @param type The desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD,
531 * UCAL_DST, UCAL_SHORT_DST
532 * @param locale The desired locale for the display name.
533 * @param result A pointer to a buffer to receive the formatted number.
534 * @param resultLength The maximum size of result.
535 * @param status A pointer to an UErrorCode to receive any errors
536 * @return The total buffer size needed; if greater than resultLength, the output was truncated.
539 U_STABLE
int32_t U_EXPORT2
540 ucal_getTimeZoneDisplayName(const UCalendar
* cal
,
541 UCalendarDisplayNameType type
,
544 int32_t resultLength
,
548 * Determine if a UCalendar is currently in daylight savings time.
549 * Daylight savings time is not used in all parts of the world.
550 * @param cal The UCalendar to query.
551 * @param status A pointer to an UErrorCode to receive any errors
552 * @return TRUE if cal is currently in daylight savings time, FALSE otherwise
555 U_STABLE UBool U_EXPORT2
556 ucal_inDaylightTime(const UCalendar
* cal
,
557 UErrorCode
* status
);
560 * Types of UCalendar attributes
563 enum UCalendarAttribute
{
564 /** Lenient parsing */
566 /** First day of week */
567 UCAL_FIRST_DAY_OF_WEEK
,
568 /** Minimum number of days in first week */
569 UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
572 /** @stable ICU 2.0 */
573 typedef enum UCalendarAttribute UCalendarAttribute
;
576 * Get a numeric attribute associated with a UCalendar.
577 * Numeric attributes include the first day of the week, or the minimal numbers
578 * of days in the first week of the month.
579 * @param cal The UCalendar to query.
580 * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK,
581 * or UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
582 * @return The value of attr.
583 * @see ucal_setAttribute
586 U_STABLE
int32_t U_EXPORT2
587 ucal_getAttribute(const UCalendar
* cal
,
588 UCalendarAttribute attr
);
591 * Set a numeric attribute associated with a UCalendar.
592 * Numeric attributes include the first day of the week, or the minimal numbers
593 * of days in the first week of the month.
594 * @param cal The UCalendar to set.
595 * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK,
596 * or UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
597 * @param newValue The new value of attr.
598 * @see ucal_getAttribute
601 U_STABLE
void U_EXPORT2
602 ucal_setAttribute(UCalendar
* cal
,
603 UCalendarAttribute attr
,
607 * Get a locale for which calendars are available.
608 * A UCalendar in a locale returned by this function will contain the correct
609 * day and month names for the locale.
610 * @param index The index of the desired locale.
611 * @return A locale for which calendars are available, or 0 if none.
612 * @see ucal_countAvailable
615 U_STABLE
const char* U_EXPORT2
616 ucal_getAvailable(int32_t index
);
619 * Determine how many locales have calendars available.
620 * This function is most useful as determining the loop ending condition for
621 * calls to \ref ucal_getAvailable.
622 * @return The number of locales for which calendars are available.
623 * @see ucal_getAvailable
626 U_STABLE
int32_t U_EXPORT2
627 ucal_countAvailable(void);
630 * Get a UCalendar's current time in millis.
631 * The time is represented as milliseconds from the epoch.
632 * @param cal The UCalendar to query.
633 * @param status A pointer to an UErrorCode to receive any errors
634 * @return The calendar's current time in millis.
635 * @see ucal_setMillis
637 * @see ucal_setDateTime
640 U_STABLE UDate U_EXPORT2
641 ucal_getMillis(const UCalendar
* cal
,
645 * Set a UCalendar's current time in millis.
646 * The time is represented as milliseconds from the epoch.
647 * @param cal The UCalendar to set.
648 * @param dateTime The desired date and time.
649 * @param status A pointer to an UErrorCode to receive any errors
650 * @see ucal_getMillis
652 * @see ucal_setDateTime
655 U_STABLE
void U_EXPORT2
656 ucal_setMillis(UCalendar
* cal
,
658 UErrorCode
* status
);
661 * Set a UCalendar's current date.
662 * The date is represented as a series of 32-bit integers.
663 * @param cal The UCalendar to set.
664 * @param year The desired year.
665 * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY,
666 * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER
667 * @param date The desired day of the month.
668 * @param status A pointer to an UErrorCode to receive any errors
669 * @see ucal_getMillis
670 * @see ucal_setMillis
671 * @see ucal_setDateTime
674 U_STABLE
void U_EXPORT2
675 ucal_setDate(UCalendar
* cal
,
682 * Set a UCalendar's current date.
683 * The date is represented as a series of 32-bit integers.
684 * @param cal The UCalendar to set.
685 * @param year The desired year.
686 * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY,
687 * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER
688 * @param date The desired day of the month.
689 * @param hour The desired hour of day.
690 * @param minute The desired minute.
691 * @param second The desirec second.
692 * @param status A pointer to an UErrorCode to receive any errors
693 * @see ucal_getMillis
694 * @see ucal_setMillis
698 U_STABLE
void U_EXPORT2
699 ucal_setDateTime(UCalendar
* cal
,
709 * Returns TRUE if two UCalendars are equivalent. Equivalent
710 * UCalendars will behave identically, but they may be set to
712 * @param cal1 The first of the UCalendars to compare.
713 * @param cal2 The second of the UCalendars to compare.
714 * @return TRUE if cal1 and cal2 are equivalent, FALSE otherwise.
717 U_STABLE UBool U_EXPORT2
718 ucal_equivalentTo(const UCalendar
* cal1
,
719 const UCalendar
* cal2
);
722 * Add a specified signed amount to a particular field in a UCalendar.
723 * This can modify more significant fields in the calendar.
724 * @param cal The UCalendar to which to add.
725 * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
726 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
727 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
728 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
729 * @param amount The signed amount to add to field. If the amount causes the value
730 * to exceed to maximum or minimum values for that field, other fields are modified
731 * to preserve the magnitude of the change.
732 * @param status A pointer to an UErrorCode to receive any errors
736 U_STABLE
void U_EXPORT2
737 ucal_add(UCalendar
* cal
,
738 UCalendarDateFields field
,
743 * Add a specified signed amount to a particular field in a UCalendar.
744 * This will not modify more significant fields in the calendar.
745 * @param cal The UCalendar to which to add.
746 * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
747 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
748 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
749 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
750 * @param amount The signed amount to add to field. If the amount causes the value
751 * to exceed to maximum or minimum values for that field, the field is pinned to a permissible
753 * @param status A pointer to an UErrorCode to receive any errors
757 U_STABLE
void U_EXPORT2
758 ucal_roll(UCalendar
* cal
,
759 UCalendarDateFields field
,
764 * Get the current value of a field from a UCalendar.
765 * All fields are represented as 32-bit integers.
766 * @param cal The UCalendar to query.
767 * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
768 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
769 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
770 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
771 * @param status A pointer to an UErrorCode to receive any errors
772 * @return The value of the desired field.
775 * @see ucal_clearField
779 U_STABLE
int32_t U_EXPORT2
780 ucal_get(const UCalendar
* cal
,
781 UCalendarDateFields field
,
782 UErrorCode
* status
);
785 * Set the value of a field in a UCalendar.
786 * All fields are represented as 32-bit integers.
787 * @param cal The UCalendar to set.
788 * @param field The field to set; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
789 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
790 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
791 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
792 * @param value The desired value of field.
795 * @see ucal_clearField
799 U_STABLE
void U_EXPORT2
800 ucal_set(UCalendar
* cal
,
801 UCalendarDateFields field
,
805 * Determine if a field in a UCalendar is set.
806 * All fields are represented as 32-bit integers.
807 * @param cal The UCalendar to query.
808 * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
809 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
810 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
811 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
812 * @return TRUE if field is set, FALSE otherwise.
815 * @see ucal_clearField
819 U_STABLE UBool U_EXPORT2
820 ucal_isSet(const UCalendar
* cal
,
821 UCalendarDateFields field
);
824 * Clear a field in a UCalendar.
825 * All fields are represented as 32-bit integers.
826 * @param cal The UCalendar containing the field to clear.
827 * @param field The field to clear; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
828 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
829 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
830 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
837 U_STABLE
void U_EXPORT2
838 ucal_clearField(UCalendar
* cal
,
839 UCalendarDateFields field
);
842 * Clear all fields in a UCalendar.
843 * All fields are represented as 32-bit integers.
844 * @param calendar The UCalendar to clear.
848 * @see ucal_clearField
851 U_STABLE
void U_EXPORT2
852 ucal_clear(UCalendar
* calendar
);
855 * Possible limit values for a UCalendar
858 enum UCalendarLimitType
{
863 /** Greatest minimum value */
864 UCAL_GREATEST_MINIMUM
,
865 /** Leaest maximum value */
867 /** Actual minimum value */
869 /** Actual maximum value */
873 /** @stable ICU 2.0 */
874 typedef enum UCalendarLimitType UCalendarLimitType
;
877 * Determine a limit for a field in a UCalendar.
878 * A limit is a maximum or minimum value for a field.
879 * @param cal The UCalendar to query.
880 * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH,
881 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK,
882 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND,
883 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
884 * @param type The desired critical point; one of UCAL_MINIMUM, UCAL_MAXIMUM, UCAL_GREATEST_MINIMUM,
885 * UCAL_LEAST_MAXIMUM, UCAL_ACTUAL_MINIMUM, UCAL_ACTUAL_MAXIMUM
886 * @param status A pointer to an UErrorCode to receive any errors.
887 * @return The requested value.
890 U_STABLE
int32_t U_EXPORT2
891 ucal_getLimit(const UCalendar
* cal
,
892 UCalendarDateFields field
,
893 UCalendarLimitType type
,
896 #ifdef U_USE_UCAL_OBSOLETE_2_8
898 * Get an available TimeZone ID.
899 * A Timezone ID is a string of the form "America/Los Angeles".
900 * @param rawOffset The desired GMT offset
901 * @param index The index of the desired TimeZone.
902 * @param status A pointer to an UErrorCode to receive any errors
903 * @return The requested TimeZone ID, or 0 if not found
904 * @see ucal_countAvailableTZIDs
905 * @obsolete ICU 2.8. Use ucal_openTimeZoneEnumeration instead since this API will be removed in that release.
907 U_OBSOLETE
const UChar
* U_EXPORT2
908 ucal_getAvailableTZIDs(int32_t rawOffset
,
913 * Determine how many TimeZones exist with a certain offset.
914 * This function is most useful as determining the loop ending condition for
915 * calls to \ref ucal_getAvailableTZIDs.
916 * @param rawOffset The desired GMT offset.
917 * @return The number of TimeZones with rawOffset.
918 * @see ucal_getAvailableTZIDs
919 * @obsolete ICU 2.8. Use ucal_openTimeZoneEnumeration instead since this API will be removed in that release.
921 U_OBSOLETE
int32_t U_EXPORT2
922 ucal_countAvailableTZIDs(int32_t rawOffset
);
925 /** Get the locale for this calendar object. You can choose between valid and actual locale.
926 * @param cal The calendar object
927 * @param type type of the locale we're looking for (valid or actual)
928 * @param status error code for the operation
929 * @return the locale name
930 * @draft ICU 2.8 likely to change in ICU 3.0, based on feedback
932 U_DRAFT
const char * U_EXPORT2
933 ucal_getLocaleByType(const UCalendar
*cal
, ULocDataLocaleType type
, UErrorCode
* status
);
935 #endif /* #if !UCONFIG_NO_FORMATTING */