ICU 50.2 50.2
ucal.h
Go to the documentation of this file.
1/*
2 *******************************************************************************
3 * Copyright (C) 1996-2012, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 *******************************************************************************
6 */
7
8#ifndef UCAL_H
9#define UCAL_H
10
11#include "unicode/utypes.h"
12#include "unicode/uenum.h"
13#include "unicode/uloc.h"
15
16#if !UCONFIG_NO_FORMATTING
17
142
147#define UCAL_UNKNOWN_ZONE_ID "Etc/Unknown"
148
153typedef void* UCalendar;
154
176
179
442
469
472
507
510
520
523
547
550
567U_STABLE UEnumeration* U_EXPORT2
569 const int32_t* rawOffset, UErrorCode* ec);
570
582U_STABLE UEnumeration* U_EXPORT2
584
601U_STABLE UEnumeration* U_EXPORT2
602ucal_openCountryTimeZones(const char* country, UErrorCode* ec);
603
620U_STABLE int32_t U_EXPORT2
621ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec);
622
632U_STABLE void U_EXPORT2
634
651U_STABLE int32_t U_EXPORT2
653
660U_STABLE UDate U_EXPORT2
662
686U_STABLE UCalendar* U_EXPORT2
687ucal_open(const UChar* zoneID,
688 int32_t len,
689 const char* locale,
690 UCalendarType type,
691 UErrorCode* status);
692
699U_STABLE void U_EXPORT2
701
702#if U_SHOW_CPLUSPLUS_API
703
705
716
718
719#endif
720
729U_STABLE UCalendar* U_EXPORT2
731 UErrorCode* status);
732
742U_STABLE void U_EXPORT2
744 const UChar* zoneID,
745 int32_t len,
746 UErrorCode* status);
747
762
765
779U_STABLE int32_t U_EXPORT2
782 const char* locale,
783 UChar* result,
784 int32_t resultLength,
785 UErrorCode* status);
786
795U_STABLE UBool U_EXPORT2
797 UErrorCode* status );
798
819U_STABLE void U_EXPORT2
821
842U_STABLE UDate U_EXPORT2
844
881
884
898#ifndef U_HIDE_DRAFT_API
899 ,
913#endif /* U_HIDE_DRAFT_API */
914};
915
917
929U_STABLE int32_t U_EXPORT2
931 UCalendarAttribute attr);
932
944U_STABLE void U_EXPORT2
947 int32_t newValue);
948
958U_STABLE const char* U_EXPORT2
959ucal_getAvailable(int32_t localeIndex);
960
969U_STABLE int32_t U_EXPORT2
971
983U_STABLE UDate U_EXPORT2
985 UErrorCode* status);
986
998U_STABLE void U_EXPORT2
1000 UDate dateTime,
1001 UErrorCode* status );
1002
1017U_STABLE void U_EXPORT2
1019 int32_t year,
1020 int32_t month,
1021 int32_t date,
1022 UErrorCode* status);
1023
1041U_STABLE void U_EXPORT2
1043 int32_t year,
1044 int32_t month,
1045 int32_t date,
1046 int32_t hour,
1047 int32_t minute,
1048 int32_t second,
1049 UErrorCode* status);
1050
1060U_STABLE UBool U_EXPORT2
1062 const UCalendar* cal2);
1063
1082U_STABLE void U_EXPORT2
1084 UCalendarDateFields field,
1085 int32_t amount,
1086 UErrorCode* status);
1087
1112U_STABLE void U_EXPORT2
1114 UCalendarDateFields field,
1115 int32_t amount,
1116 UErrorCode* status);
1117
1134U_STABLE int32_t U_EXPORT2
1136 UCalendarDateFields field,
1137 UErrorCode* status );
1138
1154U_STABLE void U_EXPORT2
1156 UCalendarDateFields field,
1157 int32_t value);
1158
1174U_STABLE UBool U_EXPORT2
1176 UCalendarDateFields field);
1177
1192U_STABLE void U_EXPORT2
1194 UCalendarDateFields field);
1195
1206U_STABLE void U_EXPORT2
1208
1227
1230
1245U_STABLE int32_t U_EXPORT2
1247 UCalendarDateFields field,
1248 UCalendarLimitType type,
1249 UErrorCode* status);
1250
1258U_STABLE const char * U_EXPORT2
1260
1267U_STABLE const char * U_EXPORT2
1269
1288U_STABLE int32_t U_EXPORT2
1289ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len,
1290 UChar* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status);
1298U_STABLE const char * U_EXPORT2
1299ucal_getType(const UCalendar *cal, UErrorCode* status);
1300
1317U_STABLE UEnumeration* U_EXPORT2
1319 const char* locale,
1320 UBool commonlyUsed,
1321 UErrorCode* status);
1322
1323
1351
1354
1373
1389U_STABLE int32_t U_EXPORT2
1391
1402U_STABLE UBool U_EXPORT2
1403ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status);
1404
1429U_STABLE int32_t U_EXPORT2
1431 UDate target,
1432 UCalendarDateFields field,
1433 UErrorCode* status);
1434
1435#ifndef U_HIDE_DRAFT_API
1466
1469
1485U_DRAFT UBool U_EXPORT2
1487 UDate* transition, UErrorCode* status);
1488
1489#endif /* U_HIDE_DRAFT_API */
1490
1491#endif /* #if !UCONFIG_NO_FORMATTING */
1492
1493#endif
"Smart pointer" class, closes a UCalendar via ucal_close().
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
UEnumeration * ucal_openCountryTimeZones(const char *country, UErrorCode *ec)
Create an enumeration over all time zones associated with the given country.
UCalendarDateFields
Possible fields in a UCalendar.
Definition ucal.h:183
@ UCAL_HOUR_OF_DAY
Field number indicating the hour of the day.
Definition ucal.h:332
@ UCAL_EXTENDED_YEAR
Year of this calendar system, encompassing all supra-year fields.
Definition ucal.h:395
@ UCAL_ERA
Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar.
Definition ucal.h:189
@ UCAL_WEEK_OF_MONTH
Field number indicating the week number within the current month.
Definition ucal.h:244
@ UCAL_YEAR
Field number indicating the year.
Definition ucal.h:195
@ UCAL_DAY_OF_YEAR
Field number indicating the day number within the current year.
Definition ucal.h:260
@ UCAL_YEAR_WOY
Field number indicating the extended year corresponding to the UCAL_WEEK_OF_YEAR field.
Definition ucal.h:379
@ UCAL_MINUTE
Field number indicating the minute within the hour.
Definition ucal.h:340
@ UCAL_JULIAN_DAY
Field number indicating the modified Julian day number.
Definition ucal.h:407
@ UCAL_DATE
Field number indicating the day of the month.
Definition ucal.h:253
@ UCAL_SECOND
Field number indicating the second within the minute.
Definition ucal.h:348
@ 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:301
@ UCAL_MONTH
Field number indicating the month.
Definition ucal.h:216
@ UCAL_ZONE_OFFSET
Field number indicating the raw offset from GMT in milliseconds.
Definition ucal.h:363
@ UCAL_WEEK_OF_YEAR
Field number indicating the week number within the current year.
Definition ucal.h:229
@ UCAL_MILLISECOND
Field number indicating the millisecond within the second.
Definition ucal.h:356
@ UCAL_HOUR
Field number indicating the hour of the morning or afternoon.
Definition ucal.h:323
@ UCAL_DAY_OF_MONTH
Field number indicating the day of the month.
Definition ucal.h:440
@ UCAL_DAY_OF_WEEK
Field number indicating the day of the week.
Definition ucal.h:276
@ UCAL_AM_PM
Field number indicating whether the HOUR is before or after noon.
Definition ucal.h:312
@ UCAL_FIELD_COUNT
Field count.
Definition ucal.h:430
@ UCAL_IS_LEAP_MONTH
Whether or not the current month is a leap month (0 or 1).
Definition ucal.h:424
@ UCAL_DST_OFFSET
Field number indicating the daylight savings offset in milliseconds.
Definition ucal.h:370
@ UCAL_MILLISECONDS_IN_DAY
Ranges from 0 to 23:59:59.999 (regardless of DST).
Definition ucal.h:418
@ UCAL_DOW_LOCAL
Field number indicating the localized day of week.
Definition ucal.h:387
UBool ucal_inDaylightTime(const UCalendar *cal, UErrorCode *status)
Determine if a UCalendar is currently in daylight savings time.
UCalendar * ucal_clone(const UCalendar *cal, UErrorCode *status)
Open a copy of a UCalendar.
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,...
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.
const char * ucal_getAvailable(int32_t localeIndex)
Get a locale for which calendars are available.
const char * ucal_getTZDataVersion(UErrorCode *status)
Returns the timezone data version currently used by ICU.
USystemTimeZoneType
System time zone type constants used by filtering zones in ucal_openTimeZoneIDEnumeration.
Definition ucal.h:530
@ UCAL_ZONE_TYPE_CANONICAL
Canonical system zones.
Definition ucal.h:540
@ UCAL_ZONE_TYPE_ANY
Any system zones.
Definition ucal.h:535
@ UCAL_ZONE_TYPE_CANONICAL_LOCATION
Canonical system zones associated with actual locations.
Definition ucal.h:545
void ucal_setDefaultTimeZone(const UChar *zoneID, UErrorCode *ec)
Set the default time zone.
UCalendarAttribute
Types of UCalendar attributes.
Definition ucal.h:849
@ UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
Minimum number of days in first week.
Definition ucal.h:864
@ UCAL_REPEATED_WALL_TIME
The behavior for handling wall time repeating multiple times at negative time zone offset transitions...
Definition ucal.h:872
@ UCAL_FIRST_DAY_OF_WEEK
First day of week.
Definition ucal.h:859
@ UCAL_SKIPPED_WALL_TIME
The behavior for handling skipped wall time at positive time zone offset transitions.
Definition ucal.h:878
@ UCAL_LENIENT
Lenient parsing.
Definition ucal.h:854
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...
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.
void ucal_clear(UCalendar *calendar)
Clear all fields in a UCalendar.
UCalendarWallTimeOption
Options for handling ambiguous wall time at time zone offset transitions.
Definition ucal.h:890
@ UCAL_WALLTIME_NEXT_VALID
An ambiguous wall time to be interpreted as the next valid wall time.
Definition ucal.h:912
@ UCAL_WALLTIME_LAST
An ambiguous wall time to be interpreted as the latest.
Definition ucal.h:897
@ UCAL_WALLTIME_FIRST
An ambiguous wall time to be interpreted as the earliest.
Definition ucal.h:906
UBool ucal_equivalentTo(const UCalendar *cal1, const UCalendar *cal2)
Returns TRUE if two UCalendars are equivalent.
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...
UDate ucal_getMillis(const UCalendar *cal, UErrorCode *status)
Get a UCalendar's current time in millis.
void ucal_setMillis(UCalendar *cal, UDate dateTime, UErrorCode *status)
Set a UCalendar's current time in millis.
UCalendarWeekdayType
Weekday types, as returned by ucal_getDayOfWeekType().
Definition ucal.h:1327
@ UCAL_WEEKDAY
Designates a full weekday (no part of the day is included in the weekend).
Definition ucal.h:1332
@ UCAL_WEEKEND_CEASE
Designates a day that starts as the weekend and transitions to a weekday.
Definition ucal.h:1349
@ UCAL_WEEKEND
Designates a full weekend day (the entire day is included in the weekend).
Definition ucal.h:1337
@ UCAL_WEEKEND_ONSET
Designates a day that starts as a weekday and transitions to the weekend.
Definition ucal.h:1343
int32_t ucal_getLimit(const UCalendar *cal, UCalendarDateFields field, UCalendarLimitType type, UErrorCode *status)
Determine a limit for a field in a UCalendar.
int32_t ucal_get(const UCalendar *cal, UCalendarDateFields field, UErrorCode *status)
Get the current value of a field from a UCalendar.
UCalendarDaysOfWeek
Useful constant for days of week.
Definition ucal.h:453
@ UCAL_WEDNESDAY
Wednesday.
Definition ucal.h:461
@ UCAL_SATURDAY
Saturday.
Definition ucal.h:467
@ UCAL_THURSDAY
Thursday.
Definition ucal.h:463
@ UCAL_MONDAY
Monday.
Definition ucal.h:457
@ UCAL_SUNDAY
Sunday.
Definition ucal.h:455
@ UCAL_FRIDAY
Friday.
Definition ucal.h:465
@ UCAL_TUESDAY
Tuesday.
Definition ucal.h:459
UCalendarLimitType
Possible limit values for a UCalendar.
Definition ucal.h:1213
@ UCAL_ACTUAL_MAXIMUM
Actual maximum value.
Definition ucal.h:1225
@ UCAL_ACTUAL_MINIMUM
Actual minimum value.
Definition ucal.h:1223
@ UCAL_GREATEST_MINIMUM
Greatest minimum value.
Definition ucal.h:1219
@ UCAL_MINIMUM
Minimum value.
Definition ucal.h:1215
@ UCAL_MAXIMUM
Maximum value.
Definition ucal.h:1217
@ UCAL_LEAST_MAXIMUM
Leaest maximum value.
Definition ucal.h:1221
UCalendarAMPMs
Possible AM/PM values in a UCalendar.
Definition ucal.h:514
@ UCAL_AM
AM.
Definition ucal.h:516
@ UCAL_PM
PM.
Definition ucal.h:518
void ucal_add(UCalendar *cal, UCalendarDateFields field, int32_t amount, UErrorCode *status)
Add a specified signed amount to a particular field in a UCalendar.
UEnumeration * ucal_openTimeZones(UErrorCode *ec)
Create an enumeration over all time zones.
const char * ucal_getType(const UCalendar *cal, UErrorCode *status)
Get the resource keyword value string designating the calendar type for the UCalendar.
UTimeZoneTransitionType
Time zone transition types for ucal_getTimeZoneTransitionDate.
Definition ucal.h:1440
@ UCAL_TZ_TRANSITION_PREVIOUS
Get the previous transition before the current date, i.e.
Definition ucal.h:1458
@ UCAL_TZ_TRANSITION_PREVIOUS_INCLUSIVE
Get the previous transition on or before the current date, i.e.
Definition ucal.h:1464
@ UCAL_TZ_TRANSITION_NEXT
Get the next transition after the current date, i.e.
Definition ucal.h:1446
@ UCAL_TZ_TRANSITION_NEXT_INCLUSIVE
Get the next transition on or after the current date, i.e.
Definition ucal.h:1452
UCalendarType
Possible types of UCalendars.
Definition ucal.h:158
@ UCAL_GREGORIAN
Unambiguously designates the Gregorian calendar for the locale.
Definition ucal.h:174
@ UCAL_DEFAULT
A better name for UCAL_TRADITIONAL.
Definition ucal.h:169
@ UCAL_TRADITIONAL
Despite the name, UCAL_TRADITIONAL designates the locale's default calendar, which may be the Gregori...
Definition ucal.h:164
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 di...
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 zon...
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.
void ucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode)
Sets the GregorianCalendar change date.
void ucal_roll(UCalendar *cal, UCalendarDateFields field, int32_t amount, UErrorCode *status)
Add a specified signed amount to a particular field in a UCalendar.
void ucal_setAttribute(UCalendar *cal, UCalendarAttribute attr, int32_t newValue)
Set a numeric attribute associated with a UCalendar.
const char * ucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode *status)
Get the locale for this calendar object.
int32_t ucal_countAvailable(void)
Determine how many locales have calendars available.
int32_t ucal_getDefaultTimeZone(UChar *result, int32_t resultCapacity, UErrorCode *ec)
Return the default time zone.
UDate ucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode)
Gets the Gregorian Calendar change date.
void ucal_setDate(UCalendar *cal, int32_t year, int32_t month, int32_t date, UErrorCode *status)
Set a UCalendar's current date.
UBool ucal_isSet(const UCalendar *cal, UCalendarDateFields field)
Determine if a field in a UCalendar is set.
UDate ucal_getNow(void)
Get the current date and time.
UBool ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status)
Returns TRUE if the given UDate is in the weekend in this calendar system.
int32_t ucal_getAttribute(const UCalendar *cal, UCalendarAttribute attr)
Get a numeric attribute associated with a UCalendar.
void ucal_close(UCalendar *cal)
Close a UCalendar.
void ucal_setTimeZone(UCalendar *cal, const UChar *zoneID, int32_t len, UErrorCode *status)
Set the TimeZone used by a UCalendar.
void ucal_clearField(UCalendar *cal, UCalendarDateFields field)
Clear a field in a UCalendar.
void ucal_set(UCalendar *cal, UCalendarDateFields field, int32_t value)
Set the value of a field in a UCalendar.
UCalendarDisplayNameType
Possible formats for a UCalendar's display name.
Definition ucal.h:752
@ UCAL_STANDARD
Standard display name.
Definition ucal.h:754
@ UCAL_SHORT_DST
Short daylight savings display name.
Definition ucal.h:760
@ UCAL_SHORT_STANDARD
Short standard display name.
Definition ucal.h:756
@ UCAL_DST
Daylight savings display name.
Definition ucal.h:758
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.
UCalendarMonths
Possible months in a UCalendar.
Definition ucal.h:476
@ UCAL_DECEMBER
December.
Definition ucal.h:500
@ UCAL_MAY
May.
Definition ucal.h:486
@ UCAL_UNDECIMBER
Value of the UCAL_MONTH field indicating the thirteenth month of the year.
Definition ucal.h:505
@ UCAL_APRIL
April.
Definition ucal.h:484
@ UCAL_NOVEMBER
November.
Definition ucal.h:498
@ UCAL_JUNE
June.
Definition ucal.h:488
@ UCAL_AUGUST
August.
Definition ucal.h:492
@ UCAL_JULY
July.
Definition ucal.h:490
@ UCAL_SEPTEMBER
September.
Definition ucal.h:494
@ UCAL_JANUARY
January.
Definition ucal.h:478
@ UCAL_FEBRUARY
February.
Definition ucal.h:480
@ UCAL_MARCH
March.
Definition ucal.h:482
@ UCAL_OCTOBER
October.
Definition ucal.h:496
UCalendar * ucal_open(const UChar *zoneID, int32_t len, const char *locale, UCalendarType type, UErrorCode *status)
Open a UCalendar.
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.
void * UCalendar
A calendar.
Definition ucal.h:153
C API: String Enumeration.
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition uenum.h:39
C API: Locale.
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition uloc.h:336
int8_t UBool
The ICU boolean type.
Definition umachine.h:200
#define U_DRAFT
This is used to declare a function as a draft public ICU C API.
Definition umachine.h:111
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition umachine.h:278
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition umachine.h:109
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:476
double UDate
Date and Time data type.
Definition utypes.h:201
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129