#include "unicode/utypes.h"
Go to the source code of this file.
Typedefs | |
typedef void * | UCalendar |
A calendar. More... | |
typedef enum UCalendarType | UCalendarType |
@stable. | |
typedef enum UCalendarDateFields | UCalendarDateFields |
@stable. | |
typedef enum UCalendarDaysOfWeek | UCalendarDaysOfWeek |
@stable. | |
typedef enum UCalendarMonths | UCalendarMonths |
@stable. | |
typedef enum UCalendarAMPMs | UCalendarAMPMs |
@stable. | |
typedef enum UCalendarDisplayNameType | UCalendarDisplayNameType |
@stable. | |
typedef enum UCalendarAttribute | UCalendarAttribute |
@stable. | |
typedef enum UCalendarLimitType | UCalendarLimitType |
@stable. | |
Enumerations | |
enum | UCalendarType { UCAL_TRADITIONAL, UCAL_GREGORIAN } |
Possible types of UCalendars @stable. 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_FIELD_COUNT } |
Possible fields in a UCalendar @stable. More... | |
enum | UCalendarDaysOfWeek { UCAL_SUNDAY = 1, UCAL_MONDAY, UCAL_TUESDAY, UCAL_WEDNESDAY, UCAL_THURSDAY, UCAL_FRIDAY, UCAL_SATURDAY } |
Possible days of the week in a UCalendar @stable. 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 @stable. More... | |
enum | UCalendarDisplayNameType { UCAL_STANDARD, UCAL_SHORT_STANDARD, UCAL_DST, UCAL_SHORT_DST } |
Possible formats for a UCalendar's display name @stable. More... | |
enum | UCalendarAttribute { UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK } |
Types of UCalendar attributes @stable. 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 @stable. More... | |
Functions | |
U_CAPI const UChar *U_EXPORT2 | ucal_getAvailableTZIDs (int32_t rawOffset, int32_t index, UErrorCode *status) |
Get an available TimeZone ID. More... | |
U_CAPI int32_t U_EXPORT2 | ucal_countAvailableTZIDs (int32_t rawOffset) |
Determine how many TimeZones exist with a certain offset. More... | |
U_CAPI UDate U_EXPORT2 | ucal_getNow (void) |
Get the current date and time. More... | |
U_CAPI UCalendar *U_EXPORT2 | ucal_open (const UChar *zoneID, int32_t len, const char *locale, UCalendarType type, UErrorCode *status) |
Open a UCalendar. More... | |
U_CAPI void U_EXPORT2 | ucal_close (UCalendar *cal) |
Close a UCalendar. More... | |
U_CAPI void U_EXPORT2 | ucal_setTimeZone (UCalendar *cal, const UChar *zoneID, int32_t len, UErrorCode *status) |
Set the TimeZone used by a UCalendar. More... | |
U_CAPI int32_t U_EXPORT2 | 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. More... | |
U_CAPI UBool U_EXPORT2 | ucal_inDaylightTime (const UCalendar *cal, UErrorCode *status) |
Determine if a UCalendar is currently in daylight savings time. More... | |
U_CAPI int32_t U_EXPORT2 | ucal_getAttribute (const UCalendar *cal, UCalendarAttribute attr) |
Get a numeric attribute associated with a UCalendar. More... | |
U_CAPI void U_EXPORT2 | ucal_setAttribute (UCalendar *cal, UCalendarAttribute attr, int32_t newValue) |
Set a numeric attribute associated with a UCalendar. More... | |
U_CAPI const char *U_EXPORT2 | ucal_getAvailable (int32_t index) |
Get a locale for which calendars are available. More... | |
U_CAPI int32_t U_EXPORT2 | ucal_countAvailable (void) |
Determine how many locales have calendars available. More... | |
U_CAPI UDate U_EXPORT2 | ucal_getMillis (const UCalendar *cal, UErrorCode *status) |
Get a UCalendar's current time in millis. More... | |
U_CAPI void U_EXPORT2 | ucal_setMillis (UCalendar *cal, UDate dateTime, UErrorCode *status) |
Set a UCalendar's current time in millis. More... | |
U_CAPI void U_EXPORT2 | ucal_setDate (UCalendar *cal, int32_t year, int32_t month, int32_t date, UErrorCode *status) |
Set a UCalendar's current date. More... | |
U_CAPI void U_EXPORT2 | 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. More... | |
U_CAPI UBool U_EXPORT2 | ucal_equivalentTo (const UCalendar *cal1, const UCalendar *cal2) |
Determine if two UCalendars represent the same date. More... | |
U_CAPI void U_EXPORT2 | ucal_add (UCalendar *cal, UCalendarDateFields field, int32_t amount, UErrorCode *status) |
Add a specified signed amount to a particular field in a UCalendar. More... | |
U_CAPI void U_EXPORT2 | ucal_roll (UCalendar *cal, UCalendarDateFields field, int32_t amount, UErrorCode *status) |
Add a specified signed amount to a particular field in a UCalendar. More... | |
U_CAPI int32_t U_EXPORT2 | ucal_get (const UCalendar *cal, UCalendarDateFields field, UErrorCode *status) |
Get the current value of a field from a UCalendar. More... | |
U_CAPI void U_EXPORT2 | ucal_set (UCalendar *cal, UCalendarDateFields field, int32_t value) |
Set the value of a field in a UCalendar. More... | |
U_CAPI UBool U_EXPORT2 | ucal_isSet (const UCalendar *cal, UCalendarDateFields field) |
Determine if a field in a UCalendar is set. More... | |
U_CAPI void U_EXPORT2 | ucal_clearField (UCalendar *cal, UCalendarDateFields field) |
Clear a field in a UCalendar. More... | |
U_CAPI void U_EXPORT2 | ucal_clear (UCalendar *calendar) |
Clear all fields in a UCalendar. More... | |
U_CAPI int32_t U_EXPORT2 | ucal_getLimit (const UCalendar *cal, UCalendarDateFields field, UCalendarLimitType type, UErrorCode *status) |
Determine a limit for a field in a UCalendar. More... |
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 U_CAPI 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);
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_MONTH + UCAL_DAY_OF_MONTH UCAL_MONTH + UCAL_WEEK_OF_MONTH + UCAL_DAY_OF_WEEK UCAL_MONTH + UCAL_DAY_OF_WEEK_IN_MONTH + UCAL_DAY_OF_WEEK UCAL_DAY_OF_YEAR UCAL_DAY_OF_WEEK + UCAL_WEEK_OF_YEAR
For the time of day:
Note: for some non-Gregorian calendars, different fields may be necessary for complete disambiguation. For example, a full specification of the historial 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:
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 UDateFormat 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
.
@stable
|
A calendar. For usage in C programs. @stable |
|
Possible AM/PM values in a UCalendar @stable.
|
|
Types of UCalendar attributes @stable.
|
|
|
Possible days of the week in a UCalendar @stable.
|
|
Possible formats for a UCalendar's display name @stable.
|
|
Possible limit values for a UCalendar @stable.
|
|
Possible months in a UCalendar. Note: Calendar month is 0-based. @stable |
|
Possible types of UCalendars @stable.
|
|
Add a specified signed amount to a particular field in a UCalendar. This can modify more significant fields in the calendar.
|
|
Clear all fields in a UCalendar. All fields are represented as 32-bit integers.
|
|
Clear a field in a UCalendar. All fields are represented as 32-bit integers.
|
|
Close a UCalendar. Once closed, a UCalendar may no longer be used.
|
|
Determine how many locales have calendars available. This function is most useful as determining the loop ending condition for calls to \Ref{ucal_getAvailable}.
|
|
Determine how many TimeZones exist with a certain offset. This function is most useful as determining the loop ending condition for calls to \Ref{ucal_getAvailableTZIDs}.
|
|
Determine if two UCalendars represent the same date. Two UCalendars may represent the same date and have different fields if they are in different time zones.
|
|
Get the current value of a field from a UCalendar. All fields are represented as 32-bit integers.
|
|
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.
|
|
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.
|
|
Get an available TimeZone ID. A Timezone ID is a string of the form "America/Los Angeles".
|
|
Determine a limit for a field in a UCalendar. A limit is a maximum or minimum value for a field.
|
|
Get a UCalendar's current time in millis. The time is represented as milliseconds from the epoch.
|
|
Get the current date and time. The value returned is represented as milliseconds from the epoch.
|
|
Get the display name for a UCalendar's TimeZone. A display name is suitable for presentation to a user.
|
|
Determine if a UCalendar is currently in daylight savings time. Daylight savings time is not used in all parts of the world.
|
|
Determine if a field in a UCalendar is set. All fields are represented as 32-bit integers.
|
|
Open a UCalendar. A UCalendar may be used to convert a millisecond value to a year, month, and day.
|
|
Add a specified signed amount to a particular field in a UCalendar. This will not modify more significant fields in the calendar.
|
|
Set the value of a field in a UCalendar. All fields are represented as 32-bit integers.
|
|
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.
|
|
Set a UCalendar's current date. The date is represented as a series of 32-bit integers.
|
|
Set a UCalendar's current date. The date is represented as a series of 32-bit integers.
|
|
Set a UCalendar's current time in millis. The time is represented as milliseconds from the epoch.
|
|
Set the TimeZone used by a UCalendar. A UCalendar uses a timezone for converting from Greenwich time to local time.
|