ICU 65.1  65.1
ucal.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4  *******************************************************************************
5  * Copyright (C) 1996-2015, International Business Machines Corporation and
6  * others. All Rights Reserved.
7  *******************************************************************************
8  */
9 
10 #ifndef UCAL_H
11 #define UCAL_H
12 
13 #include "unicode/utypes.h"
14 #include "unicode/uenum.h"
15 #include "unicode/uloc.h"
16 #include "unicode/localpointer.h"
17 
18 #if !UCONFIG_NO_FORMATTING
19 
163 #define UCAL_UNKNOWN_ZONE_ID "Etc/Unknown"
164 
169 typedef void* UCalendar;
170 
191 };
192 
195 
206 
212 
233 
246 
261 
270 
277 
293 
318 
329 
340 
349 
357 
365 
373 
380 
387 
396 
404 
412 
424 
435 
441 
442  /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API,
443  * it is needed for layout of Calendar, DateFormat, and other objects */
449 
459 };
460 
486 };
487 
490 
524 };
525 
528 
537 };
538 
541 
564 };
565 
568 
585 U_STABLE UEnumeration* U_EXPORT2
586 ucal_openTimeZoneIDEnumeration(USystemTimeZoneType zoneType, const char* region,
587  const int32_t* rawOffset, UErrorCode* ec);
588 
600 U_STABLE UEnumeration* U_EXPORT2
602 
619 U_STABLE UEnumeration* U_EXPORT2
620 ucal_openCountryTimeZones(const char* country, UErrorCode* ec);
621 
645 U_STABLE int32_t U_EXPORT2
646 ucal_getDefaultTimeZone(UChar* result, int32_t resultCapacity, UErrorCode* ec);
647 
657 U_STABLE void U_EXPORT2
658 ucal_setDefaultTimeZone(const UChar* zoneID, UErrorCode* ec);
659 
660 #ifndef U_HIDE_DRAFT_API
661 
691 U_DRAFT int32_t U_EXPORT2
692 ucal_getHostTimeZone(UChar *result, int32_t resultCapacity, UErrorCode *ec);
693 
694 #endif // U_HIDE_DRAFT_API
695 
712 U_STABLE int32_t U_EXPORT2
713 ucal_getDSTSavings(const UChar* zoneID, UErrorCode* ec);
714 
721 U_STABLE UDate U_EXPORT2
722 ucal_getNow(void);
723 
747 U_STABLE UCalendar* U_EXPORT2
748 ucal_open(const UChar* zoneID,
749  int32_t len,
750  const char* locale,
751  UCalendarType type,
752  UErrorCode* status);
753 
760 U_STABLE void U_EXPORT2
761 ucal_close(UCalendar *cal);
762 
763 #if U_SHOW_CPLUSPLUS_API
764 
765 U_NAMESPACE_BEGIN
766 
777 
778 U_NAMESPACE_END
779 
780 #endif
781 
790 U_STABLE UCalendar* U_EXPORT2
791 ucal_clone(const UCalendar* cal,
792  UErrorCode* status);
793 
803 U_STABLE void U_EXPORT2
805  const UChar* zoneID,
806  int32_t len,
807  UErrorCode* status);
808 
819 U_STABLE int32_t U_EXPORT2
820 ucal_getTimeZoneID(const UCalendar *cal,
821  UChar *result,
822  int32_t resultLength,
823  UErrorCode *status);
824 
838 };
839 
842 
856 U_STABLE int32_t U_EXPORT2
859  const char* locale,
860  UChar* result,
861  int32_t resultLength,
862  UErrorCode* status);
863 
872 U_STABLE UBool U_EXPORT2
873 ucal_inDaylightTime(const UCalendar* cal,
874  UErrorCode* status );
875 
896 U_STABLE void U_EXPORT2
897 ucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode);
898 
919 U_STABLE UDate U_EXPORT2
920 ucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode);
921 
954 };
955 
958 
985 };
988 
1000 U_STABLE int32_t U_EXPORT2
1001 ucal_getAttribute(const UCalendar* cal,
1002  UCalendarAttribute attr);
1003 
1015 U_STABLE void U_EXPORT2
1017  UCalendarAttribute attr,
1018  int32_t newValue);
1019 
1029 U_STABLE const char* U_EXPORT2
1030 ucal_getAvailable(int32_t localeIndex);
1031 
1040 U_STABLE int32_t U_EXPORT2
1041 ucal_countAvailable(void);
1042 
1054 U_STABLE UDate U_EXPORT2
1055 ucal_getMillis(const UCalendar* cal,
1056  UErrorCode* status);
1057 
1069 U_STABLE void U_EXPORT2
1071  UDate dateTime,
1072  UErrorCode* status );
1073 
1088 U_STABLE void U_EXPORT2
1089 ucal_setDate(UCalendar* cal,
1090  int32_t year,
1091  int32_t month,
1092  int32_t date,
1093  UErrorCode* status);
1094 
1112 U_STABLE void U_EXPORT2
1114  int32_t year,
1115  int32_t month,
1116  int32_t date,
1117  int32_t hour,
1118  int32_t minute,
1119  int32_t second,
1120  UErrorCode* status);
1121 
1131 U_STABLE UBool U_EXPORT2
1132 ucal_equivalentTo(const UCalendar* cal1,
1133  const UCalendar* cal2);
1134 
1153 U_STABLE void U_EXPORT2
1154 ucal_add(UCalendar* cal,
1155  UCalendarDateFields field,
1156  int32_t amount,
1157  UErrorCode* status);
1158 
1183 U_STABLE void U_EXPORT2
1184 ucal_roll(UCalendar* cal,
1185  UCalendarDateFields field,
1186  int32_t amount,
1187  UErrorCode* status);
1188 
1205 U_STABLE int32_t U_EXPORT2
1206 ucal_get(const UCalendar* cal,
1207  UCalendarDateFields field,
1208  UErrorCode* status );
1209 
1225 U_STABLE void U_EXPORT2
1226 ucal_set(UCalendar* cal,
1227  UCalendarDateFields field,
1228  int32_t value);
1229 
1245 U_STABLE UBool U_EXPORT2
1246 ucal_isSet(const UCalendar* cal,
1247  UCalendarDateFields field);
1248 
1263 U_STABLE void U_EXPORT2
1265  UCalendarDateFields field);
1266 
1277 U_STABLE void U_EXPORT2
1278 ucal_clear(UCalendar* calendar);
1279 
1297 };
1298 
1301 
1316 U_STABLE int32_t U_EXPORT2
1317 ucal_getLimit(const UCalendar* cal,
1318  UCalendarDateFields field,
1319  UCalendarLimitType type,
1320  UErrorCode* status);
1321 
1329 U_STABLE const char * U_EXPORT2
1330 ucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode* status);
1331 
1338 U_STABLE const char * U_EXPORT2
1340 
1359 U_STABLE int32_t U_EXPORT2
1360 ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len,
1361  UChar* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status);
1369 U_STABLE const char * U_EXPORT2
1370 ucal_getType(const UCalendar *cal, UErrorCode* status);
1371 
1388 U_STABLE UEnumeration* U_EXPORT2
1389 ucal_getKeywordValuesForLocale(const char* key,
1390  const char* locale,
1391  UBool commonlyUsed,
1392  UErrorCode* status);
1393 
1394 
1421 };
1422 
1425 
1444 ucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode* status);
1445 
1461 U_STABLE int32_t U_EXPORT2
1462 ucal_getWeekendTransition(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode *status);
1463 
1474 U_STABLE UBool U_EXPORT2
1475 ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status);
1476 
1501 U_STABLE int32_t U_EXPORT2
1503  UDate target,
1504  UCalendarDateFields field,
1505  UErrorCode* status);
1506 
1536 };
1537 
1555 U_STABLE UBool U_EXPORT2
1557  UDate* transition, UErrorCode* status);
1558 
1583 U_STABLE int32_t U_EXPORT2
1584 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len,
1585  UChar* winid, int32_t winidCapacity, UErrorCode* status);
1586 
1615 U_STABLE int32_t U_EXPORT2
1616 ucal_getTimeZoneIDForWindowsID(const UChar* winid, int32_t len, const char* region,
1617  UChar* id, int32_t idCapacity, UErrorCode* status);
1618 
1619 #endif /* #if !UCONFIG_NO_FORMATTING */
1620 
1621 #endif
UCalendar * ucal_clone(const UCalendar *cal, UErrorCode *status)
Open a copy of a UCalendar.
A better name for UCAL_TRADITIONAL.
Definition: ucal.h:185
void * UCalendar
A calendar.
Definition: ucal.h:169
Field number indicating the day number within the current year.
Definition: ucal.h:276
August.
Definition: ucal.h:510
May.
Definition: ucal.h:504
Short standard display name.
Definition: ucal.h:833
UCalendarDateFields
Possible fields in a UCalendar.
Definition: ucal.h:199
void ucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode)
Sets the GregorianCalendar change date.
Field number indicating the day of the month.
Definition: ucal.h:269
void ucal_clear(UCalendar *calendar)
Clear all fields in a UCalendar.
Ranges from 0 to 23:59:59.999 (regardless of DST).
Definition: ucal.h:434
Minimum number of days in first week.
Definition: ucal.h:941
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.
int32_t ucal_countAvailable(void)
Determine how many locales have calendars available.
Lenient parsing.
Definition: ucal.h:931
AM.
Definition: ucal.h:534
Field number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar.
Definition: ucal.h:205
Designates a day that starts as the weekend and transitions to a weekday.
Definition: ucal.h:1420
Get the next transition on or after the current date, i.e.
Definition: ucal.h:1523
UBool ucal_inDaylightTime(const UCalendar *cal, UErrorCode *status)
Determine if a UCalendar is currently in daylight savings time.
Designates a full weekday (no part of the day is included in the weekend).
Definition: ucal.h:1403
Value of the UCAL_MONTH field indicating the thirteenth month of the year.
Definition: ucal.h:523
int32_t ucal_get(const UCalendar *cal, UCalendarDateFields field, UErrorCode *status)
Get the current value of a field from a UCalendar.
int32_t ucal_getLimit(const UCalendar *cal, UCalendarDateFields field, UCalendarLimitType type, UErrorCode *status)
Determine a limit for a field in a UCalendar.
UBool ucal_isSet(const UCalendar *cal, UCalendarDateFields field)
Determine if a field in a UCalendar is set.
Get the next transition after the current date, i.e.
Definition: ucal.h:1517
Maximum value.
Definition: ucal.h:1288
June.
Definition: ucal.h:506
Leaest maximum value.
Definition: ucal.h:1292
double UDate
Date and Time data type.
Definition: utypes.h:203
Field number indicating the week number within the current month.
Definition: ucal.h:260
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition: uenum.h:43
Field number indicating the millisecond within the second.
Definition: ucal.h:372
Year of this calendar system, encompassing all supra-year fields.
Definition: ucal.h:411
Standard display name.
Definition: ucal.h:831
UBool ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status)
Returns TRUE if the given UDate is in the weekend in this calendar system.
Actual minimum value.
Definition: ucal.h:1294
Friday.
Definition: ucal.h:483
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...
const char * ucal_getAvailable(int32_t localeIndex)
Get a locale for which calendars are available.
Minimum value.
Definition: ucal.h:1286
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...
UBool ucal_equivalentTo(const UCalendar *cal1, const UCalendar *cal2)
Returns TRUE if two UCalendars are equivalent.
Wednesday.
Definition: ucal.h:479
Tuesday.
Definition: ucal.h:477
UCalendarWeekdayType
Weekday types, as returned by ucal_getDayOfWeekType().
Definition: ucal.h:1398
Saturday.
Definition: ucal.h:485
March.
Definition: ucal.h:500
Field number indicating the extended year corresponding to the UCAL_WEEK_OF_YEAR field.
Definition: ucal.h:395
Field number indicating the day of the month.
Definition: ucal.h:458
"Smart pointer" class, closes a UCalendar via ucal_close().
UCalendarAttribute
Types of UCalendar attributes.
Definition: ucal.h:926
UTimeZoneTransitionType
Time zone transition types for ucal_getTimeZoneTransitionDate.
Definition: ucal.h:1511
Get the previous transition before the current date, i.e.
Definition: ucal.h:1529
An ambiguous wall time to be interpreted as the earliest.
Definition: ucal.h:978
Sunday.
Definition: ucal.h:473
UCalendarWallTimeOption
Options for handling ambiguous wall time at time zone offset transitions.
Definition: ucal.h:964
Field number indicating whether the HOUR is before or after noon.
Definition: ucal.h:328
Field number indicating the ordinal number of the day of the week within the current month...
Definition: ucal.h:317
First day of week.
Definition: ucal.h:936
int32_t ucal_getTimeZoneID(const UCalendar *cal, UChar *result, int32_t resultLength, UErrorCode *status)
Get the ID of the UCalendar's time zone.
February.
Definition: ucal.h:498
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...
October.
Definition: ucal.h:514
Short daylight savings display name.
Definition: ucal.h:837
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...
Greatest minimum value.
Definition: ucal.h:1290
UCalendarDaysOfWeek
Useful constant for days of week.
Definition: ucal.h:471
November.
Definition: ucal.h:516
const char * ucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode *status)
Get the locale for this calendar object.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:562
Daylight savings display name.
Definition: ucal.h:835
Despite the name, UCAL_TRADITIONAL designates the locale's default calendar, which may be the Gregori...
Definition: ucal.h:180
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...
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
July.
Definition: ucal.h:508
UEnumeration * ucal_openTimeZones(UErrorCode *ec)
Create an enumeration over all time zones.
Canonical system zones associated with actual locations.
Definition: ucal.h:563
Monday.
Definition: ucal.h:475
Field number indicating the hour of the morning or afternoon.
Definition: ucal.h:339
Field number indicating the minute within the hour.
Definition: ucal.h:356
UEnumeration * ucal_openCountryTimeZones(const char *country, UErrorCode *ec)
Create an enumeration over all time zones associated with the given country.
UCalendar * ucal_open(const UChar *zoneID, int32_t len, const char *locale, UCalendarType type, UErrorCode *status)
Open a UCalendar.
int32_t ucal_getAttribute(const UCalendar *cal, UCalendarAttribute attr)
Get a numeric attribute associated with a UCalendar.
April.
Definition: ucal.h:502
void ucal_setAttribute(UCalendar *cal, UCalendarAttribute attr, int32_t newValue)
Set a numeric attribute associated with a UCalendar.
Any system zones.
Definition: ucal.h:553
Field number indicating the day of the week.
Definition: ucal.h:292
void ucal_set(UCalendar *cal, UCalendarDateFields field, int32_t value)
Set the value of a field in a UCalendar.
Whether or not the current month is a leap month (0 or 1).
Definition: ucal.h:440
The behavior for handling skipped wall time at positive time zone offset transitions.
Definition: ucal.h:953
Field number indicating the year.
Definition: ucal.h:211
Get the previous transition on or before the current date, i.e.
Definition: ucal.h:1535
void ucal_close(UCalendar *cal)
Close a UCalendar.
const char * ucal_getTZDataVersion(UErrorCode *status)
Returns the timezone data version currently used by ICU.
void ucal_setMillis(UCalendar *cal, UDate dateTime, UErrorCode *status)
Set a UCalendar's current time in millis.
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...
Actual maximum value.
Definition: ucal.h:1296
uint16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:377
UCalendarType
Possible types of UCalendars.
Definition: ucal.h:174
void ucal_setDate(UCalendar *cal, int32_t year, int32_t month, int32_t date, UErrorCode *status)
Set a UCalendar's current date.
Thursday.
Definition: ucal.h:481
September.
Definition: ucal.h:512
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.
An ambiguous wall time to be interpreted as the next valid wall time.
Definition: ucal.h:984
Canonical system zones.
Definition: ucal.h:558
USystemTimeZoneType
System time zone type constants used by filtering zones in ucal_openTimeZoneIDEnumeration.
Definition: ucal.h:548
Field number indicating the localized day of week.
Definition: ucal.h:403
Designates a full weekend day (the entire day is included in the weekend).
Definition: ucal.h:1408
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
void ucal_add(UCalendar *cal, UCalendarDateFields field, int32_t amount, UErrorCode *status)
Add a specified signed amount to a particular field in a UCalendar.
void ucal_setDefaultTimeZone(const UChar *zoneID, UErrorCode *ec)
Set the default time zone.
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:338
Unambiguously designates the Gregorian calendar for the locale.
Definition: ucal.h:190
C API: String Enumeration.
int32_t ucal_getDefaultTimeZone(UChar *result, int32_t resultCapacity, UErrorCode *ec)
Return the default time zone.
January.
Definition: ucal.h:496
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.
const char * ucal_getType(const UCalendar *cal, UErrorCode *status)
Get the resource keyword value string designating the calendar type for the UCalendar.
Basic definitions for ICU, for both C and C++ APIs.
The behavior for handling wall time repeating multiple times at negative time zone offset transitions...
Definition: ucal.h:947
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.
Designates a day that starts as a weekday and transitions to the weekend.
Definition: ucal.h:1414
Field number indicating the daylight savings offset in milliseconds.
Definition: ucal.h:386
Field number indicating the second within the minute.
Definition: ucal.h:364
One more than the highest normal UCalendarDateFields value.
Definition: ucal.h:448
int32_t ucal_getHostTimeZone(UChar *result, int32_t resultCapacity, UErrorCode *ec)
Return the current host time zone.
void ucal_roll(UCalendar *cal, UCalendarDateFields field, int32_t amount, UErrorCode *status)
Add a specified signed amount to a particular field in a UCalendar.
UCalendarDisplayNameType
Possible formats for a UCalendar's display name.
Definition: ucal.h:829
Field number indicating the raw offset from GMT in milliseconds.
Definition: ucal.h:379
void ucal_setTimeZone(UCalendar *cal, const UChar *zoneID, int32_t len, UErrorCode *status)
Set the TimeZone used by a UCalendar.
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...
UCalendarAMPMs
Possible AM/PM values in a UCalendar.
Definition: ucal.h:532
Field number indicating the week number within the current year.
Definition: ucal.h:245
UCalendarLimitType
Possible limit values for a UCalendar.
Definition: ucal.h:1284
#define U_DRAFT
This is used to declare a function as a draft public ICU C API.
Definition: umachine.h:113
UDate ucal_getNow(void)
Get the current date and time.
UCalendarMonths
Possible months in a UCalendar.
Definition: ucal.h:494
December.
Definition: ucal.h:518
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. ...
An ambiguous wall time to be interpreted as the latest.
Definition: ucal.h:971
Field number indicating the hour of the day.
Definition: ucal.h:348
Field number indicating the modified Julian day number.
Definition: ucal.h:423
UDate ucal_getMillis(const UCalendar *cal, UErrorCode *status)
Get a UCalendar's current time in millis.
UDate ucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode)
Gets the Gregorian Calendar change date.
void ucal_clearField(UCalendar *cal, UCalendarDateFields field)
Clear a field in a UCalendar.
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:111
int8_t UBool
The ICU boolean type.
Definition: umachine.h:260
Field number indicating the month.
Definition: ucal.h:232
PM.
Definition: ucal.h:536
C API: Locale.