webkit
2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
|
#include "unicode/utypes.h"
#include "unicode/uenum.h"
#include "unicode/uloc.h"
#include "unicode/localpointer.h"
Go to the source code of this file.
Macros | |
#define | UCAL_UNKNOWN_ZONE_ID "Etc/Unknown" |
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_STABLE 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.
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.
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:
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
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
.
ICU 2.0
#define UCAL_UNKNOWN_ZONE_ID "Etc/Unknown" |
The time zone ID reserved for unknown time zone. ICU 4.8
ICU 2.0
ICU 2.0
ICU 2.0
Types of UCalendar attributes ICU 2.0
Enumerator | |
---|---|
UCAL_LENIENT | Lenient parsing ICU 2.0 |
UCAL_FIRST_DAY_OF_WEEK | First day of week ICU 2.0 |
UCAL_MINIMAL_DAYS_IN_FIRST_WEEK | Minimum number of days in first week ICU 2.0 |
UCAL_REPEATED_WALL_TIME | The behavior for handling wall time repeating multiple times at negative time zone offset transitions ICU 49 |
UCAL_SKIPPED_WALL_TIME | The behavior for handling skipped wall time at positive time zone offset transitions. ICU 49 |
Possible fields in a UCalendar 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. ICU 2.6 |
UCAL_YEAR | Field number indicating the year. This is a calendar-specific value. ICU 2.6 |
UCAL_MONTH | Field number indicating the month. This is a calendar-specific value. The first month of the year is |
UCAL_WEEK_OF_YEAR | Field number indicating the week number within the current year. The first week of the year, as defined by
|
UCAL_WEEK_OF_MONTH | Field number indicating the week number within the current month. The first week of the month, as defined by |
UCAL_DATE | Field number indicating the day of the month. This is a synonym for
|
UCAL_DAY_OF_YEAR | Field number indicating the day number within the current year. The first day of the year has value 1. ICU 2.6 |
UCAL_DAY_OF_WEEK | Field number indicating the day of the week. This field takes values
|
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
|
UCAL_AM_PM | Field number indicating whether the |
UCAL_HOUR | Field number indicating the hour of the morning or afternoon.
|
UCAL_HOUR_OF_DAY | Field number indicating the hour of the day.
|
UCAL_MINUTE | Field number indicating the minute within the hour. E.g., at 10:04:15.250 PM the |
UCAL_SECOND | Field number indicating the second within the minute. E.g., at 10:04:15.250 PM the |
UCAL_MILLISECOND | Field number indicating the millisecond within the second. E.g., at 10:04:15.250 PM the |
UCAL_ZONE_OFFSET | Field number indicating the raw offset from GMT in milliseconds. ICU 2.6 |
UCAL_DST_OFFSET | Field number indicating the daylight savings offset in milliseconds. ICU 2.6 |
UCAL_YEAR_WOY | Field number indicating the extended year corresponding to the |
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. 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. 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. 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. 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_FIELD_COUNT | Field count ICU 2.6 |
UCAL_DAY_OF_MONTH | Field number indicating the day of the month. This is a synonym for |
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 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 |
Possible months in a UCalendar. Note: Calendar month is 0-based. ICU 2.0
Possible types of UCalendars 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. ICU 2.0 |
UCAL_DEFAULT | A better name for UCAL_TRADITIONAL. ICU 4.2 |
UCAL_GREGORIAN | Unambiguously designates the Gregorian calendar for the locale. ICU 2.0 |
Options for handling ambiguous wall time at time zone offset transitions. ICU 49
Weekday types, as returned by ucal_getDayOfWeekType(). ICU 4.4
Enumerator | |
---|---|
UCAL_WEEKDAY | Designates a full weekday (no part of the day is included in the weekend). ICU 4.4 |
UCAL_WEEKEND | Designates a full weekend day (the entire day is included in the weekend). 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. 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. ICU 4.4 |
System time zone type constants used by filtering zones in ucal_openTimeZoneIDEnumeration.
Time zone transition types for ucal_getTimeZoneTransitionDate ICU 50
U_STABLE 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. 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).
cal | The UCalendar to which to add. |
field | The 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. |
amount | The 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. |
status | A pointer to an UErrorCode to receive any errors |
Clear all fields in a UCalendar. All fields are represented as 32-bit integers.
calendar | The UCalendar to clear. |
U_STABLE void U_EXPORT2 ucal_clearField | ( | UCalendar * | cal, |
UCalendarDateFields | field | ||
) |
Clear a field in a UCalendar. All fields are represented as 32-bit integers.
cal | The UCalendar containing the field to clear. |
field | The 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. |
U_STABLE UCalendar* U_EXPORT2 ucal_clone | ( | const UCalendar * | cal, |
UErrorCode * | status | ||
) |
Close a UCalendar. Once closed, a UCalendar may no longer be used.
cal | The UCalendar to close. ICU 2.0 |
Determine how many locales have calendars available. This function is most useful as determining the loop ending condition for calls to ucal_getAvailable.
Returns TRUE if two UCalendars are equivalent. Equivalent UCalendars will behave identically, but they may be set to different times.
U_STABLE int32_t U_EXPORT2 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.
cal | The UCalendar to query. |
field | The 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. |
status | A pointer to an UErrorCode to receive any errors |
U_STABLE int32_t U_EXPORT2 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.
cal | The UCalendar to query. |
attr | The 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 |
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.
localeIndex | The index of the desired locale. |
U_STABLE int32_t U_EXPORT2 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.
id | The input timezone ID to be canonicalized. |
len | The length of id, or -1 if null-terminated. |
result | The buffer receives the canonical system timezone ID or the custom timezone ID in normalized format. |
resultCapacity | The capacity of the result buffer. |
isSystemID | Receives if the given ID is a known system timezone ID. |
status | Recevies 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. |
U_STABLE UCalendarWeekdayType U_EXPORT2 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.
cal | The UCalendar to query. |
dayOfWeek | The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY). |
status | The error code for the operation. |
U_STABLE int32_t U_EXPORT2 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. It may be changed with ucal_setDefaultTimeZone() or with the C++ TimeZone API.
result | A buffer to receive the result, or NULL |
resultCapacity | The capacity of the result buffer |
ec | input/output error code |
ICU 2.6
U_STABLE int32_t U_EXPORT2 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.
zoneID | null-terminated time zone ID |
ec | input/output error code |
ICU 2.6
U_STABLE int32_t U_EXPORT2 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.
cal | The UCalendar to compare and update. |
target | The target date to compare to the current calendar setting. |
field | The 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. |
status | A pointer to an UErrorCode to receive any errors |
U_STABLE UDate U_EXPORT2 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.
cal | The calendar object. |
pErrorCode | Pointer 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.) |
U_STABLE UEnumeration* U_EXPORT2 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.
key | one of the keys supported by this service. For now, only "calendar" is supported. |
locale | the locale |
commonlyUsed | if 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. |
status | error status |
U_STABLE int32_t U_EXPORT2 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.
cal | The UCalendar to query. |
field | The 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. |
type | The desired critical point; one of UCAL_MINIMUM, UCAL_MAXIMUM, UCAL_GREATEST_MINIMUM, UCAL_LEAST_MAXIMUM, UCAL_ACTUAL_MINIMUM, UCAL_ACTUAL_MAXIMUM |
status | A pointer to an UErrorCode to receive any errors. |
U_STABLE const char* U_EXPORT2 ucal_getLocaleByType | ( | const UCalendar * | cal, |
ULocDataLocaleType | type, | ||
UErrorCode * | status | ||
) |
Get the locale for this calendar object. You can choose between valid and actual locale.
cal | The calendar object |
type | type of the locale we're looking for (valid or actual) |
status | error code for the operation |
U_STABLE UDate U_EXPORT2 ucal_getMillis | ( | const UCalendar * | cal, |
UErrorCode * | status | ||
) |
Get a UCalendar's current time in millis. The time is represented as milliseconds from the epoch.
U_STABLE 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. A display name is suitable for presentation to a user.
cal | The UCalendar to query. |
type | The desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD, UCAL_DST, UCAL_SHORT_DST |
locale | The desired locale for the display name. |
result | A pointer to a buffer to receive the formatted number. |
resultLength | The maximum size of result. |
status | A pointer to an UErrorCode to receive any errors |
U_DRAFT int32_t U_EXPORT2 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.
winid | A Windows time zone ID. |
len | The length of winid , or -1 if null-terminated. |
region | A null-terminated region code, or NULL if no regional preference. |
id | A buffer to receive a system time zone ID. |
idCapacity | The capacity of the result buffer id . |
status | Receives the status. |
ICU 52
U_DRAFT UBool U_EXPORT2 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.
cal | The UCalendar to query. |
type | The type of transition desired. |
transition | A pointer to a UDate to be set to the transition time. If the function returns FALSE, the value set is unspecified. |
status | A pointer to a UErrorCode to receive any errors. |
U_STABLE const char* U_EXPORT2 ucal_getType | ( | const UCalendar * | cal, |
UErrorCode * | status | ||
) |
U_STABLE const char* U_EXPORT2 ucal_getTZDataVersion | ( | UErrorCode * | status | ) |
Returns the timezone data version currently used by ICU.
status | error code for the operation |
U_STABLE int32_t U_EXPORT2 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).
cal | The UCalendar to query. |
dayOfWeek | The day of the week for which the weekend transition time is desired (UCAL_SUNDAY..UCAL_SATURDAY). |
status | The error code for the operation. |
U_DRAFT int32_t U_EXPORT2 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.
id | A system time zone ID. |
len | The length of id , or -1 if null-terminated. |
winid | A buffer to receive a Windows time zone ID. |
winidCapacity | The capacity of the result buffer winid . |
status | Receives the status. |
ICU 52
U_STABLE UBool U_EXPORT2 ucal_inDaylightTime | ( | const UCalendar * | cal, |
UErrorCode * | status | ||
) |
U_STABLE UBool U_EXPORT2 ucal_isSet | ( | const UCalendar * | cal, |
UCalendarDateFields | field | ||
) |
Determine if a field in a UCalendar is set. All fields are represented as 32-bit integers.
cal | The UCalendar to query. |
field | The 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. |
U_STABLE UCalendar* U_EXPORT2 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
.
zoneID | The desired TimeZone ID. If 0, use the default time zone. |
len | The length of zoneID, or -1 if null-terminated. |
locale | The desired locale |
type | The 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. |
status | A pointer to an UErrorCode to receive any errors |
U_STABLE UEnumeration* U_EXPORT2 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.
country | the ISO 3166 two-letter country code, or NULL to retrieve zones not affiliated with any country |
ec | input/output error code |
ICU 2.6
U_STABLE UEnumeration* U_EXPORT2 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.
zoneType | The system time zone type. |
region | The ISO 3166 two-letter country code or UN M.49 three-digit area code. When NULL, no filtering done by region. |
rawOffset | An offset from GMT in milliseconds, ignoring the effect of daylight savings time, if any. When NULL, no filtering done by zone offset. |
ec | A pointer to an UErrorCode to receive any errors |
U_STABLE UEnumeration* U_EXPORT2 ucal_openTimeZones | ( | UErrorCode * | ec | ) |
Create an enumeration over all time zones.
ec | input/output error code |
ICU 2.6
U_STABLE 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. 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).
cal | The UCalendar to which to add. |
field | The 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. |
amount | The 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. |
status | A pointer to an UErrorCode to receive any errors |
Set the value of a field in a UCalendar. All fields are represented as 32-bit integers.
cal | The UCalendar to set. |
field | The 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. |
value | The desired value of field. |
U_STABLE void U_EXPORT2 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.
cal | The UCalendar to set. |
attr | The 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 |
newValue | The new value of attr. |
U_STABLE void U_EXPORT2 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.
cal | The UCalendar to set. |
year | The desired year. |
month | The 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 |
date | The desired day of the month. |
status | A pointer to an UErrorCode to receive any errors |
U_STABLE 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. The date is represented as a series of 32-bit integers.
cal | The UCalendar to set. |
year | The desired year. |
month | The 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 |
date | The desired day of the month. |
hour | The desired hour of day. |
minute | The desired minute. |
second | The desirec second. |
status | A pointer to an UErrorCode to receive any errors |
U_STABLE void U_EXPORT2 ucal_setDefaultTimeZone | ( | const UChar * | zoneID, |
UErrorCode * | ec | ||
) |
Set the default time zone.
zoneID | null-terminated time zone ID |
ec | input/output error code |
ICU 2.6
U_STABLE void U_EXPORT2 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.
cal | The calendar object. |
date | The given Gregorian cutover date. |
pErrorCode | Pointer 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.) |
Set a UCalendar's current time in millis. The time is represented as milliseconds from the epoch.
cal | The UCalendar to set. |
dateTime | The desired date and time. |
status | A pointer to an UErrorCode to receive any errors |