ICU 76.1 76.1
Loading...
Searching...
No Matches
Namespaces | Macros | Typedefs | Enumerations | Functions
ucal.h File Reference

C API: Calendar. More...

#include "unicode/utypes.h"
#include "unicode/uenum.h"
#include "unicode/uloc.h"
#include "unicode/localpointer.h"

Go to the source code of this file.

Namespaces

namespace  icu
 File coll.h.
 

Macros

#define UCAL_UNKNOWN_ZONE_ID   "Etc/Unknown"
 The time zone ID reserved for unknown time zone.
 

Typedefs

typedef void * UCalendar
 A calendar.
 
typedef enum UCalendarType UCalendarType
 
typedef enum UCalendarDateFields UCalendarDateFields
 
typedef enum UCalendarDaysOfWeek UCalendarDaysOfWeek
 
typedef enum UCalendarMonths UCalendarMonths
 
typedef enum UCalendarAMPMs UCalendarAMPMs
 
typedef enum USystemTimeZoneType USystemTimeZoneType
 
typedef enum UCalendarDisplayNameType UCalendarDisplayNameType
 
typedef enum UCalendarAttribute UCalendarAttribute
 
typedef enum UCalendarWallTimeOption UCalendarWallTimeOption
 
typedef enum UCalendarLimitType UCalendarLimitType
 
typedef enum UCalendarWeekdayType UCalendarWeekdayType
 
typedef enum UTimeZoneTransitionType UTimeZoneTransitionType
 
typedef enum UTimeZoneLocalOption UTimeZoneLocalOption
 

Enumerations

enum  UCalendarType { UCAL_TRADITIONAL , UCAL_DEFAULT = UCAL_TRADITIONAL , UCAL_GREGORIAN }
 Possible types of UCalendars. More...
 
enum  UCalendarDateFields {
  UCAL_ERA , UCAL_YEAR , UCAL_MONTH , UCAL_WEEK_OF_YEAR ,
  UCAL_WEEK_OF_MONTH , UCAL_DATE , UCAL_DAY_OF_YEAR , UCAL_DAY_OF_WEEK ,
  UCAL_DAY_OF_WEEK_IN_MONTH , UCAL_AM_PM , UCAL_HOUR , UCAL_HOUR_OF_DAY ,
  UCAL_MINUTE , UCAL_SECOND , UCAL_MILLISECOND , UCAL_ZONE_OFFSET ,
  UCAL_DST_OFFSET , UCAL_YEAR_WOY , UCAL_DOW_LOCAL , UCAL_EXTENDED_YEAR ,
  UCAL_JULIAN_DAY , UCAL_MILLISECONDS_IN_DAY , UCAL_IS_LEAP_MONTH , UCAL_ORDINAL_MONTH ,
  UCAL_FIELD_COUNT = UCAL_ORDINAL_MONTH + 1 , UCAL_DAY_OF_MONTH =UCAL_DATE
}
 Possible fields in a UCalendar. More...
 
enum  UCalendarDaysOfWeek {
  UCAL_SUNDAY = 1 , UCAL_MONDAY , UCAL_TUESDAY , UCAL_WEDNESDAY ,
  UCAL_THURSDAY , UCAL_FRIDAY , UCAL_SATURDAY
}
 Useful constant for days of week. More...
 
enum  UCalendarMonths {
  UCAL_JANUARY , UCAL_FEBRUARY , UCAL_MARCH , UCAL_APRIL ,
  UCAL_MAY , UCAL_JUNE , UCAL_JULY , UCAL_AUGUST ,
  UCAL_SEPTEMBER , UCAL_OCTOBER , UCAL_NOVEMBER , UCAL_DECEMBER ,
  UCAL_UNDECIMBER
}
 Possible months in a UCalendar. More...
 
enum  UCalendarAMPMs { UCAL_AM , UCAL_PM }
 Possible AM/PM values in a UCalendar. More...
 
enum  USystemTimeZoneType { UCAL_ZONE_TYPE_ANY , UCAL_ZONE_TYPE_CANONICAL , UCAL_ZONE_TYPE_CANONICAL_LOCATION }
 System time zone type constants used by filtering zones in ucal_openTimeZoneIDEnumeration. More...
 
enum  UCalendarDisplayNameType { UCAL_STANDARD , UCAL_SHORT_STANDARD , UCAL_DST , UCAL_SHORT_DST }
 Possible formats for a UCalendar's display name. More...
 
enum  UCalendarAttribute {
  UCAL_LENIENT , UCAL_FIRST_DAY_OF_WEEK , UCAL_MINIMAL_DAYS_IN_FIRST_WEEK , UCAL_REPEATED_WALL_TIME ,
  UCAL_SKIPPED_WALL_TIME
}
 Types of UCalendar attributes. More...
 
enum  UCalendarWallTimeOption { UCAL_WALLTIME_LAST , UCAL_WALLTIME_FIRST , UCAL_WALLTIME_NEXT_VALID }
 Options for handling ambiguous wall time at time zone offset transitions. More...
 
enum  UCalendarLimitType {
  UCAL_MINIMUM , UCAL_MAXIMUM , UCAL_GREATEST_MINIMUM , UCAL_LEAST_MAXIMUM ,
  UCAL_ACTUAL_MINIMUM , UCAL_ACTUAL_MAXIMUM
}
 Possible limit values for a UCalendar. More...
 
enum  UCalendarWeekdayType { UCAL_WEEKDAY , UCAL_WEEKEND , UCAL_WEEKEND_ONSET , UCAL_WEEKEND_CEASE }
 Weekday types, as returned by ucal_getDayOfWeekType(). More...
 
enum  UTimeZoneTransitionType { UCAL_TZ_TRANSITION_NEXT , UCAL_TZ_TRANSITION_NEXT_INCLUSIVE , UCAL_TZ_TRANSITION_PREVIOUS , UCAL_TZ_TRANSITION_PREVIOUS_INCLUSIVE }
 Time zone transition types for ucal_getTimeZoneTransitionDate. More...
 
enum  UTimeZoneLocalOption {
  UCAL_TZ_LOCAL_FORMER = 0x04 , UCAL_TZ_LOCAL_LATTER = 0x0C , UCAL_TZ_LOCAL_STANDARD_FORMER = UCAL_TZ_LOCAL_FORMER | 0x01 , UCAL_TZ_LOCAL_STANDARD_LATTER = UCAL_TZ_LOCAL_LATTER | 0x01 ,
  UCAL_TZ_LOCAL_DAYLIGHT_FORMER = UCAL_TZ_LOCAL_FORMER | 0x03 , UCAL_TZ_LOCAL_DAYLIGHT_LATTER = UCAL_TZ_LOCAL_LATTER | 0x03
}
 Options used by ucal_getTimeZoneOffsetFromLocal and BasicTimeZone::getOffsetFromLocal() to specify how to interpret an input time when it does not exist, or when it is ambiguous, around a time zone transition. More...
 

Functions

U_CAPI UEnumerationucal_openTimeZoneIDEnumeration (USystemTimeZoneType zoneType, const char *region, const int32_t *rawOffset, UErrorCode *ec)
 Create an enumeration over system time zone IDs with the given filter conditions.
 
U_CAPI UEnumerationucal_openTimeZones (UErrorCode *ec)
 Create an enumeration over all time zones.
 
U_CAPI UEnumerationucal_openCountryTimeZones (const char *country, UErrorCode *ec)
 Create an enumeration over all time zones associated with the given country.
 
U_CAPI int32_t ucal_getDefaultTimeZone (UChar *result, int32_t resultCapacity, UErrorCode *ec)
 Return the default time zone.
 
U_CAPI void ucal_setDefaultTimeZone (const UChar *zoneID, UErrorCode *ec)
 Set the default time zone.
 
U_CAPI int32_t ucal_getHostTimeZone (UChar *result, int32_t resultCapacity, UErrorCode *ec)
 Return the current host time zone.
 
U_CAPI int32_t ucal_getDSTSavings (const UChar *zoneID, UErrorCode *ec)
 Return the amount of time in milliseconds that the clock is advanced during daylight savings time for the given time zone, or zero if the time zone does not observe daylight savings time.
 
U_CAPI UDate ucal_getNow (void)
 Get the current date and time.
 
U_CAPI UCalendarucal_open (const UChar *zoneID, int32_t len, const char *locale, UCalendarType type, UErrorCode *status)
 Open a UCalendar.
 
U_CAPI void ucal_close (UCalendar *cal)
 Close a UCalendar.
 
U_CAPI UCalendarucal_clone (const UCalendar *cal, UErrorCode *status)
 Open a copy of a UCalendar.
 
U_CAPI void ucal_setTimeZone (UCalendar *cal, const UChar *zoneID, int32_t len, UErrorCode *status)
 Set the TimeZone used by a UCalendar.
 
U_CAPI int32_t ucal_getTimeZoneID (const UCalendar *cal, UChar *result, int32_t resultLength, UErrorCode *status)
 Get the ID of the UCalendar's time zone.
 
U_CAPI int32_t ucal_getTimeZoneDisplayName (const UCalendar *cal, UCalendarDisplayNameType type, const char *locale, UChar *result, int32_t resultLength, UErrorCode *status)
 Get the display name for a UCalendar's TimeZone.
 
U_CAPI UBool ucal_inDaylightTime (const UCalendar *cal, UErrorCode *status)
 Determine if a UCalendar is currently in daylight savings time.
 
U_CAPI void ucal_setGregorianChange (UCalendar *cal, UDate date, UErrorCode *pErrorCode)
 Sets the GregorianCalendar change date.
 
U_CAPI UDate ucal_getGregorianChange (const UCalendar *cal, UErrorCode *pErrorCode)
 Gets the Gregorian Calendar change date.
 
U_CAPI int32_t ucal_getAttribute (const UCalendar *cal, UCalendarAttribute attr)
 Get a numeric attribute associated with a UCalendar.
 
U_CAPI void ucal_setAttribute (UCalendar *cal, UCalendarAttribute attr, int32_t newValue)
 Set a numeric attribute associated with a UCalendar.
 
U_CAPI const char * ucal_getAvailable (int32_t localeIndex)
 Get a locale for which calendars are available.
 
U_CAPI int32_t ucal_countAvailable (void)
 Determine how many locales have calendars available.
 
U_CAPI UDate ucal_getMillis (const UCalendar *cal, UErrorCode *status)
 Get a UCalendar's current time in millis.
 
U_CAPI void ucal_setMillis (UCalendar *cal, UDate dateTime, UErrorCode *status)
 Set a UCalendar's current time in millis.
 
U_CAPI void ucal_setDate (UCalendar *cal, int32_t year, int32_t month, int32_t date, UErrorCode *status)
 Set a UCalendar's current date.
 
U_CAPI void ucal_setDateTime (UCalendar *cal, int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second, UErrorCode *status)
 Set a UCalendar's current date.
 
U_CAPI UBool ucal_equivalentTo (const UCalendar *cal1, const UCalendar *cal2)
 Returns true if two UCalendars are equivalent.
 
U_CAPI void ucal_add (UCalendar *cal, UCalendarDateFields field, int32_t amount, UErrorCode *status)
 Add a specified signed amount to a particular field in a UCalendar.
 
U_CAPI void ucal_roll (UCalendar *cal, UCalendarDateFields field, int32_t amount, UErrorCode *status)
 Add a specified signed amount to a particular field in a UCalendar.
 
U_CAPI int32_t ucal_get (const UCalendar *cal, UCalendarDateFields field, UErrorCode *status)
 Get the current value of a field from a UCalendar.
 
U_CAPI void ucal_set (UCalendar *cal, UCalendarDateFields field, int32_t value)
 Set the value of a field in a UCalendar.
 
U_CAPI UBool ucal_isSet (const UCalendar *cal, UCalendarDateFields field)
 Determine if a field in a UCalendar is set.
 
U_CAPI void ucal_clearField (UCalendar *cal, UCalendarDateFields field)
 Clear a field in a UCalendar.
 
U_CAPI void ucal_clear (UCalendar *calendar)
 Clear all fields in a UCalendar.
 
U_CAPI int32_t ucal_getLimit (const UCalendar *cal, UCalendarDateFields field, UCalendarLimitType type, UErrorCode *status)
 Determine a limit for a field in a UCalendar.
 
U_CAPI const char * ucal_getLocaleByType (const UCalendar *cal, ULocDataLocaleType type, UErrorCode *status)
 Get the locale for this calendar object.
 
U_CAPI const char * ucal_getTZDataVersion (UErrorCode *status)
 Returns the timezone data version currently used by ICU.
 
U_CAPI int32_t ucal_getCanonicalTimeZoneID (const UChar *id, int32_t len, UChar *result, int32_t resultCapacity, UBool *isSystemID, UErrorCode *status)
 Returns the canonical system timezone ID or the normalized custom time zone ID for the given time zone ID.
 
U_CAPI int32_t ucal_getIanaTimeZoneID (const UChar *id, int32_t len, UChar *result, int32_t resultCapacity, UErrorCode *status)
 Returns the preferred time zone ID in the IANA time zone database for the given time zone ID.
 
U_CAPI const char * ucal_getType (const UCalendar *cal, UErrorCode *status)
 Get the resource keyword value string designating the calendar type for the UCalendar.
 
U_CAPI UEnumerationucal_getKeywordValuesForLocale (const char *key, const char *locale, UBool commonlyUsed, UErrorCode *status)
 Given a key and a locale, returns an array of string values in a preferred order that would make a difference.
 
U_CAPI UCalendarWeekdayType ucal_getDayOfWeekType (const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode *status)
 Returns whether the given day of the week is a weekday, a weekend day, or a day that transitions from one to the other, for the locale and calendar system associated with this UCalendar (the locale's region is often the most determinant factor).
 
U_CAPI int32_t ucal_getWeekendTransition (const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode *status)
 Returns the time during the day at which the weekend begins or ends in this calendar system.
 
U_CAPI UBool ucal_isWeekend (const UCalendar *cal, UDate date, UErrorCode *status)
 Returns true if the given UDate is in the weekend in this calendar system.
 
U_CAPI int32_t ucal_getFieldDifference (UCalendar *cal, UDate target, UCalendarDateFields field, UErrorCode *status)
 Return the difference between the target time and the time this calendar object is currently set to.
 
U_CAPI UBool ucal_getTimeZoneTransitionDate (const UCalendar *cal, UTimeZoneTransitionType type, UDate *transition, UErrorCode *status)
 Get the UDate for the next/previous time zone transition relative to the calendar's current date, in the time zone to which the calendar is currently set.
 
U_CAPI int32_t ucal_getWindowsTimeZoneID (const UChar *id, int32_t len, UChar *winid, int32_t winidCapacity, UErrorCode *status)
 Converts a system time zone ID to an equivalent Windows time zone ID.
 
U_CAPI int32_t ucal_getTimeZoneIDForWindowsID (const UChar *winid, int32_t len, const char *region, UChar *id, int32_t idCapacity, UErrorCode *status)
 Converts a Windows time zone ID to an equivalent system time zone ID for a region.
 
U_CAPI void ucal_getTimeZoneOffsetFromLocal (const UCalendar *cal, UTimeZoneLocalOption nonExistingTimeOpt, UTimeZoneLocalOption duplicatedTimeOpt, int32_t *rawOffset, int32_t *dstOffset, UErrorCode *status)
 Returns the time zone raw and GMT offset for the given moment in time.
 

Detailed Description

C API: Calendar.

Calendar C API

UCalendar C API is used for converting between a UDate object and a set of integer fields such as UCAL_YEAR, UCAL_MONTH, UCAL_DAY, UCAL_HOUR, and so on. (A UDate object represents a specific instant in time with millisecond precision. See UDate for information about the UDate .)

Types of UCalendar interpret a UDate according to the rules of a specific calendar system. The C API provides the enum UCalendarType with UCAL_TRADITIONAL and UCAL_GREGORIAN.

Like other locale-sensitive C API, calendar API provides a function, ucal_open(), which returns a pointer to UCalendar whose time fields have been initialized with the current date and time. We need to specify the type of calendar to be opened and the timezoneId.

UCalendar *caldef;
UChar *tzId;
UErrorCode status;
tzId=(UChar*)malloc(sizeof(UChar) * (strlen("PST") +1) );
u_uastrcpy(tzId, "PST");
caldef=ucal_open(tzID, u_strlen(tzID), NULL, UCAL_TRADITIONAL, &status);
U_CAPI int32_t u_strlen(const UChar *s)
U_CAPI UCalendar * ucal_open(const UChar *zoneID, int32_t len, const char *locale, UCalendarType type, UErrorCode *status)
Open a UCalendar.
@ UCAL_TRADITIONAL
Despite the name, UCAL_TRADITIONAL designates the locale's default calendar, which may be the Gregori...
Definition ucal.h:183
void * UCalendar
A calendar.
Definition ucal.h:172
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:378
U_CAPI UChar * u_uastrcpy(UChar *dst, const char *src)
Copy a byte string encoded in the default codepage to a ustring.
#define NULL
Define NULL if necessary, to nullptr for C++ and to ((void *)0) for C.
Definition utypes.h:203
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:430

A UCalendar object can produce all the time field values needed to implement the date-time formatting for a particular language and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).

When computing a UDate from time fields, two special circumstances may arise: there may be insufficient information to compute the UDate (such as only year and month but no day in the month), or there may be inconsistent information (such as "Tuesday, July 15, 1996" – July 15, 1996 is actually a Monday).

Insufficient information. The calendar will use default information to specify the missing fields. This may vary by calendar; for the Gregorian calendar, the default for a field is the same as that of the start of the epoch: i.e., UCAL_YEAR = 1970, UCAL_MONTH = JANUARY, UCAL_DATE = 1, etc.

Inconsistent information. If fields conflict, the calendar will give preference to fields set more recently. For example, when determining the day, the calendar will look for one of the following combinations of fields. The most recent combination, as determined by the most recently set single field, will be used.

@ UCAL_WEEK_OF_MONTH
Field number indicating the week number within the current month.
Definition ucal.h:263
@ UCAL_DAY_OF_YEAR
Field number indicating the day number within the current year.
Definition ucal.h:279
@ UCAL_DAY_OF_WEEK_IN_MONTH
Field number indicating the ordinal number of the day of the week within the current month.
Definition ucal.h:320
@ UCAL_MONTH
Field number indicating the month.
Definition ucal.h:235
@ UCAL_WEEK_OF_YEAR
Field number indicating the week number within the current year.
Definition ucal.h:248
@ UCAL_DAY_OF_MONTH
Field number indicating the day of the month.
Definition ucal.h:489
@ UCAL_DAY_OF_WEEK
Field number indicating the day of the week.
Definition ucal.h:295

For the time of day:

@ UCAL_HOUR_OF_DAY
Field number indicating the hour of the day.
Definition ucal.h:351
@ UCAL_HOUR
Field number indicating the hour of the morning or afternoon.
Definition ucal.h:342
@ UCAL_AM_PM
Field number indicating whether the HOUR is before or after noon.
Definition ucal.h:331

Note: for some non-Gregorian calendars, different fields may be necessary for complete disambiguation. For example, a full specification of the historical Arabic astronomical calendar requires year, month, day-of-month and day-of-week in some cases.

Note: There are certain possible ambiguities in interpretation of certain singular times, which are resolved in the following ways:

  1. 24:00:00 "belongs" to the following day. That is, 23:59 on Dec 31, 1969 < 24:00 on Jan 1, 1970 < 24:01:00 on Jan 1, 1970

  2. Although historically not precise, midnight also belongs to "am", and noon belongs to "pm", so on the same day, 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm

The date or time format strings are not part of the definition of a calendar, as those must be modifiable or overridable by the user at runtime. Use icu::DateFormat to format dates.

Calendar provides an API for field "rolling", where fields can be incremented or decremented, but wrap around. For example, rolling the month up in the date December 12, 1996 results in January 12, 1996.

Calendar also provides a date arithmetic function for adding the specified (signed) amount of time to a particular time field. For example, subtracting 5 days from the date September 12, 1996 results in September 7, 1996.

The Japanese calendar uses a combination of era name and year number. When an emperor of Japan abdicates and a new emperor ascends the throne, a new era is declared and year number is reset to 1. Even if the date of abdication is scheduled ahead of time, the new era name might not be announced until just before the date. In such case, ICU4C may include a start date of future era without actual era name, but not enabled by default. ICU4C users who want to test the behavior of the future era can enable the tentative era by:

Stable:
ICU 2.0

Definition in file ucal.h.

Macro Definition Documentation

◆ UCAL_UNKNOWN_ZONE_ID

#define UCAL_UNKNOWN_ZONE_ID   "Etc/Unknown"

The time zone ID reserved for unknown time zone.

It behaves like the GMT/UTC time zone but has the special ID "Etc/Unknown".

Stable:
ICU 4.8

Definition at line 166 of file ucal.h.

Typedef Documentation

◆ UCalendar

typedef void* UCalendar

A calendar.

For usage in C programs.

Stable:
ICU 2.0

Definition at line 172 of file ucal.h.

◆ UCalendarAMPMs

Stable:
ICU 2.0

Definition at line 571 of file ucal.h.

◆ UCalendarAttribute

Stable:
ICU 2.0

Definition at line 984 of file ucal.h.

◆ UCalendarDateFields

Stable:
ICU 2.0

Definition at line 493 of file ucal.h.

◆ UCalendarDaysOfWeek

Stable:
ICU 2.0

Definition at line 520 of file ucal.h.

◆ UCalendarDisplayNameType

Stable:
ICU 2.0

Definition at line 868 of file ucal.h.

◆ UCalendarLimitType

Stable:
ICU 2.0

Definition at line 1327 of file ucal.h.

◆ UCalendarMonths

Stable:
ICU 2.0

Definition at line 558 of file ucal.h.

◆ UCalendarType

Stable:
ICU 2.0

Definition at line 197 of file ucal.h.

◆ UCalendarWallTimeOption

Stable:
ICU 49

Definition at line 1014 of file ucal.h.

◆ UCalendarWeekdayType

Stable:
ICU 4.4

Definition at line 1481 of file ucal.h.

◆ USystemTimeZoneType

Stable:
ICU 4.8

Definition at line 598 of file ucal.h.

◆ UTimeZoneLocalOption

Stable:
ICU 69

Definition at line 1732 of file ucal.h.

◆ UTimeZoneTransitionType

Stable:
ICU 50

Definition at line 1595 of file ucal.h.

Enumeration Type Documentation

◆ UCalendarAMPMs

Possible AM/PM values in a UCalendar.

Stable:
ICU 2.0
Enumerator
UCAL_AM 

AM.

UCAL_PM 

PM.

Definition at line 563 of file ucal.h.

◆ UCalendarAttribute

Types of UCalendar attributes.

Stable:
ICU 2.0
Enumerator
UCAL_LENIENT 

Lenient parsing.

Stable:
ICU 2.0
UCAL_FIRST_DAY_OF_WEEK 

First day of week.

Stable:
ICU 2.0
UCAL_MINIMAL_DAYS_IN_FIRST_WEEK 

Minimum number of days in first week.

Stable:
ICU 2.0
UCAL_REPEATED_WALL_TIME 

The behavior for handling wall time repeating multiple times at negative time zone offset transitions.

Stable:
ICU 49
UCAL_SKIPPED_WALL_TIME 

The behavior for handling skipped wall time at positive time zone offset transitions.

Stable:
ICU 49

Definition at line 953 of file ucal.h.

◆ UCalendarDateFields

Possible fields in a UCalendar.

Stable:
ICU 2.0
Enumerator
UCAL_ERA 

Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar.

This is a calendar-specific value.

Stable:
ICU 2.6
UCAL_YEAR 

Field number indicating the year.

This is a calendar-specific value.

Stable:
ICU 2.6
UCAL_MONTH 

Field number indicating the month.

This is a calendar-specific value. The first month of the year is JANUARY; the last depends on the number of months in a year.

See also
UCAL_JANUARY
UCAL_FEBRUARY
UCAL_MARCH
UCAL_APRIL
UCAL_MAY
UCAL_JUNE
UCAL_JULY
UCAL_AUGUST
UCAL_SEPTEMBER
UCAL_OCTOBER
UCAL_NOVEMBER
UCAL_DECEMBER
UCAL_UNDECIMBER
Stable:
ICU 2.6
UCAL_WEEK_OF_YEAR 

Field number indicating the week number within the current year.

The first week of the year, as defined by UCAL_FIRST_DAY_OF_WEEK and UCAL_MINIMAL_DAYS_IN_FIRST_WEEK attributes, has value 1. Subclasses define the value of UCAL_WEEK_OF_YEAR for days before the first week of the year.

See also
ucal_getAttribute
ucal_setAttribute
Stable:
ICU 2.6
UCAL_WEEK_OF_MONTH 

Field number indicating the week number within the current month.

The first week of the month, as defined by UCAL_FIRST_DAY_OF_WEEK and UCAL_MINIMAL_DAYS_IN_FIRST_WEEK attributes, has value 1. Subclasses define the value of WEEK_OF_MONTH for days before the first week of the month.

See also
ucal_getAttribute
ucal_setAttribute
UCAL_FIRST_DAY_OF_WEEK
UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
Stable:
ICU 2.6
UCAL_DATE 

Field number indicating the day of the month.

This is a synonym for DAY_OF_MONTH. The first day of the month has value 1.

See also
UCAL_DAY_OF_MONTH
Stable:
ICU 2.6
UCAL_DAY_OF_YEAR 

Field number indicating the day number within the current year.

The first day of the year has value 1.

Stable:
ICU 2.6
UCAL_DAY_OF_WEEK 

Field number indicating the day of the week.

This field takes values SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, and SATURDAY.

See also
UCAL_SUNDAY
UCAL_MONDAY
UCAL_TUESDAY
UCAL_WEDNESDAY
UCAL_THURSDAY
UCAL_FRIDAY
UCAL_SATURDAY
Stable:
ICU 2.6
UCAL_DAY_OF_WEEK_IN_MONTH 

Field number indicating the ordinal number of the day of the week within the current month.

Together with the DAY_OF_WEEK field, this uniquely specifies a day within a month. Unlike WEEK_OF_MONTH and WEEK_OF_YEAR, this field's value does not depend on getFirstDayOfWeek() or getMinimalDaysInFirstWeek(). DAY_OF_MONTH 1 through 7 always correspond to DAY_OF_WEEK_IN_MONTH 1; 8 through 15 correspond to DAY_OF_WEEK_IN_MONTH 2, and so on. DAY_OF_WEEK_IN_MONTH 0 indicates the week before DAY_OF_WEEK_IN_MONTH 1. Negative values count back from the end of the month, so the last Sunday of a month is specified as DAY_OF_WEEK = SUNDAY, DAY_OF_WEEK_IN_MONTH = -1. Because negative values count backward they will usually be aligned differently within the month than positive values. For example, if a month has 31 days, DAY_OF_WEEK_IN_MONTH -1 will overlap DAY_OF_WEEK_IN_MONTH 5 and the end of 4.

See also
UCAL_DAY_OF_WEEK
UCAL_WEEK_OF_MONTH
Stable:
ICU 2.6
UCAL_AM_PM 

Field number indicating whether the HOUR is before or after noon.

E.g., at 10:04:15.250 PM the AM_PM is PM.

See also
UCAL_AM
UCAL_PM
UCAL_HOUR
Stable:
ICU 2.6
UCAL_HOUR 

Field number indicating the hour of the morning or afternoon.

HOUR is used for the 12-hour clock. E.g., at 10:04:15.250 PM the HOUR is 10.

See also
UCAL_AM_PM
UCAL_HOUR_OF_DAY
Stable:
ICU 2.6
UCAL_HOUR_OF_DAY 

Field number indicating the hour of the day.

HOUR_OF_DAY is used for the 24-hour clock. E.g., at 10:04:15.250 PM the HOUR_OF_DAY is 22.

See also
UCAL_HOUR
Stable:
ICU 2.6
UCAL_MINUTE 

Field number indicating the minute within the hour.

E.g., at 10:04:15.250 PM the UCAL_MINUTE is 4.

Stable:
ICU 2.6
UCAL_SECOND 

Field number indicating the second within the minute.

E.g., at 10:04:15.250 PM the UCAL_SECOND is 15.

Stable:
ICU 2.6
UCAL_MILLISECOND 

Field number indicating the millisecond within the second.

E.g., at 10:04:15.250 PM the UCAL_MILLISECOND is 250.

Stable:
ICU 2.6
UCAL_ZONE_OFFSET 

Field number indicating the raw offset from GMT in milliseconds.

Stable:
ICU 2.6
UCAL_DST_OFFSET 

Field number indicating the daylight savings offset in milliseconds.

Stable:
ICU 2.6
UCAL_YEAR_WOY 

Field number indicating the extended year corresponding to the UCAL_WEEK_OF_YEAR field.

This may be one greater or less than the value of UCAL_EXTENDED_YEAR.

Stable:
ICU 2.6
UCAL_DOW_LOCAL 

Field number indicating the localized day of week.

This will be a value from 1 to 7 inclusive, with 1 being the localized first day of the week.

Stable:
ICU 2.6
UCAL_EXTENDED_YEAR 

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.

Stable:
ICU 2.8
UCAL_JULIAN_DAY 

Field number indicating the modified Julian day number.

This is different from the conventional Julian day number in two regards. First, it demarcates days at local zone midnight, rather than noon GMT. Second, it is a local number; that is, it depends on the local time zone. It can be thought of as a single number that encompasses all the date-related fields.

Stable:
ICU 2.8
UCAL_MILLISECONDS_IN_DAY 

Ranges from 0 to 23:59:59.999 (regardless of DST).

This field behaves exactly 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 it must be combined with the DST_OFFSET field to obtain a unique local time value.

Stable:
ICU 2.8
UCAL_IS_LEAP_MONTH 

Whether or not the current month is a leap month (0 or 1).

See the Chinese calendar for an example of this.

UCAL_ORDINAL_MONTH 

Field number indicating the month.

This is a calendar-specific value. Differ from UCAL_MONTH, this value is continuous and unique within a year and range from 0 to 11 or 0 to 12 depending on how many months in a year, the calendar system has leap month or not, and in leap year or not. It is the ordinal position of that month in the corresponding year of the calendar. For Chinese, Dangi, and Hebrew calendar, the range is 0 to 11 in non-leap years and 0 to 12 in leap years. For Coptic and Ethiopian calendar, the range is always 0 to 12. For other calendars supported by ICU now, the range is 0 to 11. When the number of months in a year of the identified calendar is variable, a different UCAL_ORDINAL_MONTH value can be used for dates that are part of the same named month in different years. For example, in the Hebrew calendar, "1 Nisan 5781" is associated with UCAL_ORDINAL_MONTH value 6 while "1 Nisan 5782" is associated with UCAL_ORDINAL_MONTH value 7 because 5782 is a leap year and Nisan follows the insertion of Adar I. In Chinese calendar, "Year 4664 Month 6 Day 2" is associated with UCAL_ORDINAL_MONTH value 5 while "Year 4665 Month 6 Day 2" is associated with UCAL_ORDINAL_MONTH value 6 because 4665 is a leap year and there is an extra "Leap Month 5" which associated with UCAL_ORDINAL_MONTH value 5 before "Month 6" of year 4664.

Stable:
ICU 73
UCAL_FIELD_COUNT 

One more than the highest normal UCalendarDateFields value.

Deprecated:
ICU 58 The numeric value may change over time, see ICU ticket #12420.
UCAL_DAY_OF_MONTH 

Field number indicating the day of the month.

This is a synonym for UCAL_DATE. The first day of the month has value 1.

See also
UCAL_DATE Synonym for UCAL_DATE
Stable:
ICU 2.8

Definition at line 202 of file ucal.h.

◆ UCalendarDaysOfWeek

Useful constant for days of week.

Note: Calendar day-of-week is 1-based. Clients who create locale resources for the field of first-day-of-week should be aware of this. For instance, in US locale, first-day-of-week is set to 1, i.e., UCAL_SUNDAY. Possible days of the week in a UCalendar

Stable:
ICU 2.0
Enumerator
UCAL_SUNDAY 

Sunday.

UCAL_MONDAY 

Monday.

UCAL_TUESDAY 

Tuesday.

UCAL_WEDNESDAY 

Wednesday.

UCAL_THURSDAY 

Thursday.

UCAL_FRIDAY 

Friday.

UCAL_SATURDAY 

Saturday.

Definition at line 502 of file ucal.h.

◆ UCalendarDisplayNameType

Possible formats for a UCalendar's display name.

Stable:
ICU 2.0
Enumerator
UCAL_STANDARD 

Standard display name.

UCAL_SHORT_STANDARD 

Short standard display name.

UCAL_DST 

Daylight savings display name.

UCAL_SHORT_DST 

Short daylight savings display name.

Definition at line 856 of file ucal.h.

◆ UCalendarLimitType

Possible limit values for a UCalendar.

Stable:
ICU 2.0
Enumerator
UCAL_MINIMUM 

Minimum value.

UCAL_MAXIMUM 

Maximum value.

UCAL_GREATEST_MINIMUM 

Greatest minimum value.

UCAL_LEAST_MAXIMUM 

Least maximum value.

UCAL_ACTUAL_MINIMUM 

Actual minimum value.

UCAL_ACTUAL_MAXIMUM 

Actual maximum value.

Definition at line 1311 of file ucal.h.

◆ UCalendarMonths

Possible months in a UCalendar.

Note: Calendar month is 0-based.

Stable:
ICU 2.0
Enumerator
UCAL_JANUARY 

January.

UCAL_FEBRUARY 

February.

UCAL_MARCH 

March.

UCAL_APRIL 

April.

UCAL_MAY 

May.

UCAL_JUNE 

June.

UCAL_JULY 

July.

UCAL_AUGUST 

August.

UCAL_SEPTEMBER 

September.

UCAL_OCTOBER 

October.

UCAL_NOVEMBER 

November.

UCAL_DECEMBER 

December.

UCAL_UNDECIMBER 

Value of the UCAL_MONTH field indicating the thirteenth month of the year.

Although the Gregorian calendar does not use this value, lunar calendars do.

Definition at line 525 of file ucal.h.

◆ UCalendarType

Possible types of UCalendars.

Stable:
ICU 2.0
Enumerator
UCAL_TRADITIONAL 

Despite the name, UCAL_TRADITIONAL designates the locale's default calendar, which may be the Gregorian calendar or some other calendar.

Stable:
ICU 2.0
UCAL_DEFAULT 

A better name for UCAL_TRADITIONAL.

Stable:
ICU 4.2
UCAL_GREGORIAN 

Unambiguously designates the Gregorian calendar for the locale.

Stable:
ICU 2.0

Definition at line 177 of file ucal.h.

◆ UCalendarWallTimeOption

Options for handling ambiguous wall time at time zone offset transitions.

Stable:
ICU 49
Enumerator
UCAL_WALLTIME_LAST 

An ambiguous wall time to be interpreted as the latest.

This option is valid for UCAL_REPEATED_WALL_TIME and UCAL_SKIPPED_WALL_TIME.

Stable:
ICU 49
UCAL_WALLTIME_FIRST 

An ambiguous wall time to be interpreted as the earliest.

This option is valid for UCAL_REPEATED_WALL_TIME and UCAL_SKIPPED_WALL_TIME.

Stable:
ICU 49
UCAL_WALLTIME_NEXT_VALID 

An ambiguous wall time to be interpreted as the next valid wall time.

This option is valid for UCAL_SKIPPED_WALL_TIME.

Stable:
ICU 49

Definition at line 991 of file ucal.h.

◆ UCalendarWeekdayType

Weekday types, as returned by ucal_getDayOfWeekType().

Stable:
ICU 4.4
Enumerator
UCAL_WEEKDAY 

Designates a full weekday (no part of the day is included in the weekend).

Stable:
ICU 4.4
UCAL_WEEKEND 

Designates a full weekend day (the entire day is included in the weekend).

Stable:
ICU 4.4
UCAL_WEEKEND_ONSET 

Designates a day that starts as a weekday and transitions to the weekend.

Call ucal_getWeekendTransition() to get the time of transition.

Stable:
ICU 4.4
UCAL_WEEKEND_CEASE 

Designates a day that starts as the weekend and transitions to a weekday.

Call ucal_getWeekendTransition() to get the time of transition.

Stable:
ICU 4.4

Definition at line 1455 of file ucal.h.

◆ USystemTimeZoneType

System time zone type constants used by filtering zones in ucal_openTimeZoneIDEnumeration.

See also
ucal_openTimeZoneIDEnumeration
Stable:
ICU 4.8
Enumerator
UCAL_ZONE_TYPE_ANY 

Any system zones.

Stable:
ICU 4.8
UCAL_ZONE_TYPE_CANONICAL 

Canonical system zones.

Stable:
ICU 4.8
UCAL_ZONE_TYPE_CANONICAL_LOCATION 

Canonical system zones associated with actual locations.

Stable:
ICU 4.8

Definition at line 579 of file ucal.h.

◆ UTimeZoneLocalOption

Options used by ucal_getTimeZoneOffsetFromLocal and BasicTimeZone::getOffsetFromLocal() to specify how to interpret an input time when it does not exist, or when it is ambiguous, around a time zone transition.

Stable:
ICU 69
Enumerator
UCAL_TZ_LOCAL_FORMER 

An input time is always interpreted as local time before a time zone transition.

Stable:
ICU 69
UCAL_TZ_LOCAL_LATTER 

An input time is always interpreted as local time after a time zone transition.

Stable:
ICU 69
UCAL_TZ_LOCAL_STANDARD_FORMER 

An input time is interpreted as standard time when local time is switched to/from daylight saving time.

When both sides of a time zone transition are standard time, or daylight saving time, the local time before the transition is used.

Stable:
ICU 69
UCAL_TZ_LOCAL_STANDARD_LATTER 

An input time is interpreted as standard time when local time is switched to/from daylight saving time.

When both sides of a time zone transition are standard time, or daylight saving time, the local time after the transition is used.

Stable:
ICU 69
UCAL_TZ_LOCAL_DAYLIGHT_FORMER 

An input time is interpreted as daylight saving time when local time is switched to/from standard time.

When both sides of a time zone transition are standard time, or daylight saving time, the local time before the transition is used.

Stable:
ICU 69
UCAL_TZ_LOCAL_DAYLIGHT_LATTER 

An input time is interpreted as daylight saving time when local time is switched to/from standard time.

When both sides of a time zone transition are standard time, or daylight saving time, the local time after the transition is used.

Stable:
ICU 69

Definition at line 1682 of file ucal.h.

◆ UTimeZoneTransitionType

Time zone transition types for ucal_getTimeZoneTransitionDate.

Stable:
ICU 50
Enumerator
UCAL_TZ_TRANSITION_NEXT 

Get the next transition after the current date, i.e.

excludes the current date

Stable:
ICU 50
UCAL_TZ_TRANSITION_NEXT_INCLUSIVE 

Get the next transition on or after the current date, i.e.

may include the current date

Stable:
ICU 50
UCAL_TZ_TRANSITION_PREVIOUS 

Get the previous transition before the current date, i.e.

excludes the current date

Stable:
ICU 50
UCAL_TZ_TRANSITION_PREVIOUS_INCLUSIVE 

Get the previous transition on or before the current date, i.e.

may include the current date

Stable:
ICU 50

Definition at line 1568 of file ucal.h.

Function Documentation

◆ ucal_add()

U_CAPI void ucal_add ( UCalendar cal,
UCalendarDateFields  field,
int32_t  amount,
UErrorCode status 
)

Add a specified signed amount to a particular field in a UCalendar.

This can modify more significant fields in the calendar. Adding a positive value always means moving forward in time, so for the Gregorian calendar, starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces the numeric value of the field itself).

Parameters
calThe UCalendar to which to add.
fieldThe field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
amountThe signed amount to add to field. If the amount causes the value to exceed to maximum or minimum values for that field, other fields are modified to preserve the magnitude of the change.
statusA pointer to an UErrorCode to receive any errors
See also
ucal_roll
Stable:
ICU 2.0

◆ ucal_clear()

U_CAPI void ucal_clear ( UCalendar calendar)

Clear all fields in a UCalendar.

All fields are represented as 32-bit integers.

Parameters
calendarThe UCalendar to clear.
See also
ucal_get
ucal_set
ucal_isSet
ucal_clearField
Stable:
ICU 2.0

◆ ucal_clearField()

U_CAPI void ucal_clearField ( UCalendar cal,
UCalendarDateFields  field 
)

Clear a field in a UCalendar.

All fields are represented as 32-bit integers.

Parameters
calThe UCalendar containing the field to clear.
fieldThe field to clear; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
See also
ucal_get
ucal_set
ucal_isSet
ucal_clear
Stable:
ICU 2.0

◆ ucal_clone()

U_CAPI UCalendar * ucal_clone ( const UCalendar cal,
UErrorCode status 
)

Open a copy of a UCalendar.

This function performs a deep copy.

Parameters
calThe calendar to copy
statusA pointer to an UErrorCode to receive any errors.
Returns
A pointer to a UCalendar identical to cal.
Stable:
ICU 4.0

◆ ucal_close()

U_CAPI void ucal_close ( UCalendar cal)

Close a UCalendar.

Once closed, a UCalendar may no longer be used.

Parameters
calThe UCalendar to close.
Stable:
ICU 2.0

◆ ucal_countAvailable()

U_CAPI int32_t ucal_countAvailable ( void  )

Determine how many locales have calendars available.

This function is most useful as determining the loop ending condition for calls to ucal_getAvailable.

Returns
The number of locales for which calendars are available.
See also
ucal_getAvailable
Stable:
ICU 2.0

◆ ucal_equivalentTo()

U_CAPI UBool ucal_equivalentTo ( const UCalendar cal1,
const UCalendar cal2 
)

Returns true if two UCalendars are equivalent.

Equivalent UCalendars will behave identically, but they may be set to different times.

Parameters
cal1The first of the UCalendars to compare.
cal2The second of the UCalendars to compare.
Returns
true if cal1 and cal2 are equivalent, false otherwise.
Stable:
ICU 2.0

◆ ucal_get()

U_CAPI int32_t ucal_get ( const UCalendar cal,
UCalendarDateFields  field,
UErrorCode status 
)

Get the current value of a field from a UCalendar.

All fields are represented as 32-bit integers.

Parameters
calThe UCalendar to query.
fieldThe desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
statusA pointer to an UErrorCode to receive any errors
Returns
The value of the desired field.
See also
ucal_set
ucal_isSet
ucal_clearField
ucal_clear
Stable:
ICU 2.0

◆ ucal_getAttribute()

U_CAPI int32_t ucal_getAttribute ( const UCalendar cal,
UCalendarAttribute  attr 
)

Get a numeric attribute associated with a UCalendar.

Numeric attributes include the first day of the week, or the minimal numbers of days in the first week of the month.

Parameters
calThe UCalendar to query.
attrThe desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, UCAL_REPEATED_WALL_TIME or UCAL_SKIPPED_WALL_TIME
Returns
The value of attr.
See also
ucal_setAttribute
Stable:
ICU 2.0

◆ ucal_getAvailable()

U_CAPI const char * ucal_getAvailable ( int32_t  localeIndex)

Get a locale for which calendars are available.

A UCalendar in a locale returned by this function will contain the correct day and month names for the locale.

Parameters
localeIndexThe index of the desired locale.
Returns
A locale for which calendars are available, or 0 if none.
See also
ucal_countAvailable
Stable:
ICU 2.0

◆ ucal_getCanonicalTimeZoneID()

U_CAPI int32_t ucal_getCanonicalTimeZoneID ( const UChar id,
int32_t  len,
UChar result,
int32_t  resultCapacity,
UBool isSystemID,
UErrorCode status 
)

Returns the canonical system timezone ID or the normalized custom time zone ID for the given time zone ID.

Parameters
idThe input timezone ID to be canonicalized.
lenThe length of id, or -1 if null-terminated.
resultThe buffer receives the canonical system timezone ID or the custom timezone ID in normalized format.
resultCapacityThe capacity of the result buffer.
isSystemIDReceives if the given ID is a known system timezone ID.
statusReceives the status. When the given timezone ID is neither a known system time zone ID nor a valid custom timezone ID, U_ILLEGAL_ARGUMENT_ERROR is set.
Returns
The result string length, not including the terminating null.
Stable:
ICU 4.0

◆ ucal_getDayOfWeekType()

U_CAPI UCalendarWeekdayType ucal_getDayOfWeekType ( const UCalendar cal,
UCalendarDaysOfWeek  dayOfWeek,
UErrorCode status 
)

Returns whether the given day of the week is a weekday, a weekend day, or a day that transitions from one to the other, for the locale and calendar system associated with this UCalendar (the locale's region is often the most determinant factor).

If a transition occurs at midnight, then the days before and after the transition will have the type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time other than midnight, then the day of the transition will have the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the function ucal_getWeekendTransition() will return the point of transition.

Parameters
calThe UCalendar to query.
dayOfWeekThe day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY).
statusThe error code for the operation.
Returns
The UCalendarWeekdayType for the day of the week.
Stable:
ICU 4.4

◆ ucal_getDefaultTimeZone()

U_CAPI int32_t ucal_getDefaultTimeZone ( UChar result,
int32_t  resultCapacity,
UErrorCode ec 
)

Return the default time zone.

The default is determined initially by querying the host operating system. If the host system detection routines fail, or if they specify a TimeZone or TimeZone offset which is not recognized, then the special TimeZone "Etc/Unknown" is returned.

The default may be changed with ucal_setDefaultTimeZone() or with the C++ TimeZone API, TimeZone::adoptDefault(TimeZone*).

Parameters
resultA buffer to receive the result, or NULL
resultCapacityThe capacity of the result buffer
ecinput/output error code
Returns
The result string length, not including the terminating null
See also
UCAL_UNKNOWN_ZONE_ID
Stable:
ICU 2.6

◆ ucal_getDSTSavings()

U_CAPI int32_t ucal_getDSTSavings ( const UChar zoneID,
UErrorCode ec 
)

Return the amount of time in milliseconds that the clock is advanced during daylight savings time for the given time zone, or zero if the time zone does not observe daylight savings time.

Parameters
zoneIDnull-terminated time zone ID
ecinput/output error code
Returns
the number of milliseconds the time is advanced with respect to standard time when the daylight savings rules are in effect. This is always a non-negative number, most commonly either 3,600,000 (one hour) or zero.
Stable:
ICU 2.6

◆ ucal_getFieldDifference()

U_CAPI int32_t ucal_getFieldDifference ( UCalendar cal,
UDate  target,
UCalendarDateFields  field,
UErrorCode status 
)

Return the difference between the target time and the time this calendar object is currently set to.

If the target time is after the current calendar setting, the the returned value will be positive. The field parameter specifies the units of the return value. For example, if field is UCAL_MONTH and ucal_getFieldDifference returns 3, then the target time is 3 to less than 4 months after the current calendar setting.

As a side effect of this call, this calendar is advanced toward target by the given amount. That is, calling this function has the side effect of calling ucal_add on this calendar with the specified field and an amount equal to the return value from this function.

A typical way of using this function is to call it first with the largest field of interest, then with progressively smaller fields.

Parameters
calThe UCalendar to compare and update.
targetThe target date to compare to the current calendar setting.
fieldThe field to compare; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
statusA pointer to an UErrorCode to receive any errors
Returns
The date difference for the specified field.
Stable:
ICU 4.8

◆ ucal_getGregorianChange()

U_CAPI UDate ucal_getGregorianChange ( const UCalendar cal,
UErrorCode pErrorCode 
)

Gets the Gregorian Calendar change date.

This is the point when the switch from Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October 15, 1582. Previous to this time and date will be Julian dates.

This function works only for Gregorian calendars. If the UCalendar is not an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR error code is set.

Parameters
calThe calendar object.
pErrorCodePointer to a standard ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)
Returns
The Gregorian cutover time for this calendar.
See also
GregorianCalendar::getGregorianChange
ucal_setGregorianChange
Stable:
ICU 3.6

◆ ucal_getHostTimeZone()

U_CAPI int32_t ucal_getHostTimeZone ( UChar result,
int32_t  resultCapacity,
UErrorCode ec 
)

Return the current host time zone.

The host time zone is detected from the current host system configuration by querying the host operating system. If the host system detection routines fail, or if they specify a TimeZone or TimeZone offset which is not recognized, then the special TimeZone "Etc/Unknown" is returned.

Note that host time zone and the ICU default time zone can be different.

The ICU default time zone does not change once initialized unless modified by calling ucal_setDefaultTimeZone() or with the C++ TimeZone API, TimeZone::adoptDefault(TimeZone*).

If the host operating system configuration has changed since ICU has initialized then the returned value can be different than the ICU default time zone, even if the default has not changed.

This function is not thread safe.

Parameters
resultA buffer to receive the result, or NULL
resultCapacityThe capacity of the result buffer
ecinput/output error code
Returns
The result string length, not including the terminating null
See also
UCAL_UNKNOWN_ZONE_ID
Stable:
ICU 65

◆ ucal_getIanaTimeZoneID()

U_CAPI int32_t ucal_getIanaTimeZoneID ( const UChar id,
int32_t  len,
UChar result,
int32_t  resultCapacity,
UErrorCode status 
)

Returns the preferred time zone ID in the IANA time zone database for the given time zone ID.

There are two types of preferred IDs. The first type is the one defined in zone.tab file, such as "America/Los_Angeles". The second types is the one defined for zones not associated with a specific region, but not defined with "Link" syntax such as "Etc/GMT+10".

Note: For most of valid time zone IDs, this method returns an ID same as ucal_getCanonicalTimeZoneID(). ucal_getCanonicalTimeZoneID() is based on canonical time zone IDs defined in Unicode CLDR. These canonical time zone IDs in CLDR were based on very old version of the time zone database. In the IANA time zone database, some IDs were updated since then. This API returns a newer time zone ID. For example, CLDR defines "Asia/Calcutta" as the canonical time zone ID. This method returns "Asia/Kolkata" instead.

"Etc/Unknown" is a special time zone ID defined by CLDR. There are no corresponding zones in the IANA time zone database. Therefore, this API returns U_ILLEGAL_ARGUMENT_ERROR when the input ID is "Etc/Unknown".

Parameters
idThe input time zone ID.
lenThe length of the input time zone ID.
resultThe buffer receives the preferred time zone ID in the IANA time zone database.
resultCapacityThe capacity of the result buffer.
statusReceives the status. When the given time zone ID is not a known system time zone ID, U_ILLEGAL_ARGUMENT_ERROR is set.
Returns
The result string length, not including the terminating null.
Stable:
ICU 74

◆ ucal_getKeywordValuesForLocale()

U_CAPI UEnumeration * ucal_getKeywordValuesForLocale ( const char *  key,
const char *  locale,
UBool  commonlyUsed,
UErrorCode status 
)

Given a key and a locale, returns an array of string values in a preferred order that would make a difference.

These are all and only those values where the open (creation) of the service with the locale formed from the input locale plus input keyword and that value has different behavior than creation with the input locale alone.

Parameters
keyone of the keys supported by this service. For now, only "calendar" is supported.
localethe locale
commonlyUsedif set to true it will return only commonly used values with the given locale in preferred order. Otherwise, it will return all the available values for the locale.
statuserror status
Returns
a string enumeration over keyword values for the given key and the locale.
Stable:
ICU 4.2

◆ ucal_getLimit()

U_CAPI int32_t ucal_getLimit ( const UCalendar cal,
UCalendarDateFields  field,
UCalendarLimitType  type,
UErrorCode status 
)

Determine a limit for a field in a UCalendar.

A limit is a maximum or minimum value for a field.

Parameters
calThe UCalendar to query.
fieldThe desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
typeThe desired critical point; one of UCAL_MINIMUM, UCAL_MAXIMUM, UCAL_GREATEST_MINIMUM, UCAL_LEAST_MAXIMUM, UCAL_ACTUAL_MINIMUM, UCAL_ACTUAL_MAXIMUM
statusA pointer to an UErrorCode to receive any errors.
Returns
The requested value.
Stable:
ICU 2.0

◆ ucal_getLocaleByType()

U_CAPI const char * ucal_getLocaleByType ( const UCalendar cal,
ULocDataLocaleType  type,
UErrorCode status 
)

Get the locale for this calendar object.

You can choose between valid and actual locale.

Parameters
calThe calendar object
typetype of the locale we're looking for (valid or actual)
statuserror code for the operation
Returns
the locale name
Stable:
ICU 2.8

◆ ucal_getMillis()

U_CAPI UDate ucal_getMillis ( const UCalendar cal,
UErrorCode status 
)

Get a UCalendar's current time in millis.

The time is represented as milliseconds from the epoch.

Parameters
calThe UCalendar to query.
statusA pointer to an UErrorCode to receive any errors
Returns
The calendar's current time in millis.
See also
ucal_setMillis
ucal_setDate
ucal_setDateTime
Stable:
ICU 2.0

◆ ucal_getNow()

U_CAPI UDate ucal_getNow ( void  )

Get the current date and time.

The value returned is represented as milliseconds from the epoch.

Returns
The current date and time.
Stable:
ICU 2.0

◆ ucal_getTimeZoneDisplayName()

U_CAPI int32_t ucal_getTimeZoneDisplayName ( const UCalendar cal,
UCalendarDisplayNameType  type,
const char *  locale,
UChar result,
int32_t  resultLength,
UErrorCode status 
)

Get the display name for a UCalendar's TimeZone.

A display name is suitable for presentation to a user.

Parameters
calThe UCalendar to query.
typeThe desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD, UCAL_DST, UCAL_SHORT_DST
localeThe desired locale for the display name.
resultA pointer to a buffer to receive the formatted number.
resultLengthThe maximum size of result.
statusA pointer to an UErrorCode to receive any errors
Returns
The total buffer size needed; if greater than resultLength, the output was truncated.
Stable:
ICU 2.0

◆ ucal_getTimeZoneID()

U_CAPI int32_t ucal_getTimeZoneID ( const UCalendar cal,
UChar result,
int32_t  resultLength,
UErrorCode status 
)

Get the ID of the UCalendar's time zone.

Parameters
calThe UCalendar to query.
resultReceives the UCalendar's time zone ID.
resultLengthThe maximum size of result.
statusReceives the status.
Returns
The total buffer size needed; if greater than resultLength, the output was truncated.
Stable:
ICU 51

◆ ucal_getTimeZoneIDForWindowsID()

U_CAPI int32_t ucal_getTimeZoneIDForWindowsID ( const UChar winid,
int32_t  len,
const char *  region,
UChar id,
int32_t  idCapacity,
UErrorCode status 
)

Converts a Windows time zone ID to an equivalent system time zone ID for a region.

For example, system time zone ID "America/Los_Angeles" is returned for input Windows ID "Pacific Standard Time" and region "US" (or null), "America/Vancouver" is returned for the same Windows ID "Pacific Standard Time" and region "CA".

Not all Windows time zones can be mapped to system time zones. When the input Windows time zone ID is unknown or unmappable to a system time zone, then this function returns 0 as the result length, but the operation itself remains successful (no error status set on return).

This implementation utilizes Zone-Tzid mapping data. The mapping data is updated time to time. To get the latest changes, please read the ICU user guide section Updating the Time Zone Data.

Parameters
winidA Windows time zone ID.
lenThe length of winid, or -1 if null-terminated.
regionA null-terminated region code, or NULL if no regional preference.
idA buffer to receive a system time zone ID.
idCapacityThe capacity of the result buffer id.
statusReceives the status.
Returns
The result string length, not including the terminating null.
See also
ucal_getWindowsTimeZoneID
Stable:
ICU 52

◆ ucal_getTimeZoneOffsetFromLocal()

U_CAPI void ucal_getTimeZoneOffsetFromLocal ( const UCalendar cal,
UTimeZoneLocalOption  nonExistingTimeOpt,
UTimeZoneLocalOption  duplicatedTimeOpt,
int32_t *  rawOffset,
int32_t *  dstOffset,
UErrorCode status 
)

Returns the time zone raw and GMT offset for the given moment in time.

Upon return, local-millis = GMT-millis + rawOffset + dstOffset. All computations are performed in the proleptic Gregorian calendar.

Parameters
calThe UCalendar which specify the local date and time value to query.
nonExistingTimeOptThe option to indicate how to interpret the date and time in the calendar represent a local time that skipped at a positive time zone transitions (e.g. when the daylight saving time starts or the time zone offset is increased due to a time zone rule change).
duplicatedTimeOptThe option to indicate how to interpret the date and time in the calendar represent a local time that repeating multiple times at a negative time zone transition (e.g. when the daylight saving time ends or the time zone offset is decreased due to a time zone rule change)
rawOffsetoutput parameter to receive the raw offset, that is, the offset not including DST adjustments. If the status is set to one of the error code, the value set is unspecified.
dstOffsetoutput parameter to receive the DST offset, that is, the offset to be added to ‘rawOffset’ to obtain the total offset between local and GMT time. If DST is not in effect, this value is zero; otherwise it is a positive value, typically one hour. If the status is set to one of the error code, the value set is unspecified.
statusA pointer to a UErrorCode to receive any errors.
Stable:
ICU 69

◆ ucal_getTimeZoneTransitionDate()

U_CAPI UBool ucal_getTimeZoneTransitionDate ( const UCalendar cal,
UTimeZoneTransitionType  type,
UDate transition,
UErrorCode status 
)

Get the UDate for the next/previous time zone transition relative to the calendar's current date, in the time zone to which the calendar is currently set.

If there is no known time zone transition of the requested type relative to the calendar's date, the function returns false.

Parameters
calThe UCalendar to query.
typeThe type of transition desired.
transitionA pointer to a UDate to be set to the transition time. If the function returns false, the value set is unspecified.
statusA pointer to a UErrorCode to receive any errors.
Returns
true if a valid transition time is set in *transition, false otherwise.
Stable:
ICU 50

◆ ucal_getType()

U_CAPI const char * ucal_getType ( const UCalendar cal,
UErrorCode status 
)

Get the resource keyword value string designating the calendar type for the UCalendar.

Parameters
calThe UCalendar to query.
statusThe error code for the operation.
Returns
The resource keyword value string.
Stable:
ICU 4.2

◆ ucal_getTZDataVersion()

U_CAPI const char * ucal_getTZDataVersion ( UErrorCode status)

Returns the timezone data version currently used by ICU.

Parameters
statuserror code for the operation
Returns
the version string, such as "2007f"
Stable:
ICU 3.8

◆ ucal_getWeekendTransition()

U_CAPI int32_t ucal_getWeekendTransition ( const UCalendar cal,
UCalendarDaysOfWeek  dayOfWeek,
UErrorCode status 
)

Returns the time during the day at which the weekend begins or ends in this calendar system.

If ucal_getDayOfWeekType() returns UCAL_WEEKEND_ONSET for the specified dayOfWeek, return the time at which the weekend begins. If ucal_getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek, return the time at which the weekend ends. If ucal_getDayOfWeekType() returns some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition (U_ILLEGAL_ARGUMENT_ERROR).

Parameters
calThe UCalendar to query.
dayOfWeekThe day of the week for which the weekend transition time is desired (UCAL_SUNDAY..UCAL_SATURDAY).
statusThe error code for the operation.
Returns
The milliseconds after midnight at which the weekend begins or ends.
Stable:
ICU 4.4

◆ ucal_getWindowsTimeZoneID()

U_CAPI int32_t ucal_getWindowsTimeZoneID ( const UChar id,
int32_t  len,
UChar winid,
int32_t  winidCapacity,
UErrorCode status 
)

Converts a system time zone ID to an equivalent Windows time zone ID.

For example, Windows time zone ID "Pacific Standard Time" is returned for input "America/Los_Angeles".

There are system time zones that cannot be mapped to Windows zones. When the input system time zone ID is unknown or unmappable to a Windows time zone, then this function returns 0 as the result length, but the operation itself remains successful (no error status set on return).

This implementation utilizes Zone-Tzid mapping data. The mapping data is updated time to time. To get the latest changes, please read the ICU user guide section Updating the Time Zone Data.

Parameters
idA system time zone ID.
lenThe length of id, or -1 if null-terminated.
winidA buffer to receive a Windows time zone ID.
winidCapacityThe capacity of the result buffer winid.
statusReceives the status.
Returns
The result string length, not including the terminating null.
See also
ucal_getTimeZoneIDForWindowsID
Stable:
ICU 52

◆ ucal_inDaylightTime()

U_CAPI UBool ucal_inDaylightTime ( const UCalendar cal,
UErrorCode status 
)

Determine if a UCalendar is currently in daylight savings time.

Daylight savings time is not used in all parts of the world.

Parameters
calThe UCalendar to query.
statusA pointer to an UErrorCode to receive any errors
Returns
true if cal is currently in daylight savings time, false otherwise
Stable:
ICU 2.0

◆ ucal_isSet()

U_CAPI UBool ucal_isSet ( const UCalendar cal,
UCalendarDateFields  field 
)

Determine if a field in a UCalendar is set.

All fields are represented as 32-bit integers.

Parameters
calThe UCalendar to query.
fieldThe desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
Returns
true if field is set, false otherwise.
See also
ucal_get
ucal_set
ucal_clearField
ucal_clear
Stable:
ICU 2.0

◆ ucal_isWeekend()

U_CAPI UBool ucal_isWeekend ( const UCalendar cal,
UDate  date,
UErrorCode status 
)

Returns true if the given UDate is in the weekend in this calendar system.

Parameters
calThe UCalendar to query.
dateThe UDate in question.
statusThe error code for the operation.
Returns
true if the given UDate is in the weekend in this calendar system, false otherwise.
Stable:
ICU 4.4

◆ ucal_open()

U_CAPI UCalendar * ucal_open ( const UChar zoneID,
int32_t  len,
const char *  locale,
UCalendarType  type,
UErrorCode status 
)

Open a UCalendar.

A UCalendar may be used to convert a millisecond value to a year, month, and day.

Note: When unknown TimeZone ID is specified or if the TimeZone ID specified is "Etc/Unknown", the UCalendar returned by the function is initialized with GMT zone with TimeZone ID UCAL_UNKNOWN_ZONE_ID ("Etc/Unknown") without any errors/warnings. If you want to check if a TimeZone ID is valid prior to this function, use ucal_getCanonicalTimeZoneID.

Parameters
zoneIDThe desired TimeZone ID. If 0, use the default time zone.
lenThe length of zoneID, or -1 if null-terminated.
localeThe desired locale
typeThe type of UCalendar to open. This can be UCAL_GREGORIAN to open the Gregorian calendar for the locale, or UCAL_DEFAULT to open the default calendar for the locale (the default calendar may also be Gregorian). To open a specific non-Gregorian calendar for the locale, use uloc_setKeywordValue to set the value of the calendar keyword for the locale and then pass the locale to ucal_open with UCAL_DEFAULT as the type.
statusA pointer to an UErrorCode to receive any errors
Returns
A pointer to a UCalendar, or 0 if an error occurred.
See also
UCAL_UNKNOWN_ZONE_ID
Stable:
ICU 2.0

◆ ucal_openCountryTimeZones()

U_CAPI UEnumeration * ucal_openCountryTimeZones ( const char *  country,
UErrorCode ec 
)

Create an enumeration over all time zones associated with the given country.

Some zones are affiliated with no country (e.g., "UTC"); these may also be retrieved, as a group.

Parameters
countrythe ISO 3166 two-letter country code, or NULL to retrieve zones not affiliated with any country
ecinput/output error code
Returns
an enumeration object that the caller must dispose of using uenum_close(), or NULL upon failure. In case of failure *ec will indicate the error.
Stable:
ICU 2.6

◆ ucal_openTimeZoneIDEnumeration()

U_CAPI UEnumeration * ucal_openTimeZoneIDEnumeration ( USystemTimeZoneType  zoneType,
const char *  region,
const int32_t *  rawOffset,
UErrorCode ec 
)

Create an enumeration over system time zone IDs with the given filter conditions.

Parameters
zoneTypeThe system time zone type.
regionThe ISO 3166 two-letter country code or UN M.49 three-digit area code. When NULL, no filtering done by region.
rawOffsetAn offset from GMT in milliseconds, ignoring the effect of daylight savings time, if any. When NULL, no filtering done by zone offset.
ecA pointer to an UErrorCode to receive any errors
Returns
an enumeration object that the caller must dispose of using enum_close(), or NULL upon failure. In case of failure, *ec will indicate the error.
Stable:
ICU 4.8

◆ ucal_openTimeZones()

U_CAPI UEnumeration * ucal_openTimeZones ( UErrorCode ec)

Create an enumeration over all time zones.

Parameters
ecinput/output error code
Returns
an enumeration object that the caller must dispose of using uenum_close(), or NULL upon failure. In case of failure *ec will indicate the error.
Stable:
ICU 2.6

◆ ucal_roll()

U_CAPI void ucal_roll ( UCalendar cal,
UCalendarDateFields  field,
int32_t  amount,
UErrorCode status 
)

Add a specified signed amount to a particular field in a UCalendar.

This will not modify more significant fields in the calendar. Rolling by a positive value always means moving forward in time (unless the limit of the field is reached, in which case it may pin or wrap), so for Gregorian calendar, starting with 100 BC and rolling the year by +1 results in 99 BC. When eras have a definite beginning and end (as in the Chinese calendar, or as in most eras in the Japanese calendar) then rolling the year past either limit of the era will cause the year to wrap around. When eras only have a limit at one end, then attempting to roll the year past that limit will result in pinning the year at that limit. Note that for most calendars in which era 0 years move forward in time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to result in negative years for era 0 (that is the only way to represent years before the calendar epoch).

Parameters
calThe UCalendar to which to add.
fieldThe field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
amountThe signed amount to add to field. If the amount causes the value to exceed to maximum or minimum values for that field, the field is pinned to a permissible value.
statusA pointer to an UErrorCode to receive any errors
See also
ucal_add
Stable:
ICU 2.0

◆ ucal_set()

U_CAPI void ucal_set ( UCalendar cal,
UCalendarDateFields  field,
int32_t  value 
)

Set the value of a field in a UCalendar.

All fields are represented as 32-bit integers.

Parameters
calThe UCalendar to set.
fieldThe field to set; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET.
valueThe desired value of field.
See also
ucal_get
ucal_isSet
ucal_clearField
ucal_clear
Stable:
ICU 2.0

◆ ucal_setAttribute()

U_CAPI void ucal_setAttribute ( UCalendar cal,
UCalendarAttribute  attr,
int32_t  newValue 
)

Set a numeric attribute associated with a UCalendar.

Numeric attributes include the first day of the week, or the minimal numbers of days in the first week of the month.

Parameters
calThe UCalendar to set.
attrThe desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, UCAL_REPEATED_WALL_TIME or UCAL_SKIPPED_WALL_TIME
newValueThe new value of attr.
See also
ucal_getAttribute
Stable:
ICU 2.0

◆ ucal_setDate()

U_CAPI void ucal_setDate ( UCalendar cal,
int32_t  year,
int32_t  month,
int32_t  date,
UErrorCode status 
)

Set a UCalendar's current date.

The date is represented as a series of 32-bit integers.

Parameters
calThe UCalendar to set.
yearThe desired year.
monthThe desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY, UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER
dateThe desired day of the month.
statusA pointer to an UErrorCode to receive any errors
See also
ucal_getMillis
ucal_setMillis
ucal_setDateTime
Stable:
ICU 2.0

◆ ucal_setDateTime()

U_CAPI void ucal_setDateTime ( UCalendar cal,
int32_t  year,
int32_t  month,
int32_t  date,
int32_t  hour,
int32_t  minute,
int32_t  second,
UErrorCode status 
)

Set a UCalendar's current date.

The date is represented as a series of 32-bit integers.

Parameters
calThe UCalendar to set.
yearThe desired year.
monthThe desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY, UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER
dateThe desired day of the month.
hourThe desired hour of day.
minuteThe desired minute.
secondThe desirec second.
statusA pointer to an UErrorCode to receive any errors
See also
ucal_getMillis
ucal_setMillis
ucal_setDate
Stable:
ICU 2.0

◆ ucal_setDefaultTimeZone()

U_CAPI void ucal_setDefaultTimeZone ( const UChar zoneID,
UErrorCode ec 
)

Set the default time zone.

Parameters
zoneIDnull-terminated time zone ID
ecinput/output error code
Stable:
ICU 2.6

◆ ucal_setGregorianChange()

U_CAPI void ucal_setGregorianChange ( UCalendar cal,
UDate  date,
UErrorCode pErrorCode 
)

Sets the GregorianCalendar change date.

This is the point when the switch from Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October 15, 1582. Previous to this time and date will be Julian dates.

This function works only for Gregorian calendars. If the UCalendar is not an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR error code is set.

Parameters
calThe calendar object.
dateThe given Gregorian cutover date.
pErrorCodePointer to a standard ICU error code. Its input value must pass the U_SUCCESS() test, or else the function returns immediately. Check for U_FAILURE() on output or use with function chaining. (See User Guide for details.)
See also
GregorianCalendar::setGregorianChange
ucal_getGregorianChange
Stable:
ICU 3.6

◆ ucal_setMillis()

U_CAPI void ucal_setMillis ( UCalendar cal,
UDate  dateTime,
UErrorCode status 
)

Set a UCalendar's current time in millis.

The time is represented as milliseconds from the epoch.

Parameters
calThe UCalendar to set.
dateTimeThe desired date and time.
statusA pointer to an UErrorCode to receive any errors
See also
ucal_getMillis
ucal_setDate
ucal_setDateTime
Stable:
ICU 2.0

◆ ucal_setTimeZone()

U_CAPI void ucal_setTimeZone ( UCalendar cal,
const UChar zoneID,
int32_t  len,
UErrorCode status 
)

Set the TimeZone used by a UCalendar.

A UCalendar uses a timezone for converting from Greenwich time to local time.

Parameters
calThe UCalendar to set.
zoneIDThe desired TimeZone ID. If 0, use the default time zone.
lenThe length of zoneID, or -1 if null-terminated.
statusA pointer to an UErrorCode to receive any errors.
Stable:
ICU 2.0