UDate
UCAL_YEAR
UCAL_MONTH
UCAL_DAY
UCAL_HOUR
37 * Types of UCalendar interpret a UDate 38 * according to the rules of a specific calendar system. The C API 39 * provides the enum UCalendarType with UCAL_TRADITIONAL and 40 * UCAL_GREGORIAN. 41 *
UCalendar
42 * Like other locale-sensitive C API, calendar API provides a 43 * function, ucal_open(), which returns a pointer to 44 * UCalendar whose time fields have been initialized 45 * with the current date and time. We need to specify the type of 46 * calendar to be opened and the timezoneId. 47 * \htmlonly
ucal_open()
\endhtmlonly 48 * 49 * \code 50 * UCalendar *caldef; 51 * UChar *tzId; 52 * UErrorCode status; 53 * tzId=(UChar*)malloc(sizeof(UChar) * (strlen("PST") +1) ); 54 * u_uastrcpy(tzId, "PST"); 55 * caldef=ucal_open(tzID, u_strlen(tzID), NULL, UCAL_TRADITIONAL, &status); 56 * \endcode 57 * 58 * \htmlonly
49 * \code 50 * UCalendar *caldef; 51 * UChar *tzId; 52 * UErrorCode status; 53 * tzId=(UChar*)malloc(sizeof(UChar) * (strlen("PST") +1) ); 54 * u_uastrcpy(tzId, "PST"); 55 * caldef=ucal_open(tzID, u_strlen(tzID), NULL, UCAL_TRADITIONAL, &status); 56 * \endcode 57 *
61 * A UCalendar object can produce all the time field values 62 * needed to implement the date-time formatting for a particular language 63 * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional). 64 * 65 *
66 * When computing a UDate from time fields, two special circumstances 67 * may arise: there may be insufficient information to compute the 68 * UDate (such as only year and month but no day in the month), 69 * or there may be inconsistent information (such as "Tuesday, July 15, 1996" 70 * -- July 15, 1996 is actually a Monday). 71 * 72 *
73 * Insufficient information. The calendar will use default 74 * information to specify the missing fields. This may vary by calendar; for 75 * the Gregorian calendar, the default for a field is the same as that of the 76 * start of the epoch: i.e., UCAL_YEAR = 1970, UCAL_MONTH = JANUARY, UCAL_DATE = 1, etc. 77 * 78 *
79 * Inconsistent information. If fields conflict, the calendar 80 * will give preference to fields set more recently. For example, when 81 * determining the day, the calendar will look for one of the following 82 * combinations of fields. The most recent combination, as determined by the 83 * most recently set single field, will be used. 84 * 85 * \htmlonly
\endhtmlonly 86 * 87 * \code 88 * UCAL_MONTH + UCAL_DAY_OF_MONTH 89 * UCAL_MONTH + UCAL_WEEK_OF_MONTH + UCAL_DAY_OF_WEEK 90 * UCAL_MONTH + UCAL_DAY_OF_WEEK_IN_MONTH + UCAL_DAY_OF_WEEK 91 * UCAL_DAY_OF_YEAR 92 * UCAL_DAY_OF_WEEK + UCAL_WEEK_OF_YEAR 93 * \endcode 94 * 95 * \htmlonly
87 * \code 88 * UCAL_MONTH + UCAL_DAY_OF_MONTH 89 * UCAL_MONTH + UCAL_WEEK_OF_MONTH + UCAL_DAY_OF_WEEK 90 * UCAL_MONTH + UCAL_DAY_OF_WEEK_IN_MONTH + UCAL_DAY_OF_WEEK 91 * UCAL_DAY_OF_YEAR 92 * UCAL_DAY_OF_WEEK + UCAL_WEEK_OF_YEAR 93 * \endcode 94 *
\endhtmlonly 100 * 101 * \code 102 * UCAL_HOUR_OF_DAY 103 * UCAL_AM_PM + UCAL_HOUR 104 * \endcode 105 * 106 * \htmlonly
101 * \code 102 * UCAL_HOUR_OF_DAY 103 * UCAL_AM_PM + UCAL_HOUR 104 * \endcode 105 *
109 * Note: for some non-Gregorian calendars, different 110 * fields may be necessary for complete disambiguation. For example, a full 111 * specification of the historical Arabic astronomical calendar requires year, 112 * month, day-of-month and day-of-week in some cases. 113 * 114 *
115 * Note: There are certain possible ambiguities in 116 * interpretation of certain singular times, which are resolved in the 117 * following ways: 118 *
128 * The date or time format strings are not part of the definition of a 129 * calendar, as those must be modifiable or overridable by the user at 130 * runtime. Use {@link icu::DateFormat} 131 * to format dates. 132 * 133 *
134 * Calendar provides an API for field "rolling", where fields 135 * can be incremented or decremented, but wrap around. For example, rolling the 136 * month up in the date December 12, 1996 results in 137 * January 12, 1996. 138 * 139 *
Calendar
December 12, 1996
January 12, 1996
140 * Calendar also provides a date arithmetic function for 141 * adding the specified (signed) amount of time to a particular time field. 142 * For example, subtracting 5 days from the date September 12, 1996 143 * results in September 7, 1996. 144 * 145 *
September 12, 1996
September 7, 1996
146 * The Japanese calendar uses a combination of era name and year number. 147 * When an emperor of Japan abdicates and a new emperor ascends the throne, 148 * a new era is declared and year number is reset to 1. Even if the date of 149 * abdication is scheduled ahead of time, the new era name might not be 150 * announced until just before the date. In such case, ICU4C may include 151 * a start date of future era without actual era name, but not enabled 152 * by default. ICU4C users who want to test the behavior of the future era 153 * can enable the tentative era by: 154 *
ICU_ENABLE_TENTATIVE_ERA=true
JANUARY
UCAL_FIRST_DAY_OF_WEEK
UCAL_MINIMAL_DAYS_IN_FIRST_WEEK
UCAL_WEEK_OF_YEAR
WEEK_OF_MONTH
DAY_OF_MONTH
SUNDAY
MONDAY
TUESDAY
WEDNESDAY
THURSDAY
FRIDAY
SATURDAY
DAY_OF_WEEK
WEEK_OF_YEAR
getFirstDayOfWeek()
getMinimalDaysInFirstWeek()
DAY_OF_MONTH 1
7
DAY_OF_WEEK_IN_MONTH 306 * 1
8
15
DAY_OF_WEEK_IN_MONTH 2
DAY_OF_WEEK_IN_MONTH 0
DAY_OF_WEEK_IN_MONTH 1
DAY_OF_WEEK = SUNDAY, DAY_OF_WEEK_IN_MONTH = -1
DAY_OF_WEEK_IN_MONTH -1
DAY_OF_WEEK_IN_MONTH 5
4
HOUR
AM_PM
PM
HOUR_OF_DAY
UCAL_MINUTE
UCAL_SECOND
UCAL_MILLISECOND
UCAL_EXTENDED_YEAR
UCAL_DATE
This function is not thread safe.
763 * Note: When unknown TimeZone ID is specified or if the TimeZone ID specified is "Etc/Unknown", 764 * the UCalendar returned by the function is initialized with GMT zone with TimeZone ID 765 * UCAL_UNKNOWN_ZONE_ID ("Etc/Unknown") without any errors/warnings. If you want 766 * to check if a TimeZone ID is valid prior to this function, use ucal_getCanonicalTimeZoneID. 767 * 768 * @param zoneID The desired TimeZone ID. If 0, use the default time zone. 769 * @param len The length of zoneID, or -1 if null-terminated. 770 * @param locale The desired locale 771 * @param type The type of UCalendar to open. This can be UCAL_GREGORIAN to open the Gregorian 772 * calendar for the locale, or UCAL_DEFAULT to open the default calendar for the locale (the 773 * default calendar may also be Gregorian). To open a specific non-Gregorian calendar for the 774 * locale, use uloc_setKeywordValue to set the value of the calendar keyword for the locale 775 * and then pass the locale to ucal_open with UCAL_DEFAULT as the type. 776 * @param status A pointer to an UErrorCode to receive any errors 777 * @return A pointer to a UCalendar, or 0 if an error occurred. 778 * @see #UCAL_UNKNOWN_ZONE_ID 779 * @stable ICU 2.0 780 */ 781 U_CAPI UCalendar* U_EXPORT2 782 ucal_open(const UChar* zoneID, 783 int32_t len, 784 const char* locale, 785 UCalendarType type, 786 UErrorCode* status); 787 788 /** 789 * Close a UCalendar. 790 * Once closed, a UCalendar may no longer be used. 791 * @param cal The UCalendar to close. 792 * @stable ICU 2.0 793 */ 794 U_CAPI void U_EXPORT2 795 ucal_close(UCalendar *cal); 796 797 #if U_SHOW_CPLUSPLUS_API 798 799 U_NAMESPACE_BEGIN 800 801 /** 802 * \class LocalUCalendarPointer 803 * "Smart pointer" class, closes a UCalendar via ucal_close(). 804 * For most methods see the LocalPointerBase base class. 805 * 806 * @see LocalPointerBase 807 * @see LocalPointer 808 * @stable ICU 4.4 809 */ 810 U_DEFINE_LOCAL_OPEN_POINTER(LocalUCalendarPointer, UCalendar, ucal_close); 811 812 U_NAMESPACE_END 813 814 #endif 815 816 /** 817 * Open a copy of a UCalendar. 818 * This function performs a deep copy. 819 * @param cal The calendar to copy 820 * @param status A pointer to an UErrorCode to receive any errors. 821 * @return A pointer to a UCalendar identical to cal. 822 * @stable ICU 4.0 823 */ 824 U_CAPI UCalendar* U_EXPORT2 825 ucal_clone(const UCalendar* cal, 826 UErrorCode* status); 827 828 /** 829 * Set the TimeZone used by a UCalendar. 830 * A UCalendar uses a timezone for converting from Greenwich time to local time. 831 * @param cal The UCalendar to set. 832 * @param zoneID The desired TimeZone ID. If 0, use the default time zone. 833 * @param len The length of zoneID, or -1 if null-terminated. 834 * @param status A pointer to an UErrorCode to receive any errors. 835 * @stable ICU 2.0 836 */ 837 U_CAPI void U_EXPORT2 838 ucal_setTimeZone(UCalendar* cal, 839 const UChar* zoneID, 840 int32_t len, 841 UErrorCode* status); 842 843 /** 844 * Get the ID of the UCalendar's time zone. 845 * 846 * @param cal The UCalendar to query. 847 * @param result Receives the UCalendar's time zone ID. 848 * @param resultLength The maximum size of result. 849 * @param status Receives the status. 850 * @return The total buffer size needed; if greater than resultLength, the output was truncated. 851 * @stable ICU 51 852 */ 853 U_CAPI int32_t U_EXPORT2 854 ucal_getTimeZoneID(const UCalendar *cal, 855 UChar *result, 856 int32_t resultLength, 857 UErrorCode *status); 858 859 /** 860 * Possible formats for a UCalendar's display name 861 * @stable ICU 2.0 862 */ 863 enum UCalendarDisplayNameType { 864 /** Standard display name */ 865 UCAL_STANDARD, 866 /** Short standard display name */ 867 UCAL_SHORT_STANDARD, 868 /** Daylight savings display name */ 869 UCAL_DST, 870 /** Short daylight savings display name */ 871 UCAL_SHORT_DST 872 }; 873 874 /** @stable ICU 2.0 */ 875 typedef enum UCalendarDisplayNameType UCalendarDisplayNameType; 876 877 /** 878 * Get the display name for a UCalendar's TimeZone. 879 * A display name is suitable for presentation to a user. 880 * @param cal The UCalendar to query. 881 * @param type The desired display name format; one of UCAL_STANDARD, UCAL_SHORT_STANDARD, 882 * UCAL_DST, UCAL_SHORT_DST 883 * @param locale The desired locale for the display name. 884 * @param result A pointer to a buffer to receive the formatted number. 885 * @param resultLength The maximum size of result. 886 * @param status A pointer to an UErrorCode to receive any errors 887 * @return The total buffer size needed; if greater than resultLength, the output was truncated. 888 * @stable ICU 2.0 889 */ 890 U_CAPI int32_t U_EXPORT2 891 ucal_getTimeZoneDisplayName(const UCalendar* cal, 892 UCalendarDisplayNameType type, 893 const char* locale, 894 UChar* result, 895 int32_t resultLength, 896 UErrorCode* status); 897 898 /** 899 * Determine if a UCalendar is currently in daylight savings time. 900 * Daylight savings time is not used in all parts of the world. 901 * @param cal The UCalendar to query. 902 * @param status A pointer to an UErrorCode to receive any errors 903 * @return true if cal is currently in daylight savings time, false otherwise 904 * @stable ICU 2.0 905 */ 906 U_CAPI UBool U_EXPORT2 907 ucal_inDaylightTime(const UCalendar* cal, 908 UErrorCode* status ); 909 910 /** 911 * Sets the GregorianCalendar change date. This is the point when the switch from 912 * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October 913 * 15, 1582. Previous to this time and date will be Julian dates. 914 * 915 * This function works only for Gregorian calendars. If the UCalendar is not 916 * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR 917 * error code is set. 918 * 919 * @param cal The calendar object. 920 * @param date The given Gregorian cutover date. 921 * @param pErrorCode Pointer to a standard ICU error code. Its input value must 922 * pass the U_SUCCESS() test, or else the function returns 923 * immediately. Check for U_FAILURE() on output or use with 924 * function chaining. (See User Guide for details.) 925 * 926 * @see GregorianCalendar::setGregorianChange 927 * @see ucal_getGregorianChange 928 * @stable ICU 3.6 929 */ 930 U_CAPI void U_EXPORT2 931 ucal_setGregorianChange(UCalendar *cal, UDate date, UErrorCode *pErrorCode); 932 933 /** 934 * Gets the Gregorian Calendar change date. This is the point when the switch from 935 * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October 936 * 15, 1582. Previous to this time and date will be Julian dates. 937 * 938 * This function works only for Gregorian calendars. If the UCalendar is not 939 * an instance of a Gregorian calendar, then a U_UNSUPPORTED_ERROR 940 * error code is set. 941 * 942 * @param cal The calendar object. 943 * @param pErrorCode Pointer to a standard ICU error code. Its input value must 944 * pass the U_SUCCESS() test, or else the function returns 945 * immediately. Check for U_FAILURE() on output or use with 946 * function chaining. (See User Guide for details.) 947 * @return The Gregorian cutover time for this calendar. 948 * 949 * @see GregorianCalendar::getGregorianChange 950 * @see ucal_setGregorianChange 951 * @stable ICU 3.6 952 */ 953 U_CAPI UDate U_EXPORT2 954 ucal_getGregorianChange(const UCalendar *cal, UErrorCode *pErrorCode); 955 956 /** 957 * Types of UCalendar attributes 958 * @stable ICU 2.0 959 */ 960 enum UCalendarAttribute { 961 /** 962 * Lenient parsing 963 * @stable ICU 2.0 964 */ 965 UCAL_LENIENT, 966 /** 967 * First day of week 968 * @stable ICU 2.0 969 */ 970 UCAL_FIRST_DAY_OF_WEEK, 971 /** 972 * Minimum number of days in first week 973 * @stable ICU 2.0 974 */ 975 UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, 976 /** 977 * The behavior for handling wall time repeating multiple times 978 * at negative time zone offset transitions 979 * @stable ICU 49 980 */ 981 UCAL_REPEATED_WALL_TIME, 982 /** 983 * The behavior for handling skipped wall time at positive time 984 * zone offset transitions. 985 * @stable ICU 49 986 */ 987 UCAL_SKIPPED_WALL_TIME 988 }; 989 990 /** @stable ICU 2.0 */ 991 typedef enum UCalendarAttribute UCalendarAttribute; 992 993 /** 994 * Options for handling ambiguous wall time at time zone 995 * offset transitions. 996 * @stable ICU 49 997 */ 998 enum UCalendarWallTimeOption { 999 /** 1000 * An ambiguous wall time to be interpreted as the latest. 1001 * This option is valid for UCAL_REPEATED_WALL_TIME and 1002 * UCAL_SKIPPED_WALL_TIME. 1003 * @stable ICU 49 1004 */ 1005 UCAL_WALLTIME_LAST, 1006 /** 1007 * An ambiguous wall time to be interpreted as the earliest. 1008 * This option is valid for UCAL_REPEATED_WALL_TIME and 1009 * UCAL_SKIPPED_WALL_TIME. 1010 * @stable ICU 49 1011 */ 1012 UCAL_WALLTIME_FIRST, 1013 /** 1014 * An ambiguous wall time to be interpreted as the next valid 1015 * wall time. This option is valid for UCAL_SKIPPED_WALL_TIME. 1016 * @stable ICU 49 1017 */ 1018 UCAL_WALLTIME_NEXT_VALID 1019 }; 1020 /** @stable ICU 49 */ 1021 typedef enum UCalendarWallTimeOption UCalendarWallTimeOption; 1022 1023 /** 1024 * Get a numeric attribute associated with a UCalendar. 1025 * Numeric attributes include the first day of the week, or the minimal numbers 1026 * of days in the first week of the month. 1027 * @param cal The UCalendar to query. 1028 * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK, 1029 * UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, UCAL_REPEATED_WALL_TIME or UCAL_SKIPPED_WALL_TIME 1030 * @return The value of attr. 1031 * @see ucal_setAttribute 1032 * @stable ICU 2.0 1033 */ 1034 U_CAPI int32_t U_EXPORT2 1035 ucal_getAttribute(const UCalendar* cal, 1036 UCalendarAttribute attr); 1037 1038 /** 1039 * Set a numeric attribute associated with a UCalendar. 1040 * Numeric attributes include the first day of the week, or the minimal numbers 1041 * of days in the first week of the month. 1042 * @param cal The UCalendar to set. 1043 * @param attr The desired attribute; one of UCAL_LENIENT, UCAL_FIRST_DAY_OF_WEEK, 1044 * UCAL_MINIMAL_DAYS_IN_FIRST_WEEK, UCAL_REPEATED_WALL_TIME or UCAL_SKIPPED_WALL_TIME 1045 * @param newValue The new value of attr. 1046 * @see ucal_getAttribute 1047 * @stable ICU 2.0 1048 */ 1049 U_CAPI void U_EXPORT2 1050 ucal_setAttribute(UCalendar* cal, 1051 UCalendarAttribute attr, 1052 int32_t newValue); 1053 1054 /** 1055 * Get a locale for which calendars are available. 1056 * A UCalendar in a locale returned by this function will contain the correct 1057 * day and month names for the locale. 1058 * @param localeIndex The index of the desired locale. 1059 * @return A locale for which calendars are available, or 0 if none. 1060 * @see ucal_countAvailable 1061 * @stable ICU 2.0 1062 */ 1063 U_CAPI const char* U_EXPORT2 1064 ucal_getAvailable(int32_t localeIndex); 1065 1066 /** 1067 * Determine how many locales have calendars available. 1068 * This function is most useful as determining the loop ending condition for 1069 * calls to \ref ucal_getAvailable. 1070 * @return The number of locales for which calendars are available. 1071 * @see ucal_getAvailable 1072 * @stable ICU 2.0 1073 */ 1074 U_CAPI int32_t U_EXPORT2 1075 ucal_countAvailable(void); 1076 1077 /** 1078 * Get a UCalendar's current time in millis. 1079 * The time is represented as milliseconds from the epoch. 1080 * @param cal The UCalendar to query. 1081 * @param status A pointer to an UErrorCode to receive any errors 1082 * @return The calendar's current time in millis. 1083 * @see ucal_setMillis 1084 * @see ucal_setDate 1085 * @see ucal_setDateTime 1086 * @stable ICU 2.0 1087 */ 1088 U_CAPI UDate U_EXPORT2 1089 ucal_getMillis(const UCalendar* cal, 1090 UErrorCode* status); 1091 1092 /** 1093 * Set a UCalendar's current time in millis. 1094 * The time is represented as milliseconds from the epoch. 1095 * @param cal The UCalendar to set. 1096 * @param dateTime The desired date and time. 1097 * @param status A pointer to an UErrorCode to receive any errors 1098 * @see ucal_getMillis 1099 * @see ucal_setDate 1100 * @see ucal_setDateTime 1101 * @stable ICU 2.0 1102 */ 1103 U_CAPI void U_EXPORT2 1104 ucal_setMillis(UCalendar* cal, 1105 UDate dateTime, 1106 UErrorCode* status ); 1107 1108 /** 1109 * Set a UCalendar's current date. 1110 * The date is represented as a series of 32-bit integers. 1111 * @param cal The UCalendar to set. 1112 * @param year The desired year. 1113 * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY, 1114 * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER 1115 * @param date The desired day of the month. 1116 * @param status A pointer to an UErrorCode to receive any errors 1117 * @see ucal_getMillis 1118 * @see ucal_setMillis 1119 * @see ucal_setDateTime 1120 * @stable ICU 2.0 1121 */ 1122 U_CAPI void U_EXPORT2 1123 ucal_setDate(UCalendar* cal, 1124 int32_t year, 1125 int32_t month, 1126 int32_t date, 1127 UErrorCode* status); 1128 1129 /** 1130 * Set a UCalendar's current date. 1131 * The date is represented as a series of 32-bit integers. 1132 * @param cal The UCalendar to set. 1133 * @param year The desired year. 1134 * @param month The desired month; one of UCAL_JANUARY, UCAL_FEBRUARY, UCAL_MARCH, UCAL_APRIL, UCAL_MAY, 1135 * UCAL_JUNE, UCAL_JULY, UCAL_AUGUST, UCAL_SEPTEMBER, UCAL_OCTOBER, UCAL_NOVEMBER, UCAL_DECEMBER, UCAL_UNDECIMBER 1136 * @param date The desired day of the month. 1137 * @param hour The desired hour of day. 1138 * @param minute The desired minute. 1139 * @param second The desirec second. 1140 * @param status A pointer to an UErrorCode to receive any errors 1141 * @see ucal_getMillis 1142 * @see ucal_setMillis 1143 * @see ucal_setDate 1144 * @stable ICU 2.0 1145 */ 1146 U_CAPI void U_EXPORT2 1147 ucal_setDateTime(UCalendar* cal, 1148 int32_t year, 1149 int32_t month, 1150 int32_t date, 1151 int32_t hour, 1152 int32_t minute, 1153 int32_t second, 1154 UErrorCode* status); 1155 1156 /** 1157 * Returns true if two UCalendars are equivalent. Equivalent 1158 * UCalendars will behave identically, but they may be set to 1159 * different times. 1160 * @param cal1 The first of the UCalendars to compare. 1161 * @param cal2 The second of the UCalendars to compare. 1162 * @return true if cal1 and cal2 are equivalent, false otherwise. 1163 * @stable ICU 2.0 1164 */ 1165 U_CAPI UBool U_EXPORT2 1166 ucal_equivalentTo(const UCalendar* cal1, 1167 const UCalendar* cal2); 1168 1169 /** 1170 * Add a specified signed amount to a particular field in a UCalendar. 1171 * This can modify more significant fields in the calendar. 1172 * Adding a positive value always means moving forward in time, so for the Gregorian calendar, 1173 * starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces 1174 * the numeric value of the field itself). 1175 * @param cal The UCalendar to which to add. 1176 * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1177 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1178 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1179 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1180 * @param amount The signed amount to add to field. If the amount causes the value 1181 * to exceed to maximum or minimum values for that field, other fields are modified 1182 * to preserve the magnitude of the change. 1183 * @param status A pointer to an UErrorCode to receive any errors 1184 * @see ucal_roll 1185 * @stable ICU 2.0 1186 */ 1187 U_CAPI void U_EXPORT2 1188 ucal_add(UCalendar* cal, 1189 UCalendarDateFields field, 1190 int32_t amount, 1191 UErrorCode* status); 1192 1193 /** 1194 * Add a specified signed amount to a particular field in a UCalendar. 1195 * This will not modify more significant fields in the calendar. 1196 * Rolling by a positive value always means moving forward in time (unless the limit of the 1197 * field is reached, in which case it may pin or wrap), so for Gregorian calendar, 1198 * starting with 100 BC and rolling the year by +1 results in 99 BC. 1199 * When eras have a definite beginning and end (as in the Chinese calendar, or as in most eras in the 1200 * Japanese calendar) then rolling the year past either limit of the era will cause the year to wrap around. 1201 * When eras only have a limit at one end, then attempting to roll the year past that limit will result in 1202 * pinning the year at that limit. Note that for most calendars in which era 0 years move forward in time 1203 * (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to result in negative years for 1204 * era 0 (that is the only way to represent years before the calendar epoch). 1205 * @param cal The UCalendar to which to add. 1206 * @param field The field to which to add the signed value; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1207 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1208 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1209 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1210 * @param amount The signed amount to add to field. If the amount causes the value 1211 * to exceed to maximum or minimum values for that field, the field is pinned to a permissible 1212 * value. 1213 * @param status A pointer to an UErrorCode to receive any errors 1214 * @see ucal_add 1215 * @stable ICU 2.0 1216 */ 1217 U_CAPI void U_EXPORT2 1218 ucal_roll(UCalendar* cal, 1219 UCalendarDateFields field, 1220 int32_t amount, 1221 UErrorCode* status); 1222 1223 /** 1224 * Get the current value of a field from a UCalendar. 1225 * All fields are represented as 32-bit integers. 1226 * @param cal The UCalendar to query. 1227 * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1228 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1229 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1230 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1231 * @param status A pointer to an UErrorCode to receive any errors 1232 * @return The value of the desired field. 1233 * @see ucal_set 1234 * @see ucal_isSet 1235 * @see ucal_clearField 1236 * @see ucal_clear 1237 * @stable ICU 2.0 1238 */ 1239 U_CAPI int32_t U_EXPORT2 1240 ucal_get(const UCalendar* cal, 1241 UCalendarDateFields field, 1242 UErrorCode* status ); 1243 1244 /** 1245 * Set the value of a field in a UCalendar. 1246 * All fields are represented as 32-bit integers. 1247 * @param cal The UCalendar to set. 1248 * @param field The field to set; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1249 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1250 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1251 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1252 * @param value The desired value of field. 1253 * @see ucal_get 1254 * @see ucal_isSet 1255 * @see ucal_clearField 1256 * @see ucal_clear 1257 * @stable ICU 2.0 1258 */ 1259 U_CAPI void U_EXPORT2 1260 ucal_set(UCalendar* cal, 1261 UCalendarDateFields field, 1262 int32_t value); 1263 1264 /** 1265 * Determine if a field in a UCalendar is set. 1266 * All fields are represented as 32-bit integers. 1267 * @param cal The UCalendar to query. 1268 * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1269 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1270 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1271 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1272 * @return true if field is set, false otherwise. 1273 * @see ucal_get 1274 * @see ucal_set 1275 * @see ucal_clearField 1276 * @see ucal_clear 1277 * @stable ICU 2.0 1278 */ 1279 U_CAPI UBool U_EXPORT2 1280 ucal_isSet(const UCalendar* cal, 1281 UCalendarDateFields field); 1282 1283 /** 1284 * Clear a field in a UCalendar. 1285 * All fields are represented as 32-bit integers. 1286 * @param cal The UCalendar containing the field to clear. 1287 * @param field The field to clear; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1288 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1289 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1290 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1291 * @see ucal_get 1292 * @see ucal_set 1293 * @see ucal_isSet 1294 * @see ucal_clear 1295 * @stable ICU 2.0 1296 */ 1297 U_CAPI void U_EXPORT2 1298 ucal_clearField(UCalendar* cal, 1299 UCalendarDateFields field); 1300 1301 /** 1302 * Clear all fields in a UCalendar. 1303 * All fields are represented as 32-bit integers. 1304 * @param calendar The UCalendar to clear. 1305 * @see ucal_get 1306 * @see ucal_set 1307 * @see ucal_isSet 1308 * @see ucal_clearField 1309 * @stable ICU 2.0 1310 */ 1311 U_CAPI void U_EXPORT2 1312 ucal_clear(UCalendar* calendar); 1313 1314 /** 1315 * Possible limit values for a UCalendar 1316 * @stable ICU 2.0 1317 */ 1318 enum UCalendarLimitType { 1319 /** Minimum value */ 1320 UCAL_MINIMUM, 1321 /** Maximum value */ 1322 UCAL_MAXIMUM, 1323 /** Greatest minimum value */ 1324 UCAL_GREATEST_MINIMUM, 1325 /** Least maximum value */ 1326 UCAL_LEAST_MAXIMUM, 1327 /** Actual minimum value */ 1328 UCAL_ACTUAL_MINIMUM, 1329 /** Actual maximum value */ 1330 UCAL_ACTUAL_MAXIMUM 1331 }; 1332 1333 /** @stable ICU 2.0 */ 1334 typedef enum UCalendarLimitType UCalendarLimitType; 1335 1336 /** 1337 * Determine a limit for a field in a UCalendar. 1338 * A limit is a maximum or minimum value for a field. 1339 * @param cal The UCalendar to query. 1340 * @param field The desired field; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1341 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1342 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1343 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1344 * @param type The desired critical point; one of UCAL_MINIMUM, UCAL_MAXIMUM, UCAL_GREATEST_MINIMUM, 1345 * UCAL_LEAST_MAXIMUM, UCAL_ACTUAL_MINIMUM, UCAL_ACTUAL_MAXIMUM 1346 * @param status A pointer to an UErrorCode to receive any errors. 1347 * @return The requested value. 1348 * @stable ICU 2.0 1349 */ 1350 U_CAPI int32_t U_EXPORT2 1351 ucal_getLimit(const UCalendar* cal, 1352 UCalendarDateFields field, 1353 UCalendarLimitType type, 1354 UErrorCode* status); 1355 1356 /** Get the locale for this calendar object. You can choose between valid and actual locale. 1357 * @param cal The calendar object 1358 * @param type type of the locale we're looking for (valid or actual) 1359 * @param status error code for the operation 1360 * @return the locale name 1361 * @stable ICU 2.8 1362 */ 1363 U_CAPI const char * U_EXPORT2 1364 ucal_getLocaleByType(const UCalendar *cal, ULocDataLocaleType type, UErrorCode* status); 1365 1366 /** 1367 * Returns the timezone data version currently used by ICU. 1368 * @param status error code for the operation 1369 * @return the version string, such as "2007f" 1370 * @stable ICU 3.8 1371 */ 1372 U_CAPI const char * U_EXPORT2 1373 ucal_getTZDataVersion(UErrorCode* status); 1374 1375 /** 1376 * Returns the canonical system timezone ID or the normalized 1377 * custom time zone ID for the given time zone ID. 1378 * @param id The input timezone ID to be canonicalized. 1379 * @param len The length of id, or -1 if null-terminated. 1380 * @param result The buffer receives the canonical system timezone ID 1381 * or the custom timezone ID in normalized format. 1382 * @param resultCapacity The capacity of the result buffer. 1383 * @param isSystemID Receives if the given ID is a known system 1384 * timezone ID. 1385 * @param status Receives the status. When the given timezone ID 1386 * is neither a known system time zone ID nor a 1387 * valid custom timezone ID, U_ILLEGAL_ARGUMENT_ERROR 1388 * is set. 1389 * @return The result string length, not including the terminating 1390 * null. 1391 * @stable ICU 4.0 1392 */ 1393 U_CAPI int32_t U_EXPORT2 1394 ucal_getCanonicalTimeZoneID(const UChar* id, int32_t len, 1395 UChar* result, int32_t resultCapacity, UBool *isSystemID, UErrorCode* status); 1396 1397 #ifndef U_HIDE_DRAFT_API 1398 /** 1399 * Returns the preferred time zone ID in the IANA time zone database for the given time zone ID. 1400 * There are two types of preferred IDs. The first type is the one defined in zone.tab file, 1401 * such as "America/Los_Angeles". The second types is the one defined for zones not associated 1402 * with a specific region, but not defined with "Link" syntax such as "Etc/GMT+10". 1403 * 1404 *
UCAL_UNKNOWN_ZONE_ID
ucal_getCanonicalTimeZoneID
Note: For most of valid time zone IDs, this method returns an ID same as ucal_getCanonicalTimeZoneID(). 1405 * ucal_getCanonicalTimeZoneID() is based on canonical time zone IDs defined in Unicode CLDR. 1406 * These canonical time zone IDs in CLDR were based on very old version of the time zone database. 1407 * In the IANA time zone database, some IDs were updated since then. This API returns a newer 1408 * time zone ID. For example, CLDR defines "Asia/Calcutta" as the canonical time zone ID. This 1409 * method returns "Asia/Kolkata" instead. 1410 *
"Etc/Unknown" is a special time zone ID defined by CLDR. There are no corresponding zones 1411 * in the IANA time zone database. Therefore, this API returns U_ILLEGAL_ARGUMENT_ERROR when the 1412 * input ID is "Etc/Unknown". 1413 * 1414 * @param id The input time zone ID. 1415 * @param len The length of the input time zone ID. 1416 * @param result The buffer receives the preferred time zone ID in the IANA time zone database. 1417 * @param resultCapacity The capacity of the result buffer. 1418 * @param status Receives the status. When the given time zone ID is not a known system time zone 1419 * ID, U_ILLEGAL_ARGUMENT_ERROR is set. 1420 * @return The result string length, not including the terminating null. 1421 * @draft ICU 74 1422 */ 1423 U_CAPI int32_t U_EXPORT2 1424 ucal_getIanaTimeZoneID(const UChar* id, int32_t len, 1425 UChar* result, int32_t resultCapacity, UErrorCode* status); 1426 #endif // U_HIDE_DRAFT_API 1427 1428 /** 1429 * Get the resource keyword value string designating the calendar type for the UCalendar. 1430 * @param cal The UCalendar to query. 1431 * @param status The error code for the operation. 1432 * @return The resource keyword value string. 1433 * @stable ICU 4.2 1434 */ 1435 U_CAPI const char * U_EXPORT2 1436 ucal_getType(const UCalendar *cal, UErrorCode* status); 1437 1438 /** 1439 * Given a key and a locale, returns an array of string values in a preferred 1440 * order that would make a difference. These are all and only those values where 1441 * the open (creation) of the service with the locale formed from the input locale 1442 * plus input keyword and that value has different behavior than creation with the 1443 * input locale alone. 1444 * @param key one of the keys supported by this service. For now, only 1445 * "calendar" is supported. 1446 * @param locale the locale 1447 * @param commonlyUsed if set to true it will return only commonly used values 1448 * with the given locale in preferred order. Otherwise, 1449 * it will return all the available values for the locale. 1450 * @param status error status 1451 * @return a string enumeration over keyword values for the given key and the locale. 1452 * @stable ICU 4.2 1453 */ 1454 U_CAPI UEnumeration* U_EXPORT2 1455 ucal_getKeywordValuesForLocale(const char* key, 1456 const char* locale, 1457 UBool commonlyUsed, 1458 UErrorCode* status); 1459 1460 1461 /** Weekday types, as returned by ucal_getDayOfWeekType(). 1462 * @stable ICU 4.4 1463 */ 1464 enum UCalendarWeekdayType { 1465 /** 1466 * Designates a full weekday (no part of the day is included in the weekend). 1467 * @stable ICU 4.4 1468 */ 1469 UCAL_WEEKDAY, 1470 /** 1471 * Designates a full weekend day (the entire day is included in the weekend). 1472 * @stable ICU 4.4 1473 */ 1474 UCAL_WEEKEND, 1475 /** 1476 * Designates a day that starts as a weekday and transitions to the weekend. 1477 * Call ucal_getWeekendTransition() to get the time of transition. 1478 * @stable ICU 4.4 1479 */ 1480 UCAL_WEEKEND_ONSET, 1481 /** 1482 * Designates a day that starts as the weekend and transitions to a weekday. 1483 * Call ucal_getWeekendTransition() to get the time of transition. 1484 * @stable ICU 4.4 1485 */ 1486 UCAL_WEEKEND_CEASE 1487 }; 1488 1489 /** @stable ICU 4.4 */ 1490 typedef enum UCalendarWeekdayType UCalendarWeekdayType; 1491 1492 /** 1493 * Returns whether the given day of the week is a weekday, a weekend day, 1494 * or a day that transitions from one to the other, for the locale and 1495 * calendar system associated with this UCalendar (the locale's region is 1496 * often the most determinant factor). If a transition occurs at midnight, 1497 * then the days before and after the transition will have the 1498 * type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time 1499 * other than midnight, then the day of the transition will have 1500 * the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the 1501 * function ucal_getWeekendTransition() will return the point of 1502 * transition. 1503 * @param cal The UCalendar to query. 1504 * @param dayOfWeek The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY). 1505 * @param status The error code for the operation. 1506 * @return The UCalendarWeekdayType for the day of the week. 1507 * @stable ICU 4.4 1508 */ 1509 U_CAPI UCalendarWeekdayType U_EXPORT2 1510 ucal_getDayOfWeekType(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode* status); 1511 1512 /** 1513 * Returns the time during the day at which the weekend begins or ends in 1514 * this calendar system. If ucal_getDayOfWeekType() returns UCAL_WEEKEND_ONSET 1515 * for the specified dayOfWeek, return the time at which the weekend begins. 1516 * If ucal_getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek, 1517 * return the time at which the weekend ends. If ucal_getDayOfWeekType() returns 1518 * some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition 1519 * (U_ILLEGAL_ARGUMENT_ERROR). 1520 * @param cal The UCalendar to query. 1521 * @param dayOfWeek The day of the week for which the weekend transition time is 1522 * desired (UCAL_SUNDAY..UCAL_SATURDAY). 1523 * @param status The error code for the operation. 1524 * @return The milliseconds after midnight at which the weekend begins or ends. 1525 * @stable ICU 4.4 1526 */ 1527 U_CAPI int32_t U_EXPORT2 1528 ucal_getWeekendTransition(const UCalendar *cal, UCalendarDaysOfWeek dayOfWeek, UErrorCode *status); 1529 1530 /** 1531 * Returns true if the given UDate is in the weekend in 1532 * this calendar system. 1533 * @param cal The UCalendar to query. 1534 * @param date The UDate in question. 1535 * @param status The error code for the operation. 1536 * @return true if the given UDate is in the weekend in 1537 * this calendar system, false otherwise. 1538 * @stable ICU 4.4 1539 */ 1540 U_CAPI UBool U_EXPORT2 1541 ucal_isWeekend(const UCalendar *cal, UDate date, UErrorCode *status); 1542 1543 /** 1544 * Return the difference between the target time and the time this calendar object is currently set to. 1545 * If the target time is after the current calendar setting, the the returned value will be positive. 1546 * The field parameter specifies the units of the return value. For example, if field is UCAL_MONTH 1547 * and ucal_getFieldDifference returns 3, then the target time is 3 to less than 4 months after the 1548 * current calendar setting. 1549 * 1550 * As a side effect of this call, this calendar is advanced toward target by the given amount. That is, 1551 * calling this function has the side effect of calling ucal_add on this calendar with the specified 1552 * field and an amount equal to the return value from this function. 1553 * 1554 * A typical way of using this function is to call it first with the largest field of interest, then 1555 * with progressively smaller fields. 1556 * 1557 * @param cal The UCalendar to compare and update. 1558 * @param target The target date to compare to the current calendar setting. 1559 * @param field The field to compare; one of UCAL_ERA, UCAL_YEAR, UCAL_MONTH, 1560 * UCAL_WEEK_OF_YEAR, UCAL_WEEK_OF_MONTH, UCAL_DATE, UCAL_DAY_OF_YEAR, UCAL_DAY_OF_WEEK, 1561 * UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_AM_PM, UCAL_HOUR, UCAL_HOUR_OF_DAY, UCAL_MINUTE, UCAL_SECOND, 1562 * UCAL_MILLISECOND, UCAL_ZONE_OFFSET, UCAL_DST_OFFSET. 1563 * @param status A pointer to an UErrorCode to receive any errors 1564 * @return The date difference for the specified field. 1565 * @stable ICU 4.8 1566 */ 1567 U_CAPI int32_t U_EXPORT2 1568 ucal_getFieldDifference(UCalendar* cal, 1569 UDate target, 1570 UCalendarDateFields field, 1571 UErrorCode* status); 1572 1573 /** 1574 * Time zone transition types for ucal_getTimeZoneTransitionDate 1575 * @stable ICU 50 1576 */ 1577 enum UTimeZoneTransitionType { 1578 /** 1579 * Get the next transition after the current date, 1580 * i.e. excludes the current date 1581 * @stable ICU 50 1582 */ 1583 UCAL_TZ_TRANSITION_NEXT, 1584 /** 1585 * Get the next transition on or after the current date, 1586 * i.e. may include the current date 1587 * @stable ICU 50 1588 */ 1589 UCAL_TZ_TRANSITION_NEXT_INCLUSIVE, 1590 /** 1591 * Get the previous transition before the current date, 1592 * i.e. excludes the current date 1593 * @stable ICU 50 1594 */ 1595 UCAL_TZ_TRANSITION_PREVIOUS, 1596 /** 1597 * Get the previous transition on or before the current date, 1598 * i.e. may include the current date 1599 * @stable ICU 50 1600 */ 1601 UCAL_TZ_TRANSITION_PREVIOUS_INCLUSIVE 1602 }; 1603 1604 typedef enum UTimeZoneTransitionType UTimeZoneTransitionType; /**< @stable ICU 50 */ 1605 1606 /** 1607 * Get the UDate for the next/previous time zone transition relative to 1608 * the calendar's current date, in the time zone to which the calendar 1609 * is currently set. If there is no known time zone transition of the 1610 * requested type relative to the calendar's date, the function returns 1611 * false. 1612 * @param cal The UCalendar to query. 1613 * @param type The type of transition desired. 1614 * @param transition A pointer to a UDate to be set to the transition time. 1615 * If the function returns false, the value set is unspecified. 1616 * @param status A pointer to a UErrorCode to receive any errors. 1617 * @return true if a valid transition time is set in *transition, false 1618 * otherwise. 1619 * @stable ICU 50 1620 */ 1621 U_CAPI UBool U_EXPORT2 1622 ucal_getTimeZoneTransitionDate(const UCalendar* cal, UTimeZoneTransitionType type, 1623 UDate* transition, UErrorCode* status); 1624 1625 /** 1626 * Converts a system time zone ID to an equivalent Windows time zone ID. For example, 1627 * Windows time zone ID "Pacific Standard Time" is returned for input "America/Los_Angeles". 1628 * 1629 *
There are system time zones that cannot be mapped to Windows zones. When the input 1630 * system time zone ID is unknown or unmappable to a Windows time zone, then this 1631 * function returns 0 as the result length, but the operation itself remains successful 1632 * (no error status set on return). 1633 * 1634 *
This implementation utilizes 1635 * Zone-Tzid mapping data. The mapping data is updated time to time. To get the latest changes, 1636 * please read the ICU user guide section 1637 * Updating the Time Zone Data. 1638 * 1639 * @param id A system time zone ID. 1640 * @param len The length of id, or -1 if null-terminated. 1641 * @param winid A buffer to receive a Windows time zone ID. 1642 * @param winidCapacity The capacity of the result buffer winid. 1643 * @param status Receives the status. 1644 * @return The result string length, not including the terminating null. 1645 * @see ucal_getTimeZoneIDForWindowsID 1646 * 1647 * @stable ICU 52 1648 */ 1649 U_CAPI int32_t U_EXPORT2 1650 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len, 1651 UChar* winid, int32_t winidCapacity, UErrorCode* status); 1652 1653 /** 1654 * Converts a Windows time zone ID to an equivalent system time zone ID 1655 * for a region. For example, system time zone ID "America/Los_Angeles" is returned 1656 * for input Windows ID "Pacific Standard Time" and region "US" (or null), 1657 * "America/Vancouver" is returned for the same Windows ID "Pacific Standard Time" and 1658 * region "CA". 1659 * 1660 *
id
winid
null
Not all Windows time zones can be mapped to system time zones. When the input 1661 * Windows time zone ID is unknown or unmappable to a system time zone, then this 1662 * function returns 0 as the result length, but the operation itself remains successful 1663 * (no error status set on return). 1664 * 1665 *
This implementation utilizes 1666 * Zone-Tzid mapping data. The mapping data is updated time to time. To get the latest changes, 1667 * please read the ICU user guide section 1668 * Updating the Time Zone Data. 1669 * 1670 * @param winid A Windows time zone ID. 1671 * @param len The length of winid, or -1 if null-terminated. 1672 * @param region A null-terminated region code, or NULL if no regional preference. 1673 * @param id A buffer to receive a system time zone ID. 1674 * @param idCapacity The capacity of the result buffer id. 1675 * @param status Receives the status. 1676 * @return The result string length, not including the terminating null. 1677 * @see ucal_getWindowsTimeZoneID 1678 * 1679 * @stable ICU 52 1680 */ 1681 U_CAPI int32_t U_EXPORT2 1682 ucal_getTimeZoneIDForWindowsID(const UChar* winid, int32_t len, const char* region, 1683 UChar* id, int32_t idCapacity, UErrorCode* status); 1684 1685 /** 1686 * Options used by ucal_getTimeZoneOffsetFromLocal and BasicTimeZone::getOffsetFromLocal() 1687 * to specify how to interpret an input time when it does not exist, or when it is ambiguous, 1688 * around a time zone transition. 1689 * @stable ICU 69 1690 */ 1691 enum UTimeZoneLocalOption { 1692 /** 1693 * An input time is always interpreted as local time before 1694 * a time zone transition. 1695 * @stable ICU 69 1696 */ 1697 UCAL_TZ_LOCAL_FORMER = 0x04, 1698 /** 1699 * An input time is always interpreted as local time after 1700 * a time zone transition. 1701 * @stable ICU 69 1702 */ 1703 UCAL_TZ_LOCAL_LATTER = 0x0C, 1704 /** 1705 * An input time is interpreted as standard time when local 1706 * time is switched to/from daylight saving time. When both 1707 * sides of a time zone transition are standard time, 1708 * or daylight saving time, the local time before the 1709 * transition is used. 1710 * @stable ICU 69 1711 */ 1712 UCAL_TZ_LOCAL_STANDARD_FORMER = UCAL_TZ_LOCAL_FORMER | 0x01, 1713 /** 1714 * An input time is interpreted as standard time when local 1715 * time is switched to/from daylight saving time. When both 1716 * sides of a time zone transition are standard time, 1717 * or daylight saving time, the local time after the 1718 * transition is used. 1719 * @stable ICU 69 1720 */ 1721 UCAL_TZ_LOCAL_STANDARD_LATTER = UCAL_TZ_LOCAL_LATTER | 0x01, 1722 /** 1723 * An input time is interpreted as daylight saving time when 1724 * local time is switched to/from standard time. When both 1725 * sides of a time zone transition are standard time, 1726 * or daylight saving time, the local time before the 1727 * transition is used. 1728 * @stable ICU 69 1729 */ 1730 UCAL_TZ_LOCAL_DAYLIGHT_FORMER = UCAL_TZ_LOCAL_FORMER | 0x03, 1731 /** 1732 * An input time is interpreted as daylight saving time when 1733 * local time is switched to/from standard time. When both 1734 * sides of a time zone transition are standard time, 1735 * or daylight saving time, the local time after the 1736 * transition is used. 1737 * @stable ICU 69 1738 */ 1739 UCAL_TZ_LOCAL_DAYLIGHT_LATTER = UCAL_TZ_LOCAL_LATTER | 0x03, 1740 }; 1741 typedef enum UTimeZoneLocalOption UTimeZoneLocalOption; /**< @stable ICU 69 */ 1742 1743 /** 1744 * Returns the time zone raw and GMT offset for the given moment 1745 * in time. Upon return, local-millis = GMT-millis + rawOffset + 1746 * dstOffset. All computations are performed in the proleptic 1747 * Gregorian calendar. 1748 * 1749 * @param cal The UCalendar which specify the local date and time value to query. 1750 * @param nonExistingTimeOpt The option to indicate how to interpret the date and 1751 * time in the calendar represent a local time that skipped at a positive time 1752 * zone transitions (e.g. when the daylight saving time starts or the time zone 1753 * offset is increased due to a time zone rule change). 1754 * @param duplicatedTimeOpt The option to indicate how to interpret the date and 1755 * time in the calendar represent a local time that repeating multiple times at a 1756 * negative time zone transition (e.g. when the daylight saving time ends or the 1757 * time zone offset is decreased due to a time zone rule change) 1758 * @param rawOffset output parameter to receive the raw offset, that 1759 * is, the offset not including DST adjustments. 1760 * If the status is set to one of the error code, the value set is unspecified. 1761 * @param dstOffset output parameter to receive the DST offset, 1762 * that is, the offset to be added to `rawOffset' to obtain the 1763 * total offset between local and GMT time. If DST is not in 1764 * effect, this value is zero; otherwise it is a positive value, 1765 * typically one hour. 1766 * If the status is set to one of the error code, the value set is unspecified. 1767 * @param status A pointer to a UErrorCode to receive any errors. 1768 * @stable ICU 69 1769 */ 1770 U_CAPI void U_EXPORT2 1771 ucal_getTimeZoneOffsetFromLocal( 1772 const UCalendar* cal, 1773 UTimeZoneLocalOption nonExistingTimeOpt, 1774 UTimeZoneLocalOption duplicatedTimeOpt, 1775 int32_t* rawOffset, int32_t* dstOffset, UErrorCode* status); 1776 1777 #endif /* #if !UCONFIG_NO_FORMATTING */ 1778 1779 #endif
NULL