jpayne@69
|
1 // © 2016 and later: Unicode, Inc. and others.
|
jpayne@69
|
2 // License & terms of use: http://www.unicode.org/copyright.html
|
jpayne@69
|
3 /*
|
jpayne@69
|
4 ********************************************************************************
|
jpayne@69
|
5 * Copyright (C) 1997-2014, International Business Machines
|
jpayne@69
|
6 * Corporation and others. All Rights Reserved.
|
jpayne@69
|
7 ********************************************************************************
|
jpayne@69
|
8 *
|
jpayne@69
|
9 * File CALENDAR.H
|
jpayne@69
|
10 *
|
jpayne@69
|
11 * Modification History:
|
jpayne@69
|
12 *
|
jpayne@69
|
13 * Date Name Description
|
jpayne@69
|
14 * 04/22/97 aliu Expanded and corrected comments and other header
|
jpayne@69
|
15 * contents.
|
jpayne@69
|
16 * 05/01/97 aliu Made equals(), before(), after() arguments const.
|
jpayne@69
|
17 * 05/20/97 aliu Replaced fAreFieldsSet with fAreFieldsInSync and
|
jpayne@69
|
18 * fAreAllFieldsSet.
|
jpayne@69
|
19 * 07/27/98 stephen Sync up with JDK 1.2
|
jpayne@69
|
20 * 11/15/99 weiv added YEAR_WOY and DOW_LOCAL
|
jpayne@69
|
21 * to EDateFields
|
jpayne@69
|
22 * 8/19/2002 srl Removed Javaisms
|
jpayne@69
|
23 * 11/07/2003 srl Update, clean up documentation.
|
jpayne@69
|
24 ********************************************************************************
|
jpayne@69
|
25 */
|
jpayne@69
|
26
|
jpayne@69
|
27 #ifndef CALENDAR_H
|
jpayne@69
|
28 #define CALENDAR_H
|
jpayne@69
|
29
|
jpayne@69
|
30 #include "unicode/utypes.h"
|
jpayne@69
|
31
|
jpayne@69
|
32 #if U_SHOW_CPLUSPLUS_API
|
jpayne@69
|
33
|
jpayne@69
|
34 /**
|
jpayne@69
|
35 * \file
|
jpayne@69
|
36 * \brief C++ API: Calendar object
|
jpayne@69
|
37 */
|
jpayne@69
|
38 #if !UCONFIG_NO_FORMATTING
|
jpayne@69
|
39
|
jpayne@69
|
40 #include "unicode/uobject.h"
|
jpayne@69
|
41 #include "unicode/locid.h"
|
jpayne@69
|
42 #include "unicode/timezone.h"
|
jpayne@69
|
43 #include "unicode/ucal.h"
|
jpayne@69
|
44 #include "unicode/umisc.h"
|
jpayne@69
|
45
|
jpayne@69
|
46 U_NAMESPACE_BEGIN
|
jpayne@69
|
47
|
jpayne@69
|
48 class ICUServiceFactory;
|
jpayne@69
|
49
|
jpayne@69
|
50 /**
|
jpayne@69
|
51 * @internal
|
jpayne@69
|
52 */
|
jpayne@69
|
53 typedef int32_t UFieldResolutionTable[12][8];
|
jpayne@69
|
54
|
jpayne@69
|
55 class BasicTimeZone;
|
jpayne@69
|
56 /**
|
jpayne@69
|
57 * `Calendar` is an abstract base class for converting between
|
jpayne@69
|
58 * a `UDate` object and a set of integer fields such as
|
jpayne@69
|
59 * `YEAR`, `MONTH`, `DAY`, `HOUR`, and so on.
|
jpayne@69
|
60 * (A `UDate` object represents a specific instant in
|
jpayne@69
|
61 * time with millisecond precision. See UDate
|
jpayne@69
|
62 * for information about the `UDate` class.)
|
jpayne@69
|
63 *
|
jpayne@69
|
64 * Subclasses of `Calendar` interpret a `UDate`
|
jpayne@69
|
65 * according to the rules of a specific calendar system.
|
jpayne@69
|
66 * The most commonly used subclass of `Calendar` is
|
jpayne@69
|
67 * `GregorianCalendar`. Other subclasses could represent
|
jpayne@69
|
68 * the various types of lunar calendars in use in many parts of the world.
|
jpayne@69
|
69 *
|
jpayne@69
|
70 * **NOTE**: (ICU 2.6) The subclass interface should be considered unstable -
|
jpayne@69
|
71 * it WILL change.
|
jpayne@69
|
72 *
|
jpayne@69
|
73 * Like other locale-sensitive classes, `Calendar` provides a
|
jpayne@69
|
74 * static method, `createInstance`, for getting a generally useful
|
jpayne@69
|
75 * object of this type. `Calendar`'s `createInstance` method
|
jpayne@69
|
76 * returns the appropriate `Calendar` subclass whose
|
jpayne@69
|
77 * time fields have been initialized with the current date and time:
|
jpayne@69
|
78 *
|
jpayne@69
|
79 * Calendar *rightNow = Calendar::createInstance(errCode);
|
jpayne@69
|
80 *
|
jpayne@69
|
81 * A `Calendar` object can produce all the time field values
|
jpayne@69
|
82 * needed to implement the date-time formatting for a particular language
|
jpayne@69
|
83 * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
|
jpayne@69
|
84 *
|
jpayne@69
|
85 * When computing a `UDate` from time fields, some special circumstances
|
jpayne@69
|
86 * may arise: there may be insufficient information to compute the
|
jpayne@69
|
87 * `UDate` (such as only year and month but no day in the month),
|
jpayne@69
|
88 * there may be inconsistent information (such as "Tuesday, July 15, 1996"
|
jpayne@69
|
89 * -- July 15, 1996 is actually a Monday), or the input time might be ambiguous
|
jpayne@69
|
90 * because of time zone transition.
|
jpayne@69
|
91 *
|
jpayne@69
|
92 * **Insufficient information.** The calendar will use default
|
jpayne@69
|
93 * information to specify the missing fields. This may vary by calendar; for
|
jpayne@69
|
94 * the Gregorian calendar, the default for a field is the same as that of the
|
jpayne@69
|
95 * start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc.
|
jpayne@69
|
96 *
|
jpayne@69
|
97 * **Inconsistent information.** If fields conflict, the calendar
|
jpayne@69
|
98 * will give preference to fields set more recently. For example, when
|
jpayne@69
|
99 * determining the day, the calendar will look for one of the following
|
jpayne@69
|
100 * combinations of fields. The most recent combination, as determined by the
|
jpayne@69
|
101 * most recently set single field, will be used.
|
jpayne@69
|
102 *
|
jpayne@69
|
103 * MONTH + DAY_OF_MONTH
|
jpayne@69
|
104 * MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
|
jpayne@69
|
105 * MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
|
jpayne@69
|
106 * DAY_OF_YEAR
|
jpayne@69
|
107 * DAY_OF_WEEK + WEEK_OF_YEAR
|
jpayne@69
|
108 *
|
jpayne@69
|
109 * For the time of day:
|
jpayne@69
|
110 *
|
jpayne@69
|
111 * HOUR_OF_DAY
|
jpayne@69
|
112 * AM_PM + HOUR
|
jpayne@69
|
113 *
|
jpayne@69
|
114 * **Ambiguous Wall Clock Time.** When time offset from UTC has
|
jpayne@69
|
115 * changed, it produces an ambiguous time slot around the transition. For example,
|
jpayne@69
|
116 * many US locations observe daylight saving time. On the date switching to daylight
|
jpayne@69
|
117 * saving time in US, wall clock time jumps from 12:59 AM (standard) to 2:00 AM
|
jpayne@69
|
118 * (daylight). Therefore, wall clock time from 1:00 AM to 1:59 AM do not exist on
|
jpayne@69
|
119 * the date. When the input wall time fall into this missing time slot, the ICU
|
jpayne@69
|
120 * Calendar resolves the time using the UTC offset before the transition by default.
|
jpayne@69
|
121 * In this example, 1:30 AM is interpreted as 1:30 AM standard time (non-exist),
|
jpayne@69
|
122 * so the final result will be 2:30 AM daylight time.
|
jpayne@69
|
123 *
|
jpayne@69
|
124 * On the date switching back to standard time, wall clock time is moved back one
|
jpayne@69
|
125 * hour at 2:00 AM. So wall clock time from 1:00 AM to 1:59 AM occur twice. In this
|
jpayne@69
|
126 * case, the ICU Calendar resolves the time using the UTC offset after the transition
|
jpayne@69
|
127 * by default. For example, 1:30 AM on the date is resolved as 1:30 AM standard time.
|
jpayne@69
|
128 *
|
jpayne@69
|
129 * Ambiguous wall clock time resolution behaviors can be customized by Calendar APIs
|
jpayne@69
|
130 * {@link #setRepeatedWallTimeOption} and {@link #setSkippedWallTimeOption}.
|
jpayne@69
|
131 * These methods are available in ICU 49 or later versions.
|
jpayne@69
|
132 *
|
jpayne@69
|
133 * **Note:** for some non-Gregorian calendars, different
|
jpayne@69
|
134 * fields may be necessary for complete disambiguation. For example, a full
|
jpayne@69
|
135 * specification of the historical Arabic astronomical calendar requires year,
|
jpayne@69
|
136 * month, day-of-month *and* day-of-week in some cases.
|
jpayne@69
|
137 *
|
jpayne@69
|
138 * **Note:** There are certain possible ambiguities in
|
jpayne@69
|
139 * interpretation of certain singular times, which are resolved in the
|
jpayne@69
|
140 * following ways:
|
jpayne@69
|
141 *
|
jpayne@69
|
142 * 1. 24:00:00 "belongs" to the following day. That is,
|
jpayne@69
|
143 * 23:59 on Dec 31, 1969 < 24:00 on Jan 1, 1970 < 24:01:00 on Jan 1, 1970
|
jpayne@69
|
144 * 2. Although historically not precise, midnight also belongs to "am",
|
jpayne@69
|
145 * and noon belongs to "pm", so on the same day,
|
jpayne@69
|
146 * 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm
|
jpayne@69
|
147 *
|
jpayne@69
|
148 * The date or time format strings are not part of the definition of a
|
jpayne@69
|
149 * calendar, as those must be modifiable or overridable by the user at
|
jpayne@69
|
150 * runtime. Use `DateFormat` to format dates.
|
jpayne@69
|
151 *
|
jpayne@69
|
152 * `Calendar` provides an API for field "rolling", where fields
|
jpayne@69
|
153 * can be incremented or decremented, but wrap around. For example, rolling the
|
jpayne@69
|
154 * month up in the date December 12, **1996** results in
|
jpayne@69
|
155 * January 12, **1996**.
|
jpayne@69
|
156 *
|
jpayne@69
|
157 * `Calendar` also provides a date arithmetic function for
|
jpayne@69
|
158 * adding the specified (signed) amount of time to a particular time field.
|
jpayne@69
|
159 * For example, subtracting 5 days from the date `September 12, 1996`
|
jpayne@69
|
160 * results in `September 7, 1996`.
|
jpayne@69
|
161 *
|
jpayne@69
|
162 * ***Supported range***
|
jpayne@69
|
163 *
|
jpayne@69
|
164 * The allowable range of `Calendar` has been narrowed. `GregorianCalendar` used
|
jpayne@69
|
165 * to attempt to support the range of dates with millisecond values from
|
jpayne@69
|
166 * `Long.MIN_VALUE` to `Long.MAX_VALUE`. The new `Calendar` protocol specifies the
|
jpayne@69
|
167 * maximum range of supportable dates as those having Julian day numbers
|
jpayne@69
|
168 * of `-0x7F000000` to `+0x7F000000`. This corresponds to years from ~5,800,000 BCE
|
jpayne@69
|
169 * to ~5,800,000 CE. Programmers should use the protected constants in `Calendar` to
|
jpayne@69
|
170 * specify an extremely early or extremely late date.
|
jpayne@69
|
171 *
|
jpayne@69
|
172 * <p>
|
jpayne@69
|
173 * The Japanese calendar uses a combination of era name and year number.
|
jpayne@69
|
174 * When an emperor of Japan abdicates and a new emperor ascends the throne,
|
jpayne@69
|
175 * a new era is declared and year number is reset to 1. Even if the date of
|
jpayne@69
|
176 * abdication is scheduled ahead of time, the new era name might not be
|
jpayne@69
|
177 * announced until just before the date. In such case, ICU4C may include
|
jpayne@69
|
178 * a start date of future era without actual era name, but not enabled
|
jpayne@69
|
179 * by default. ICU4C users who want to test the behavior of the future era
|
jpayne@69
|
180 * can enable the tentative era by:
|
jpayne@69
|
181 * <ul>
|
jpayne@69
|
182 * <li>Environment variable <code>ICU_ENABLE_TENTATIVE_ERA=true</code>.</li>
|
jpayne@69
|
183 * </ul>
|
jpayne@69
|
184 *
|
jpayne@69
|
185 * @stable ICU 2.0
|
jpayne@69
|
186 */
|
jpayne@69
|
187 class U_I18N_API Calendar : public UObject {
|
jpayne@69
|
188 public:
|
jpayne@69
|
189 #ifndef U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
190 /**
|
jpayne@69
|
191 * Field IDs for date and time. Used to specify date/time fields. ERA is calendar
|
jpayne@69
|
192 * specific. Example ranges given are for illustration only; see specific Calendar
|
jpayne@69
|
193 * subclasses for actual ranges.
|
jpayne@69
|
194 * @deprecated ICU 2.6. Use C enum UCalendarDateFields defined in ucal.h
|
jpayne@69
|
195 */
|
jpayne@69
|
196 enum EDateFields {
|
jpayne@69
|
197 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
198 /*
|
jpayne@69
|
199 * ERA may be defined on other platforms. To avoid any potential problems undefined it here.
|
jpayne@69
|
200 */
|
jpayne@69
|
201 #ifdef ERA
|
jpayne@69
|
202 #undef ERA
|
jpayne@69
|
203 #endif
|
jpayne@69
|
204 ERA, // Example: 0..1
|
jpayne@69
|
205 YEAR, // Example: 1..big number
|
jpayne@69
|
206 MONTH, // Example: 0..11
|
jpayne@69
|
207 WEEK_OF_YEAR, // Example: 1..53
|
jpayne@69
|
208 WEEK_OF_MONTH, // Example: 1..4
|
jpayne@69
|
209 DATE, // Example: 1..31
|
jpayne@69
|
210 DAY_OF_YEAR, // Example: 1..365
|
jpayne@69
|
211 DAY_OF_WEEK, // Example: 1..7
|
jpayne@69
|
212 DAY_OF_WEEK_IN_MONTH, // Example: 1..4, may be specified as -1
|
jpayne@69
|
213 AM_PM, // Example: 0..1
|
jpayne@69
|
214 HOUR, // Example: 0..11
|
jpayne@69
|
215 HOUR_OF_DAY, // Example: 0..23
|
jpayne@69
|
216 MINUTE, // Example: 0..59
|
jpayne@69
|
217 SECOND, // Example: 0..59
|
jpayne@69
|
218 MILLISECOND, // Example: 0..999
|
jpayne@69
|
219 ZONE_OFFSET, // Example: -12*U_MILLIS_PER_HOUR..12*U_MILLIS_PER_HOUR
|
jpayne@69
|
220 DST_OFFSET, // Example: 0 or U_MILLIS_PER_HOUR
|
jpayne@69
|
221 YEAR_WOY, // 'Y' Example: 1..big number - Year of Week of Year
|
jpayne@69
|
222 DOW_LOCAL, // 'e' Example: 1..7 - Day of Week / Localized
|
jpayne@69
|
223
|
jpayne@69
|
224 EXTENDED_YEAR,
|
jpayne@69
|
225 JULIAN_DAY,
|
jpayne@69
|
226 MILLISECONDS_IN_DAY,
|
jpayne@69
|
227 IS_LEAP_MONTH,
|
jpayne@69
|
228
|
jpayne@69
|
229 FIELD_COUNT = UCAL_FIELD_COUNT // See ucal.h for other fields.
|
jpayne@69
|
230 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
231 };
|
jpayne@69
|
232 #endif // U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
233
|
jpayne@69
|
234 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
235 /**
|
jpayne@69
|
236 * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients
|
jpayne@69
|
237 * who create locale resources for the field of first-day-of-week should be aware of
|
jpayne@69
|
238 * this. For instance, in US locale, first-day-of-week is set to 1, i.e., SUNDAY.
|
jpayne@69
|
239 * @deprecated ICU 2.6. Use C enum UCalendarDaysOfWeek defined in ucal.h
|
jpayne@69
|
240 */
|
jpayne@69
|
241 enum EDaysOfWeek {
|
jpayne@69
|
242 SUNDAY = 1,
|
jpayne@69
|
243 MONDAY,
|
jpayne@69
|
244 TUESDAY,
|
jpayne@69
|
245 WEDNESDAY,
|
jpayne@69
|
246 THURSDAY,
|
jpayne@69
|
247 FRIDAY,
|
jpayne@69
|
248 SATURDAY
|
jpayne@69
|
249 };
|
jpayne@69
|
250
|
jpayne@69
|
251 /**
|
jpayne@69
|
252 * Useful constants for month. Note: Calendar month is 0-based.
|
jpayne@69
|
253 * @deprecated ICU 2.6. Use C enum UCalendarMonths defined in ucal.h
|
jpayne@69
|
254 */
|
jpayne@69
|
255 enum EMonths {
|
jpayne@69
|
256 JANUARY,
|
jpayne@69
|
257 FEBRUARY,
|
jpayne@69
|
258 MARCH,
|
jpayne@69
|
259 APRIL,
|
jpayne@69
|
260 MAY,
|
jpayne@69
|
261 JUNE,
|
jpayne@69
|
262 JULY,
|
jpayne@69
|
263 AUGUST,
|
jpayne@69
|
264 SEPTEMBER,
|
jpayne@69
|
265 OCTOBER,
|
jpayne@69
|
266 NOVEMBER,
|
jpayne@69
|
267 DECEMBER,
|
jpayne@69
|
268 UNDECIMBER
|
jpayne@69
|
269 };
|
jpayne@69
|
270
|
jpayne@69
|
271 /**
|
jpayne@69
|
272 * Useful constants for hour in 12-hour clock. Used in GregorianCalendar.
|
jpayne@69
|
273 * @deprecated ICU 2.6. Use C enum UCalendarAMPMs defined in ucal.h
|
jpayne@69
|
274 */
|
jpayne@69
|
275 enum EAmpm {
|
jpayne@69
|
276 AM,
|
jpayne@69
|
277 PM
|
jpayne@69
|
278 };
|
jpayne@69
|
279 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
280
|
jpayne@69
|
281 /**
|
jpayne@69
|
282 * destructor
|
jpayne@69
|
283 * @stable ICU 2.0
|
jpayne@69
|
284 */
|
jpayne@69
|
285 virtual ~Calendar();
|
jpayne@69
|
286
|
jpayne@69
|
287 /**
|
jpayne@69
|
288 * Create and return a polymorphic copy of this calendar.
|
jpayne@69
|
289 *
|
jpayne@69
|
290 * @return a polymorphic copy of this calendar.
|
jpayne@69
|
291 * @stable ICU 2.0
|
jpayne@69
|
292 */
|
jpayne@69
|
293 virtual Calendar* clone() const = 0;
|
jpayne@69
|
294
|
jpayne@69
|
295 /**
|
jpayne@69
|
296 * Creates a Calendar using the default timezone and locale. Clients are responsible
|
jpayne@69
|
297 * for deleting the object returned.
|
jpayne@69
|
298 *
|
jpayne@69
|
299 * @param success Indicates the success/failure of Calendar creation. Filled in
|
jpayne@69
|
300 * with U_ZERO_ERROR if created successfully, set to a failure result
|
jpayne@69
|
301 * otherwise. U_MISSING_RESOURCE_ERROR will be returned if the resource data
|
jpayne@69
|
302 * requests a calendar type which has not been installed.
|
jpayne@69
|
303 * @return A Calendar if created successfully. NULL otherwise.
|
jpayne@69
|
304 * @stable ICU 2.0
|
jpayne@69
|
305 */
|
jpayne@69
|
306 static Calendar* U_EXPORT2 createInstance(UErrorCode& success);
|
jpayne@69
|
307
|
jpayne@69
|
308 /**
|
jpayne@69
|
309 * Creates a Calendar using the given timezone and the default locale.
|
jpayne@69
|
310 * The Calendar takes ownership of zoneToAdopt; the
|
jpayne@69
|
311 * client must not delete it.
|
jpayne@69
|
312 *
|
jpayne@69
|
313 * @param zoneToAdopt The given timezone to be adopted.
|
jpayne@69
|
314 * @param success Indicates the success/failure of Calendar creation. Filled in
|
jpayne@69
|
315 * with U_ZERO_ERROR if created successfully, set to a failure result
|
jpayne@69
|
316 * otherwise.
|
jpayne@69
|
317 * @return A Calendar if created successfully. NULL otherwise.
|
jpayne@69
|
318 * @stable ICU 2.0
|
jpayne@69
|
319 */
|
jpayne@69
|
320 static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, UErrorCode& success);
|
jpayne@69
|
321
|
jpayne@69
|
322 /**
|
jpayne@69
|
323 * Creates a Calendar using the given timezone and the default locale. The TimeZone
|
jpayne@69
|
324 * is _not_ adopted; the client is still responsible for deleting it.
|
jpayne@69
|
325 *
|
jpayne@69
|
326 * @param zone The timezone.
|
jpayne@69
|
327 * @param success Indicates the success/failure of Calendar creation. Filled in
|
jpayne@69
|
328 * with U_ZERO_ERROR if created successfully, set to a failure result
|
jpayne@69
|
329 * otherwise.
|
jpayne@69
|
330 * @return A Calendar if created successfully. NULL otherwise.
|
jpayne@69
|
331 * @stable ICU 2.0
|
jpayne@69
|
332 */
|
jpayne@69
|
333 static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, UErrorCode& success);
|
jpayne@69
|
334
|
jpayne@69
|
335 /**
|
jpayne@69
|
336 * Creates a Calendar using the default timezone and the given locale.
|
jpayne@69
|
337 *
|
jpayne@69
|
338 * @param aLocale The given locale.
|
jpayne@69
|
339 * @param success Indicates the success/failure of Calendar creation. Filled in
|
jpayne@69
|
340 * with U_ZERO_ERROR if created successfully, set to a failure result
|
jpayne@69
|
341 * otherwise.
|
jpayne@69
|
342 * @return A Calendar if created successfully. NULL otherwise.
|
jpayne@69
|
343 * @stable ICU 2.0
|
jpayne@69
|
344 */
|
jpayne@69
|
345 static Calendar* U_EXPORT2 createInstance(const Locale& aLocale, UErrorCode& success);
|
jpayne@69
|
346
|
jpayne@69
|
347 /**
|
jpayne@69
|
348 * Creates a Calendar using the given timezone and given locale.
|
jpayne@69
|
349 * The Calendar takes ownership of zoneToAdopt; the
|
jpayne@69
|
350 * client must not delete it.
|
jpayne@69
|
351 *
|
jpayne@69
|
352 * @param zoneToAdopt The given timezone to be adopted.
|
jpayne@69
|
353 * @param aLocale The given locale.
|
jpayne@69
|
354 * @param success Indicates the success/failure of Calendar creation. Filled in
|
jpayne@69
|
355 * with U_ZERO_ERROR if created successfully, set to a failure result
|
jpayne@69
|
356 * otherwise.
|
jpayne@69
|
357 * @return A Calendar if created successfully. NULL otherwise.
|
jpayne@69
|
358 * @stable ICU 2.0
|
jpayne@69
|
359 */
|
jpayne@69
|
360 static Calendar* U_EXPORT2 createInstance(TimeZone* zoneToAdopt, const Locale& aLocale, UErrorCode& success);
|
jpayne@69
|
361
|
jpayne@69
|
362 /**
|
jpayne@69
|
363 * Gets a Calendar using the given timezone and given locale. The TimeZone
|
jpayne@69
|
364 * is _not_ adopted; the client is still responsible for deleting it.
|
jpayne@69
|
365 *
|
jpayne@69
|
366 * @param zone The given timezone.
|
jpayne@69
|
367 * @param aLocale The given locale.
|
jpayne@69
|
368 * @param success Indicates the success/failure of Calendar creation. Filled in
|
jpayne@69
|
369 * with U_ZERO_ERROR if created successfully, set to a failure result
|
jpayne@69
|
370 * otherwise.
|
jpayne@69
|
371 * @return A Calendar if created successfully. NULL otherwise.
|
jpayne@69
|
372 * @stable ICU 2.0
|
jpayne@69
|
373 */
|
jpayne@69
|
374 static Calendar* U_EXPORT2 createInstance(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
|
jpayne@69
|
375
|
jpayne@69
|
376 /**
|
jpayne@69
|
377 * Returns a list of the locales for which Calendars are installed.
|
jpayne@69
|
378 *
|
jpayne@69
|
379 * @param count Number of locales returned.
|
jpayne@69
|
380 * @return An array of Locale objects representing the set of locales for which
|
jpayne@69
|
381 * Calendars are installed. The system retains ownership of this list;
|
jpayne@69
|
382 * the caller must NOT delete it. Does not include user-registered Calendars.
|
jpayne@69
|
383 * @stable ICU 2.0
|
jpayne@69
|
384 */
|
jpayne@69
|
385 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
|
jpayne@69
|
386
|
jpayne@69
|
387
|
jpayne@69
|
388 /**
|
jpayne@69
|
389 * Given a key and a locale, returns an array of string values in a preferred
|
jpayne@69
|
390 * order that would make a difference. These are all and only those values where
|
jpayne@69
|
391 * the open (creation) of the service with the locale formed from the input locale
|
jpayne@69
|
392 * plus input keyword and that value has different behavior than creation with the
|
jpayne@69
|
393 * input locale alone.
|
jpayne@69
|
394 * @param key one of the keys supported by this service. For now, only
|
jpayne@69
|
395 * "calendar" is supported.
|
jpayne@69
|
396 * @param locale the locale
|
jpayne@69
|
397 * @param commonlyUsed if set to true it will return only commonly used values
|
jpayne@69
|
398 * with the given locale in preferred order. Otherwise,
|
jpayne@69
|
399 * it will return all the available values for the locale.
|
jpayne@69
|
400 * @param status ICU Error Code
|
jpayne@69
|
401 * @return a string enumeration over keyword values for the given key and the locale.
|
jpayne@69
|
402 * @stable ICU 4.2
|
jpayne@69
|
403 */
|
jpayne@69
|
404 static StringEnumeration* U_EXPORT2 getKeywordValuesForLocale(const char* key,
|
jpayne@69
|
405 const Locale& locale, UBool commonlyUsed, UErrorCode& status);
|
jpayne@69
|
406
|
jpayne@69
|
407 /**
|
jpayne@69
|
408 * Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70
|
jpayne@69
|
409 * (derived from the system time).
|
jpayne@69
|
410 *
|
jpayne@69
|
411 * @return The current UTC time in milliseconds.
|
jpayne@69
|
412 * @stable ICU 2.0
|
jpayne@69
|
413 */
|
jpayne@69
|
414 static UDate U_EXPORT2 getNow(void);
|
jpayne@69
|
415
|
jpayne@69
|
416 /**
|
jpayne@69
|
417 * Gets this Calendar's time as milliseconds. May involve recalculation of time due
|
jpayne@69
|
418 * to previous calls to set time field values. The time specified is non-local UTC
|
jpayne@69
|
419 * (GMT) time. Although this method is const, this object may actually be changed
|
jpayne@69
|
420 * (semantically const).
|
jpayne@69
|
421 *
|
jpayne@69
|
422 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
423 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
424 * leniency, this will be set to an error status.
|
jpayne@69
|
425 * @return The current time in UTC (GMT) time, or zero if the operation
|
jpayne@69
|
426 * failed.
|
jpayne@69
|
427 * @stable ICU 2.0
|
jpayne@69
|
428 */
|
jpayne@69
|
429 inline UDate getTime(UErrorCode& status) const { return getTimeInMillis(status); }
|
jpayne@69
|
430
|
jpayne@69
|
431 /**
|
jpayne@69
|
432 * Sets this Calendar's current time with the given UDate. The time specified should
|
jpayne@69
|
433 * be in non-local UTC (GMT) time.
|
jpayne@69
|
434 *
|
jpayne@69
|
435 * @param date The given UDate in UTC (GMT) time.
|
jpayne@69
|
436 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
437 * set in the time field is invalid or restricted by
|
jpayne@69
|
438 * leniency, this will be set to an error status.
|
jpayne@69
|
439 * @stable ICU 2.0
|
jpayne@69
|
440 */
|
jpayne@69
|
441 inline void setTime(UDate date, UErrorCode& status) { setTimeInMillis(date, status); }
|
jpayne@69
|
442
|
jpayne@69
|
443 /**
|
jpayne@69
|
444 * Compares the equality of two Calendar objects. Objects of different subclasses
|
jpayne@69
|
445 * are considered unequal. This comparison is very exacting; two Calendar objects
|
jpayne@69
|
446 * must be in exactly the same state to be considered equal. To compare based on the
|
jpayne@69
|
447 * represented time, use equals() instead.
|
jpayne@69
|
448 *
|
jpayne@69
|
449 * @param that The Calendar object to be compared with.
|
jpayne@69
|
450 * @return True if the given Calendar is the same as this Calendar; false
|
jpayne@69
|
451 * otherwise.
|
jpayne@69
|
452 * @stable ICU 2.0
|
jpayne@69
|
453 */
|
jpayne@69
|
454 virtual UBool operator==(const Calendar& that) const;
|
jpayne@69
|
455
|
jpayne@69
|
456 /**
|
jpayne@69
|
457 * Compares the inequality of two Calendar objects.
|
jpayne@69
|
458 *
|
jpayne@69
|
459 * @param that The Calendar object to be compared with.
|
jpayne@69
|
460 * @return True if the given Calendar is not the same as this Calendar; false
|
jpayne@69
|
461 * otherwise.
|
jpayne@69
|
462 * @stable ICU 2.0
|
jpayne@69
|
463 */
|
jpayne@69
|
464 UBool operator!=(const Calendar& that) const {return !operator==(that);}
|
jpayne@69
|
465
|
jpayne@69
|
466 /**
|
jpayne@69
|
467 * Returns TRUE if the given Calendar object is equivalent to this
|
jpayne@69
|
468 * one. An equivalent Calendar will behave exactly as this one
|
jpayne@69
|
469 * does, but it may be set to a different time. By contrast, for
|
jpayne@69
|
470 * the operator==() method to return TRUE, the other Calendar must
|
jpayne@69
|
471 * be set to the same time.
|
jpayne@69
|
472 *
|
jpayne@69
|
473 * @param other the Calendar to be compared with this Calendar
|
jpayne@69
|
474 * @stable ICU 2.4
|
jpayne@69
|
475 */
|
jpayne@69
|
476 virtual UBool isEquivalentTo(const Calendar& other) const;
|
jpayne@69
|
477
|
jpayne@69
|
478 /**
|
jpayne@69
|
479 * Compares the Calendar time, whereas Calendar::operator== compares the equality of
|
jpayne@69
|
480 * Calendar objects.
|
jpayne@69
|
481 *
|
jpayne@69
|
482 * @param when The Calendar to be compared with this Calendar. Although this is a
|
jpayne@69
|
483 * const parameter, the object may be modified physically
|
jpayne@69
|
484 * (semantically const).
|
jpayne@69
|
485 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
486 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
487 * leniency, this will be set to an error status.
|
jpayne@69
|
488 * @return True if the current time of this Calendar is equal to the time of
|
jpayne@69
|
489 * Calendar when; false otherwise.
|
jpayne@69
|
490 * @stable ICU 2.0
|
jpayne@69
|
491 */
|
jpayne@69
|
492 UBool equals(const Calendar& when, UErrorCode& status) const;
|
jpayne@69
|
493
|
jpayne@69
|
494 /**
|
jpayne@69
|
495 * Returns true if this Calendar's current time is before "when"'s current time.
|
jpayne@69
|
496 *
|
jpayne@69
|
497 * @param when The Calendar to be compared with this Calendar. Although this is a
|
jpayne@69
|
498 * const parameter, the object may be modified physically
|
jpayne@69
|
499 * (semantically const).
|
jpayne@69
|
500 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
501 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
502 * leniency, this will be set to an error status.
|
jpayne@69
|
503 * @return True if the current time of this Calendar is before the time of
|
jpayne@69
|
504 * Calendar when; false otherwise.
|
jpayne@69
|
505 * @stable ICU 2.0
|
jpayne@69
|
506 */
|
jpayne@69
|
507 UBool before(const Calendar& when, UErrorCode& status) const;
|
jpayne@69
|
508
|
jpayne@69
|
509 /**
|
jpayne@69
|
510 * Returns true if this Calendar's current time is after "when"'s current time.
|
jpayne@69
|
511 *
|
jpayne@69
|
512 * @param when The Calendar to be compared with this Calendar. Although this is a
|
jpayne@69
|
513 * const parameter, the object may be modified physically
|
jpayne@69
|
514 * (semantically const).
|
jpayne@69
|
515 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
516 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
517 * leniency, this will be set to an error status.
|
jpayne@69
|
518 * @return True if the current time of this Calendar is after the time of
|
jpayne@69
|
519 * Calendar when; false otherwise.
|
jpayne@69
|
520 * @stable ICU 2.0
|
jpayne@69
|
521 */
|
jpayne@69
|
522 UBool after(const Calendar& when, UErrorCode& status) const;
|
jpayne@69
|
523
|
jpayne@69
|
524 #ifndef U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
525 /**
|
jpayne@69
|
526 * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
|
jpayne@69
|
527 * time field, based on the calendar's rules. For example, to subtract 5 days from
|
jpayne@69
|
528 * the current time of the calendar, call add(Calendar::DATE, -5). When adding on
|
jpayne@69
|
529 * the month or Calendar::MONTH field, other fields like date might conflict and
|
jpayne@69
|
530 * need to be changed. For instance, adding 1 month on the date 01/31/96 will result
|
jpayne@69
|
531 * in 02/29/96.
|
jpayne@69
|
532 * Adding a positive value always means moving forward in time, so for the Gregorian calendar,
|
jpayne@69
|
533 * starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces
|
jpayne@69
|
534 * the numeric value of the field itself).
|
jpayne@69
|
535 *
|
jpayne@69
|
536 * @param field Specifies which date field to modify.
|
jpayne@69
|
537 * @param amount The amount of time to be added to the field, in the natural unit
|
jpayne@69
|
538 * for that field (e.g., days for the day fields, hours for the hour
|
jpayne@69
|
539 * field.)
|
jpayne@69
|
540 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
541 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
542 * leniency, this will be set to an error status.
|
jpayne@69
|
543 * @deprecated ICU 2.6. use add(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
|
jpayne@69
|
544 */
|
jpayne@69
|
545 virtual void add(EDateFields field, int32_t amount, UErrorCode& status);
|
jpayne@69
|
546 #endif // U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
547
|
jpayne@69
|
548 /**
|
jpayne@69
|
549 * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
|
jpayne@69
|
550 * time field, based on the calendar's rules. For example, to subtract 5 days from
|
jpayne@69
|
551 * the current time of the calendar, call add(Calendar::DATE, -5). When adding on
|
jpayne@69
|
552 * the month or Calendar::MONTH field, other fields like date might conflict and
|
jpayne@69
|
553 * need to be changed. For instance, adding 1 month on the date 01/31/96 will result
|
jpayne@69
|
554 * in 02/29/96.
|
jpayne@69
|
555 * Adding a positive value always means moving forward in time, so for the Gregorian calendar,
|
jpayne@69
|
556 * starting with 100 BC and adding +1 to year results in 99 BC (even though this actually reduces
|
jpayne@69
|
557 * the numeric value of the field itself).
|
jpayne@69
|
558 *
|
jpayne@69
|
559 * @param field Specifies which date field to modify.
|
jpayne@69
|
560 * @param amount The amount of time to be added to the field, in the natural unit
|
jpayne@69
|
561 * for that field (e.g., days for the day fields, hours for the hour
|
jpayne@69
|
562 * field.)
|
jpayne@69
|
563 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
564 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
565 * leniency, this will be set to an error status.
|
jpayne@69
|
566 * @stable ICU 2.6.
|
jpayne@69
|
567 */
|
jpayne@69
|
568 virtual void add(UCalendarDateFields field, int32_t amount, UErrorCode& status);
|
jpayne@69
|
569
|
jpayne@69
|
570 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
571 /**
|
jpayne@69
|
572 * Time Field Rolling function. Rolls (up/down) a single unit of time on the given
|
jpayne@69
|
573 * time field. For example, to roll the current date up by one day, call
|
jpayne@69
|
574 * roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it
|
jpayne@69
|
575 * will roll the year value in the range between getMinimum(Calendar::YEAR) and the
|
jpayne@69
|
576 * value returned by getMaximum(Calendar::YEAR). When rolling on the month or
|
jpayne@69
|
577 * Calendar::MONTH field, other fields like date might conflict and, need to be
|
jpayne@69
|
578 * changed. For instance, rolling the month up on the date 01/31/96 will result in
|
jpayne@69
|
579 * 02/29/96. Rolling up always means rolling forward in time (unless the limit of the
|
jpayne@69
|
580 * field is reached, in which case it may pin or wrap), so for Gregorian calendar,
|
jpayne@69
|
581 * starting with 100 BC and rolling the year up results in 99 BC.
|
jpayne@69
|
582 * When eras have a definite beginning and end (as in the Chinese calendar, or as in
|
jpayne@69
|
583 * most eras in the Japanese calendar) then rolling the year past either limit of the
|
jpayne@69
|
584 * era will cause the year to wrap around. When eras only have a limit at one end,
|
jpayne@69
|
585 * then attempting to roll the year past that limit will result in pinning the year
|
jpayne@69
|
586 * at that limit. Note that for most calendars in which era 0 years move forward in
|
jpayne@69
|
587 * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to
|
jpayne@69
|
588 * result in negative years for era 0 (that is the only way to represent years before
|
jpayne@69
|
589 * the calendar epoch).
|
jpayne@69
|
590 * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the
|
jpayne@69
|
591 * hour value in the range between 0 and 23, which is zero-based.
|
jpayne@69
|
592 * <P>
|
jpayne@69
|
593 * NOTE: Do not use this method -- use roll(EDateFields, int, UErrorCode&) instead.
|
jpayne@69
|
594 *
|
jpayne@69
|
595 * @param field The time field.
|
jpayne@69
|
596 * @param up Indicates if the value of the specified time field is to be rolled
|
jpayne@69
|
597 * up or rolled down. Use true if rolling up, false otherwise.
|
jpayne@69
|
598 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
599 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
600 * leniency, this will be set to an error status.
|
jpayne@69
|
601 * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, UBool up, UErrorCode& status) instead.
|
jpayne@69
|
602 */
|
jpayne@69
|
603 inline void roll(EDateFields field, UBool up, UErrorCode& status);
|
jpayne@69
|
604 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
605
|
jpayne@69
|
606 /**
|
jpayne@69
|
607 * Time Field Rolling function. Rolls (up/down) a single unit of time on the given
|
jpayne@69
|
608 * time field. For example, to roll the current date up by one day, call
|
jpayne@69
|
609 * roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it
|
jpayne@69
|
610 * will roll the year value in the range between getMinimum(Calendar::YEAR) and the
|
jpayne@69
|
611 * value returned by getMaximum(Calendar::YEAR). When rolling on the month or
|
jpayne@69
|
612 * Calendar::MONTH field, other fields like date might conflict and, need to be
|
jpayne@69
|
613 * changed. For instance, rolling the month up on the date 01/31/96 will result in
|
jpayne@69
|
614 * 02/29/96. Rolling up always means rolling forward in time (unless the limit of the
|
jpayne@69
|
615 * field is reached, in which case it may pin or wrap), so for Gregorian calendar,
|
jpayne@69
|
616 * starting with 100 BC and rolling the year up results in 99 BC.
|
jpayne@69
|
617 * When eras have a definite beginning and end (as in the Chinese calendar, or as in
|
jpayne@69
|
618 * most eras in the Japanese calendar) then rolling the year past either limit of the
|
jpayne@69
|
619 * era will cause the year to wrap around. When eras only have a limit at one end,
|
jpayne@69
|
620 * then attempting to roll the year past that limit will result in pinning the year
|
jpayne@69
|
621 * at that limit. Note that for most calendars in which era 0 years move forward in
|
jpayne@69
|
622 * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to
|
jpayne@69
|
623 * result in negative years for era 0 (that is the only way to represent years before
|
jpayne@69
|
624 * the calendar epoch).
|
jpayne@69
|
625 * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the
|
jpayne@69
|
626 * hour value in the range between 0 and 23, which is zero-based.
|
jpayne@69
|
627 * <P>
|
jpayne@69
|
628 * NOTE: Do not use this method -- use roll(UCalendarDateFields, int, UErrorCode&) instead.
|
jpayne@69
|
629 *
|
jpayne@69
|
630 * @param field The time field.
|
jpayne@69
|
631 * @param up Indicates if the value of the specified time field is to be rolled
|
jpayne@69
|
632 * up or rolled down. Use true if rolling up, false otherwise.
|
jpayne@69
|
633 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
634 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
635 * leniency, this will be set to an error status.
|
jpayne@69
|
636 * @stable ICU 2.6.
|
jpayne@69
|
637 */
|
jpayne@69
|
638 inline void roll(UCalendarDateFields field, UBool up, UErrorCode& status);
|
jpayne@69
|
639
|
jpayne@69
|
640 #ifndef U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
641 /**
|
jpayne@69
|
642 * Time Field Rolling function. Rolls by the given amount on the given
|
jpayne@69
|
643 * time field. For example, to roll the current date up by one day, call
|
jpayne@69
|
644 * roll(Calendar::DATE, +1, status). When rolling on the month or
|
jpayne@69
|
645 * Calendar::MONTH field, other fields like date might conflict and, need to be
|
jpayne@69
|
646 * changed. For instance, rolling the month up on the date 01/31/96 will result in
|
jpayne@69
|
647 * 02/29/96. Rolling by a positive value always means rolling forward in time (unless
|
jpayne@69
|
648 * the limit of the field is reached, in which case it may pin or wrap), so for
|
jpayne@69
|
649 * Gregorian calendar, starting with 100 BC and rolling the year by + 1 results in 99 BC.
|
jpayne@69
|
650 * When eras have a definite beginning and end (as in the Chinese calendar, or as in
|
jpayne@69
|
651 * most eras in the Japanese calendar) then rolling the year past either limit of the
|
jpayne@69
|
652 * era will cause the year to wrap around. When eras only have a limit at one end,
|
jpayne@69
|
653 * then attempting to roll the year past that limit will result in pinning the year
|
jpayne@69
|
654 * at that limit. Note that for most calendars in which era 0 years move forward in
|
jpayne@69
|
655 * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to
|
jpayne@69
|
656 * result in negative years for era 0 (that is the only way to represent years before
|
jpayne@69
|
657 * the calendar epoch).
|
jpayne@69
|
658 * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the
|
jpayne@69
|
659 * hour value in the range between 0 and 23, which is zero-based.
|
jpayne@69
|
660 * <P>
|
jpayne@69
|
661 * The only difference between roll() and add() is that roll() does not change
|
jpayne@69
|
662 * the value of more significant fields when it reaches the minimum or maximum
|
jpayne@69
|
663 * of its range, whereas add() does.
|
jpayne@69
|
664 *
|
jpayne@69
|
665 * @param field The time field.
|
jpayne@69
|
666 * @param amount Indicates amount to roll.
|
jpayne@69
|
667 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
668 * previously set in the time field is invalid, this will be set to
|
jpayne@69
|
669 * an error status.
|
jpayne@69
|
670 * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
|
jpayne@69
|
671 */
|
jpayne@69
|
672 virtual void roll(EDateFields field, int32_t amount, UErrorCode& status);
|
jpayne@69
|
673 #endif // U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
674
|
jpayne@69
|
675 /**
|
jpayne@69
|
676 * Time Field Rolling function. Rolls by the given amount on the given
|
jpayne@69
|
677 * time field. For example, to roll the current date up by one day, call
|
jpayne@69
|
678 * roll(Calendar::DATE, +1, status). When rolling on the month or
|
jpayne@69
|
679 * Calendar::MONTH field, other fields like date might conflict and, need to be
|
jpayne@69
|
680 * changed. For instance, rolling the month up on the date 01/31/96 will result in
|
jpayne@69
|
681 * 02/29/96. Rolling by a positive value always means rolling forward in time (unless
|
jpayne@69
|
682 * the limit of the field is reached, in which case it may pin or wrap), so for
|
jpayne@69
|
683 * Gregorian calendar, starting with 100 BC and rolling the year by + 1 results in 99 BC.
|
jpayne@69
|
684 * When eras have a definite beginning and end (as in the Chinese calendar, or as in
|
jpayne@69
|
685 * most eras in the Japanese calendar) then rolling the year past either limit of the
|
jpayne@69
|
686 * era will cause the year to wrap around. When eras only have a limit at one end,
|
jpayne@69
|
687 * then attempting to roll the year past that limit will result in pinning the year
|
jpayne@69
|
688 * at that limit. Note that for most calendars in which era 0 years move forward in
|
jpayne@69
|
689 * time (such as Buddhist, Hebrew, or Islamic), it is possible for add or roll to
|
jpayne@69
|
690 * result in negative years for era 0 (that is the only way to represent years before
|
jpayne@69
|
691 * the calendar epoch).
|
jpayne@69
|
692 * When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the
|
jpayne@69
|
693 * hour value in the range between 0 and 23, which is zero-based.
|
jpayne@69
|
694 * <P>
|
jpayne@69
|
695 * The only difference between roll() and add() is that roll() does not change
|
jpayne@69
|
696 * the value of more significant fields when it reaches the minimum or maximum
|
jpayne@69
|
697 * of its range, whereas add() does.
|
jpayne@69
|
698 *
|
jpayne@69
|
699 * @param field The time field.
|
jpayne@69
|
700 * @param amount Indicates amount to roll.
|
jpayne@69
|
701 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
702 * previously set in the time field is invalid, this will be set to
|
jpayne@69
|
703 * an error status.
|
jpayne@69
|
704 * @stable ICU 2.6.
|
jpayne@69
|
705 */
|
jpayne@69
|
706 virtual void roll(UCalendarDateFields field, int32_t amount, UErrorCode& status);
|
jpayne@69
|
707
|
jpayne@69
|
708 #ifndef U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
709 /**
|
jpayne@69
|
710 * Return the difference between the given time and the time this
|
jpayne@69
|
711 * calendar object is set to. If this calendar is set
|
jpayne@69
|
712 * <em>before</em> the given time, the returned value will be
|
jpayne@69
|
713 * positive. If this calendar is set <em>after</em> the given
|
jpayne@69
|
714 * time, the returned value will be negative. The
|
jpayne@69
|
715 * <code>field</code> parameter specifies the units of the return
|
jpayne@69
|
716 * value. For example, if <code>fieldDifference(when,
|
jpayne@69
|
717 * Calendar::MONTH)</code> returns 3, then this calendar is set to
|
jpayne@69
|
718 * 3 months before <code>when</code>, and possibly some addition
|
jpayne@69
|
719 * time less than one month.
|
jpayne@69
|
720 *
|
jpayne@69
|
721 * <p>As a side effect of this call, this calendar is advanced
|
jpayne@69
|
722 * toward <code>when</code> by the given amount. That is, calling
|
jpayne@69
|
723 * this method has the side effect of calling <code>add(field,
|
jpayne@69
|
724 * n)</code>, where <code>n</code> is the return value.
|
jpayne@69
|
725 *
|
jpayne@69
|
726 * <p>Usage: To use this method, call it first with the largest
|
jpayne@69
|
727 * field of interest, then with progressively smaller fields. For
|
jpayne@69
|
728 * example:
|
jpayne@69
|
729 *
|
jpayne@69
|
730 * <pre>
|
jpayne@69
|
731 * int y = cal->fieldDifference(when, Calendar::YEAR, err);
|
jpayne@69
|
732 * int m = cal->fieldDifference(when, Calendar::MONTH, err);
|
jpayne@69
|
733 * int d = cal->fieldDifference(when, Calendar::DATE, err);</pre>
|
jpayne@69
|
734 *
|
jpayne@69
|
735 * computes the difference between <code>cal</code> and
|
jpayne@69
|
736 * <code>when</code> in years, months, and days.
|
jpayne@69
|
737 *
|
jpayne@69
|
738 * <p>Note: <code>fieldDifference()</code> is
|
jpayne@69
|
739 * <em>asymmetrical</em>. That is, in the following code:
|
jpayne@69
|
740 *
|
jpayne@69
|
741 * <pre>
|
jpayne@69
|
742 * cal->setTime(date1, err);
|
jpayne@69
|
743 * int m1 = cal->fieldDifference(date2, Calendar::MONTH, err);
|
jpayne@69
|
744 * int d1 = cal->fieldDifference(date2, Calendar::DATE, err);
|
jpayne@69
|
745 * cal->setTime(date2, err);
|
jpayne@69
|
746 * int m2 = cal->fieldDifference(date1, Calendar::MONTH, err);
|
jpayne@69
|
747 * int d2 = cal->fieldDifference(date1, Calendar::DATE, err);</pre>
|
jpayne@69
|
748 *
|
jpayne@69
|
749 * one might expect that <code>m1 == -m2 && d1 == -d2</code>.
|
jpayne@69
|
750 * However, this is not generally the case, because of
|
jpayne@69
|
751 * irregularities in the underlying calendar system (e.g., the
|
jpayne@69
|
752 * Gregorian calendar has a varying number of days per month).
|
jpayne@69
|
753 *
|
jpayne@69
|
754 * @param when the date to compare this calendar's time to
|
jpayne@69
|
755 * @param field the field in which to compute the result
|
jpayne@69
|
756 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
757 * previously set in the time field is invalid, this will be set to
|
jpayne@69
|
758 * an error status.
|
jpayne@69
|
759 * @return the difference, either positive or negative, between
|
jpayne@69
|
760 * this calendar's time and <code>when</code>, in terms of
|
jpayne@69
|
761 * <code>field</code>.
|
jpayne@69
|
762 * @deprecated ICU 2.6. Use fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status).
|
jpayne@69
|
763 */
|
jpayne@69
|
764 virtual int32_t fieldDifference(UDate when, EDateFields field, UErrorCode& status);
|
jpayne@69
|
765 #endif // U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
766
|
jpayne@69
|
767 /**
|
jpayne@69
|
768 * Return the difference between the given time and the time this
|
jpayne@69
|
769 * calendar object is set to. If this calendar is set
|
jpayne@69
|
770 * <em>before</em> the given time, the returned value will be
|
jpayne@69
|
771 * positive. If this calendar is set <em>after</em> the given
|
jpayne@69
|
772 * time, the returned value will be negative. The
|
jpayne@69
|
773 * <code>field</code> parameter specifies the units of the return
|
jpayne@69
|
774 * value. For example, if <code>fieldDifference(when,
|
jpayne@69
|
775 * Calendar::MONTH)</code> returns 3, then this calendar is set to
|
jpayne@69
|
776 * 3 months before <code>when</code>, and possibly some addition
|
jpayne@69
|
777 * time less than one month.
|
jpayne@69
|
778 *
|
jpayne@69
|
779 * <p>As a side effect of this call, this calendar is advanced
|
jpayne@69
|
780 * toward <code>when</code> by the given amount. That is, calling
|
jpayne@69
|
781 * this method has the side effect of calling <code>add(field,
|
jpayne@69
|
782 * n)</code>, where <code>n</code> is the return value.
|
jpayne@69
|
783 *
|
jpayne@69
|
784 * <p>Usage: To use this method, call it first with the largest
|
jpayne@69
|
785 * field of interest, then with progressively smaller fields. For
|
jpayne@69
|
786 * example:
|
jpayne@69
|
787 *
|
jpayne@69
|
788 * <pre>
|
jpayne@69
|
789 * int y = cal->fieldDifference(when, Calendar::YEAR, err);
|
jpayne@69
|
790 * int m = cal->fieldDifference(when, Calendar::MONTH, err);
|
jpayne@69
|
791 * int d = cal->fieldDifference(when, Calendar::DATE, err);</pre>
|
jpayne@69
|
792 *
|
jpayne@69
|
793 * computes the difference between <code>cal</code> and
|
jpayne@69
|
794 * <code>when</code> in years, months, and days.
|
jpayne@69
|
795 *
|
jpayne@69
|
796 * <p>Note: <code>fieldDifference()</code> is
|
jpayne@69
|
797 * <em>asymmetrical</em>. That is, in the following code:
|
jpayne@69
|
798 *
|
jpayne@69
|
799 * <pre>
|
jpayne@69
|
800 * cal->setTime(date1, err);
|
jpayne@69
|
801 * int m1 = cal->fieldDifference(date2, Calendar::MONTH, err);
|
jpayne@69
|
802 * int d1 = cal->fieldDifference(date2, Calendar::DATE, err);
|
jpayne@69
|
803 * cal->setTime(date2, err);
|
jpayne@69
|
804 * int m2 = cal->fieldDifference(date1, Calendar::MONTH, err);
|
jpayne@69
|
805 * int d2 = cal->fieldDifference(date1, Calendar::DATE, err);</pre>
|
jpayne@69
|
806 *
|
jpayne@69
|
807 * one might expect that <code>m1 == -m2 && d1 == -d2</code>.
|
jpayne@69
|
808 * However, this is not generally the case, because of
|
jpayne@69
|
809 * irregularities in the underlying calendar system (e.g., the
|
jpayne@69
|
810 * Gregorian calendar has a varying number of days per month).
|
jpayne@69
|
811 *
|
jpayne@69
|
812 * @param when the date to compare this calendar's time to
|
jpayne@69
|
813 * @param field the field in which to compute the result
|
jpayne@69
|
814 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
815 * previously set in the time field is invalid, this will be set to
|
jpayne@69
|
816 * an error status.
|
jpayne@69
|
817 * @return the difference, either positive or negative, between
|
jpayne@69
|
818 * this calendar's time and <code>when</code>, in terms of
|
jpayne@69
|
819 * <code>field</code>.
|
jpayne@69
|
820 * @stable ICU 2.6.
|
jpayne@69
|
821 */
|
jpayne@69
|
822 virtual int32_t fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status);
|
jpayne@69
|
823
|
jpayne@69
|
824 /**
|
jpayne@69
|
825 * Sets the calendar's time zone to be the one passed in. The Calendar takes ownership
|
jpayne@69
|
826 * of the TimeZone; the caller is no longer responsible for deleting it. If the
|
jpayne@69
|
827 * given time zone is NULL, this function has no effect.
|
jpayne@69
|
828 *
|
jpayne@69
|
829 * @param value The given time zone.
|
jpayne@69
|
830 * @stable ICU 2.0
|
jpayne@69
|
831 */
|
jpayne@69
|
832 void adoptTimeZone(TimeZone* value);
|
jpayne@69
|
833
|
jpayne@69
|
834 /**
|
jpayne@69
|
835 * Sets the calendar's time zone to be the same as the one passed in. The TimeZone
|
jpayne@69
|
836 * passed in is _not_ adopted; the client is still responsible for deleting it.
|
jpayne@69
|
837 *
|
jpayne@69
|
838 * @param zone The given time zone.
|
jpayne@69
|
839 * @stable ICU 2.0
|
jpayne@69
|
840 */
|
jpayne@69
|
841 void setTimeZone(const TimeZone& zone);
|
jpayne@69
|
842
|
jpayne@69
|
843 /**
|
jpayne@69
|
844 * Returns a reference to the time zone owned by this calendar. The returned reference
|
jpayne@69
|
845 * is only valid until clients make another call to adoptTimeZone or setTimeZone,
|
jpayne@69
|
846 * or this Calendar is destroyed.
|
jpayne@69
|
847 *
|
jpayne@69
|
848 * @return The time zone object associated with this calendar.
|
jpayne@69
|
849 * @stable ICU 2.0
|
jpayne@69
|
850 */
|
jpayne@69
|
851 const TimeZone& getTimeZone(void) const;
|
jpayne@69
|
852
|
jpayne@69
|
853 /**
|
jpayne@69
|
854 * Returns the time zone owned by this calendar. The caller owns the returned object
|
jpayne@69
|
855 * and must delete it when done. After this call, the new time zone associated
|
jpayne@69
|
856 * with this Calendar is the default TimeZone as returned by TimeZone::createDefault().
|
jpayne@69
|
857 *
|
jpayne@69
|
858 * @return The time zone object which was associated with this calendar.
|
jpayne@69
|
859 * @stable ICU 2.0
|
jpayne@69
|
860 */
|
jpayne@69
|
861 TimeZone* orphanTimeZone(void);
|
jpayne@69
|
862
|
jpayne@69
|
863 /**
|
jpayne@69
|
864 * Queries if the current date for this Calendar is in Daylight Savings Time.
|
jpayne@69
|
865 *
|
jpayne@69
|
866 * @param status Fill-in parameter which receives the status of this operation.
|
jpayne@69
|
867 * @return True if the current date for this Calendar is in Daylight Savings Time,
|
jpayne@69
|
868 * false, otherwise.
|
jpayne@69
|
869 * @stable ICU 2.0
|
jpayne@69
|
870 */
|
jpayne@69
|
871 virtual UBool inDaylightTime(UErrorCode& status) const = 0;
|
jpayne@69
|
872
|
jpayne@69
|
873 /**
|
jpayne@69
|
874 * Specifies whether or not date/time interpretation is to be lenient. With lenient
|
jpayne@69
|
875 * interpretation, a date such as "February 942, 1996" will be treated as being
|
jpayne@69
|
876 * equivalent to the 941st day after February 1, 1996. With strict interpretation,
|
jpayne@69
|
877 * such dates will cause an error when computing time from the time field values
|
jpayne@69
|
878 * representing the dates.
|
jpayne@69
|
879 *
|
jpayne@69
|
880 * @param lenient True specifies date/time interpretation to be lenient.
|
jpayne@69
|
881 *
|
jpayne@69
|
882 * @see DateFormat#setLenient
|
jpayne@69
|
883 * @stable ICU 2.0
|
jpayne@69
|
884 */
|
jpayne@69
|
885 void setLenient(UBool lenient);
|
jpayne@69
|
886
|
jpayne@69
|
887 /**
|
jpayne@69
|
888 * Tells whether date/time interpretation is to be lenient.
|
jpayne@69
|
889 *
|
jpayne@69
|
890 * @return True tells that date/time interpretation is to be lenient.
|
jpayne@69
|
891 * @stable ICU 2.0
|
jpayne@69
|
892 */
|
jpayne@69
|
893 UBool isLenient(void) const;
|
jpayne@69
|
894
|
jpayne@69
|
895 /**
|
jpayne@69
|
896 * Sets the behavior for handling wall time repeating multiple times
|
jpayne@69
|
897 * at negative time zone offset transitions. For example, 1:30 AM on
|
jpayne@69
|
898 * November 6, 2011 in US Eastern time (America/New_York) occurs twice;
|
jpayne@69
|
899 * 1:30 AM EDT, then 1:30 AM EST one hour later. When <code>UCAL_WALLTIME_FIRST</code>
|
jpayne@69
|
900 * is used, the wall time 1:30AM in this example will be interpreted as 1:30 AM EDT
|
jpayne@69
|
901 * (first occurrence). When <code>UCAL_WALLTIME_LAST</code> is used, it will be
|
jpayne@69
|
902 * interpreted as 1:30 AM EST (last occurrence). The default value is
|
jpayne@69
|
903 * <code>UCAL_WALLTIME_LAST</code>.
|
jpayne@69
|
904 * <p>
|
jpayne@69
|
905 * <b>Note:</b>When <code>UCAL_WALLTIME_NEXT_VALID</code> is not a valid
|
jpayne@69
|
906 * option for this. When the argument is neither <code>UCAL_WALLTIME_FIRST</code>
|
jpayne@69
|
907 * nor <code>UCAL_WALLTIME_LAST</code>, this method has no effect and will keep
|
jpayne@69
|
908 * the current setting.
|
jpayne@69
|
909 *
|
jpayne@69
|
910 * @param option the behavior for handling repeating wall time, either
|
jpayne@69
|
911 * <code>UCAL_WALLTIME_FIRST</code> or <code>UCAL_WALLTIME_LAST</code>.
|
jpayne@69
|
912 * @see #getRepeatedWallTimeOption
|
jpayne@69
|
913 * @stable ICU 49
|
jpayne@69
|
914 */
|
jpayne@69
|
915 void setRepeatedWallTimeOption(UCalendarWallTimeOption option);
|
jpayne@69
|
916
|
jpayne@69
|
917 /**
|
jpayne@69
|
918 * Gets the behavior for handling wall time repeating multiple times
|
jpayne@69
|
919 * at negative time zone offset transitions.
|
jpayne@69
|
920 *
|
jpayne@69
|
921 * @return the behavior for handling repeating wall time, either
|
jpayne@69
|
922 * <code>UCAL_WALLTIME_FIRST</code> or <code>UCAL_WALLTIME_LAST</code>.
|
jpayne@69
|
923 * @see #setRepeatedWallTimeOption
|
jpayne@69
|
924 * @stable ICU 49
|
jpayne@69
|
925 */
|
jpayne@69
|
926 UCalendarWallTimeOption getRepeatedWallTimeOption(void) const;
|
jpayne@69
|
927
|
jpayne@69
|
928 /**
|
jpayne@69
|
929 * Sets the behavior for handling skipped wall time at positive time zone offset
|
jpayne@69
|
930 * transitions. For example, 2:30 AM on March 13, 2011 in US Eastern time (America/New_York)
|
jpayne@69
|
931 * does not exist because the wall time jump from 1:59 AM EST to 3:00 AM EDT. When
|
jpayne@69
|
932 * <code>UCAL_WALLTIME_FIRST</code> is used, 2:30 AM is interpreted as 30 minutes before 3:00 AM
|
jpayne@69
|
933 * EDT, therefore, it will be resolved as 1:30 AM EST. When <code>UCAL_WALLTIME_LAST</code>
|
jpayne@69
|
934 * is used, 2:30 AM is interpreted as 31 minutes after 1:59 AM EST, therefore, it will be
|
jpayne@69
|
935 * resolved as 3:30 AM EDT. When <code>UCAL_WALLTIME_NEXT_VALID</code> is used, 2:30 AM will
|
jpayne@69
|
936 * be resolved as next valid wall time, that is 3:00 AM EDT. The default value is
|
jpayne@69
|
937 * <code>UCAL_WALLTIME_LAST</code>.
|
jpayne@69
|
938 * <p>
|
jpayne@69
|
939 * <b>Note:</b>This option is effective only when this calendar is lenient.
|
jpayne@69
|
940 * When the calendar is strict, such non-existing wall time will cause an error.
|
jpayne@69
|
941 *
|
jpayne@69
|
942 * @param option the behavior for handling skipped wall time at positive time zone
|
jpayne@69
|
943 * offset transitions, one of <code>UCAL_WALLTIME_FIRST</code>, <code>UCAL_WALLTIME_LAST</code> and
|
jpayne@69
|
944 * <code>UCAL_WALLTIME_NEXT_VALID</code>.
|
jpayne@69
|
945 * @see #getSkippedWallTimeOption
|
jpayne@69
|
946 *
|
jpayne@69
|
947 * @stable ICU 49
|
jpayne@69
|
948 */
|
jpayne@69
|
949 void setSkippedWallTimeOption(UCalendarWallTimeOption option);
|
jpayne@69
|
950
|
jpayne@69
|
951 /**
|
jpayne@69
|
952 * Gets the behavior for handling skipped wall time at positive time zone offset
|
jpayne@69
|
953 * transitions.
|
jpayne@69
|
954 *
|
jpayne@69
|
955 * @return the behavior for handling skipped wall time, one of
|
jpayne@69
|
956 * <code>UCAL_WALLTIME_FIRST</code>, <code>UCAL_WALLTIME_LAST</code>
|
jpayne@69
|
957 * and <code>UCAL_WALLTIME_NEXT_VALID</code>.
|
jpayne@69
|
958 * @see #setSkippedWallTimeOption
|
jpayne@69
|
959 * @stable ICU 49
|
jpayne@69
|
960 */
|
jpayne@69
|
961 UCalendarWallTimeOption getSkippedWallTimeOption(void) const;
|
jpayne@69
|
962
|
jpayne@69
|
963 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
964 /**
|
jpayne@69
|
965 * Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
|
jpayne@69
|
966 *
|
jpayne@69
|
967 * @param value The given first day of the week.
|
jpayne@69
|
968 * @deprecated ICU 2.6. Use setFirstDayOfWeek(UCalendarDaysOfWeek value) instead.
|
jpayne@69
|
969 */
|
jpayne@69
|
970 void setFirstDayOfWeek(EDaysOfWeek value);
|
jpayne@69
|
971 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
972
|
jpayne@69
|
973 /**
|
jpayne@69
|
974 * Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
|
jpayne@69
|
975 *
|
jpayne@69
|
976 * @param value The given first day of the week.
|
jpayne@69
|
977 * @stable ICU 2.6.
|
jpayne@69
|
978 */
|
jpayne@69
|
979 void setFirstDayOfWeek(UCalendarDaysOfWeek value);
|
jpayne@69
|
980
|
jpayne@69
|
981 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
982 /**
|
jpayne@69
|
983 * Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
|
jpayne@69
|
984 *
|
jpayne@69
|
985 * @return The first day of the week.
|
jpayne@69
|
986 * @deprecated ICU 2.6 use the overload with error code
|
jpayne@69
|
987 */
|
jpayne@69
|
988 EDaysOfWeek getFirstDayOfWeek(void) const;
|
jpayne@69
|
989 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
990
|
jpayne@69
|
991 /**
|
jpayne@69
|
992 * Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
|
jpayne@69
|
993 *
|
jpayne@69
|
994 * @param status error code
|
jpayne@69
|
995 * @return The first day of the week.
|
jpayne@69
|
996 * @stable ICU 2.6
|
jpayne@69
|
997 */
|
jpayne@69
|
998 UCalendarDaysOfWeek getFirstDayOfWeek(UErrorCode &status) const;
|
jpayne@69
|
999
|
jpayne@69
|
1000 /**
|
jpayne@69
|
1001 * Sets what the minimal days required in the first week of the year are; For
|
jpayne@69
|
1002 * example, if the first week is defined as one that contains the first day of the
|
jpayne@69
|
1003 * first month of a year, call the method with value 1. If it must be a full week,
|
jpayne@69
|
1004 * use value 7.
|
jpayne@69
|
1005 *
|
jpayne@69
|
1006 * @param value The given minimal days required in the first week of the year.
|
jpayne@69
|
1007 * @stable ICU 2.0
|
jpayne@69
|
1008 */
|
jpayne@69
|
1009 void setMinimalDaysInFirstWeek(uint8_t value);
|
jpayne@69
|
1010
|
jpayne@69
|
1011 /**
|
jpayne@69
|
1012 * Gets what the minimal days required in the first week of the year are; e.g., if
|
jpayne@69
|
1013 * the first week is defined as one that contains the first day of the first month
|
jpayne@69
|
1014 * of a year, getMinimalDaysInFirstWeek returns 1. If the minimal days required must
|
jpayne@69
|
1015 * be a full week, getMinimalDaysInFirstWeek returns 7.
|
jpayne@69
|
1016 *
|
jpayne@69
|
1017 * @return The minimal days required in the first week of the year.
|
jpayne@69
|
1018 * @stable ICU 2.0
|
jpayne@69
|
1019 */
|
jpayne@69
|
1020 uint8_t getMinimalDaysInFirstWeek(void) const;
|
jpayne@69
|
1021
|
jpayne@69
|
1022 #ifndef U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
1023 /**
|
jpayne@69
|
1024 * Gets the minimum value for the given time field. e.g., for Gregorian
|
jpayne@69
|
1025 * DAY_OF_MONTH, 1.
|
jpayne@69
|
1026 *
|
jpayne@69
|
1027 * @param field The given time field.
|
jpayne@69
|
1028 * @return The minimum value for the given time field.
|
jpayne@69
|
1029 * @deprecated ICU 2.6. Use getMinimum(UCalendarDateFields field) instead.
|
jpayne@69
|
1030 */
|
jpayne@69
|
1031 virtual int32_t getMinimum(EDateFields field) const;
|
jpayne@69
|
1032 #endif // U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
1033
|
jpayne@69
|
1034 /**
|
jpayne@69
|
1035 * Gets the minimum value for the given time field. e.g., for Gregorian
|
jpayne@69
|
1036 * DAY_OF_MONTH, 1.
|
jpayne@69
|
1037 *
|
jpayne@69
|
1038 * @param field The given time field.
|
jpayne@69
|
1039 * @return The minimum value for the given time field.
|
jpayne@69
|
1040 * @stable ICU 2.6.
|
jpayne@69
|
1041 */
|
jpayne@69
|
1042 virtual int32_t getMinimum(UCalendarDateFields field) const;
|
jpayne@69
|
1043
|
jpayne@69
|
1044 #ifndef U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
1045 /**
|
jpayne@69
|
1046 * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
|
jpayne@69
|
1047 * 31.
|
jpayne@69
|
1048 *
|
jpayne@69
|
1049 * @param field The given time field.
|
jpayne@69
|
1050 * @return The maximum value for the given time field.
|
jpayne@69
|
1051 * @deprecated ICU 2.6. Use getMaximum(UCalendarDateFields field) instead.
|
jpayne@69
|
1052 */
|
jpayne@69
|
1053 virtual int32_t getMaximum(EDateFields field) const;
|
jpayne@69
|
1054 #endif // U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
1055
|
jpayne@69
|
1056 /**
|
jpayne@69
|
1057 * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
|
jpayne@69
|
1058 * 31.
|
jpayne@69
|
1059 *
|
jpayne@69
|
1060 * @param field The given time field.
|
jpayne@69
|
1061 * @return The maximum value for the given time field.
|
jpayne@69
|
1062 * @stable ICU 2.6.
|
jpayne@69
|
1063 */
|
jpayne@69
|
1064 virtual int32_t getMaximum(UCalendarDateFields field) const;
|
jpayne@69
|
1065
|
jpayne@69
|
1066 #ifndef U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
1067 /**
|
jpayne@69
|
1068 * Gets the highest minimum value for the given field if varies. Otherwise same as
|
jpayne@69
|
1069 * getMinimum(). For Gregorian, no difference.
|
jpayne@69
|
1070 *
|
jpayne@69
|
1071 * @param field The given time field.
|
jpayne@69
|
1072 * @return The highest minimum value for the given time field.
|
jpayne@69
|
1073 * @deprecated ICU 2.6. Use getGreatestMinimum(UCalendarDateFields field) instead.
|
jpayne@69
|
1074 */
|
jpayne@69
|
1075 virtual int32_t getGreatestMinimum(EDateFields field) const;
|
jpayne@69
|
1076 #endif // U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
1077
|
jpayne@69
|
1078 /**
|
jpayne@69
|
1079 * Gets the highest minimum value for the given field if varies. Otherwise same as
|
jpayne@69
|
1080 * getMinimum(). For Gregorian, no difference.
|
jpayne@69
|
1081 *
|
jpayne@69
|
1082 * @param field The given time field.
|
jpayne@69
|
1083 * @return The highest minimum value for the given time field.
|
jpayne@69
|
1084 * @stable ICU 2.6.
|
jpayne@69
|
1085 */
|
jpayne@69
|
1086 virtual int32_t getGreatestMinimum(UCalendarDateFields field) const;
|
jpayne@69
|
1087
|
jpayne@69
|
1088 #ifndef U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
1089 /**
|
jpayne@69
|
1090 * Gets the lowest maximum value for the given field if varies. Otherwise same as
|
jpayne@69
|
1091 * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
|
jpayne@69
|
1092 *
|
jpayne@69
|
1093 * @param field The given time field.
|
jpayne@69
|
1094 * @return The lowest maximum value for the given time field.
|
jpayne@69
|
1095 * @deprecated ICU 2.6. Use getLeastMaximum(UCalendarDateFields field) instead.
|
jpayne@69
|
1096 */
|
jpayne@69
|
1097 virtual int32_t getLeastMaximum(EDateFields field) const;
|
jpayne@69
|
1098 #endif // U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
1099
|
jpayne@69
|
1100 /**
|
jpayne@69
|
1101 * Gets the lowest maximum value for the given field if varies. Otherwise same as
|
jpayne@69
|
1102 * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
|
jpayne@69
|
1103 *
|
jpayne@69
|
1104 * @param field The given time field.
|
jpayne@69
|
1105 * @return The lowest maximum value for the given time field.
|
jpayne@69
|
1106 * @stable ICU 2.6.
|
jpayne@69
|
1107 */
|
jpayne@69
|
1108 virtual int32_t getLeastMaximum(UCalendarDateFields field) const;
|
jpayne@69
|
1109
|
jpayne@69
|
1110 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
1111 /**
|
jpayne@69
|
1112 * Return the minimum value that this field could have, given the current date.
|
jpayne@69
|
1113 * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
|
jpayne@69
|
1114 *
|
jpayne@69
|
1115 * The version of this function on Calendar uses an iterative algorithm to determine the
|
jpayne@69
|
1116 * actual minimum value for the field. There is almost always a more efficient way to
|
jpayne@69
|
1117 * accomplish this (in most cases, you can simply return getMinimum()). GregorianCalendar
|
jpayne@69
|
1118 * overrides this function with a more efficient implementation.
|
jpayne@69
|
1119 *
|
jpayne@69
|
1120 * @param field the field to determine the minimum of
|
jpayne@69
|
1121 * @param status Fill-in parameter which receives the status of this operation.
|
jpayne@69
|
1122 * @return the minimum of the given field for the current date of this Calendar
|
jpayne@69
|
1123 * @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field, UErrorCode& status) instead.
|
jpayne@69
|
1124 */
|
jpayne@69
|
1125 int32_t getActualMinimum(EDateFields field, UErrorCode& status) const;
|
jpayne@69
|
1126 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
1127
|
jpayne@69
|
1128 /**
|
jpayne@69
|
1129 * Return the minimum value that this field could have, given the current date.
|
jpayne@69
|
1130 * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
|
jpayne@69
|
1131 *
|
jpayne@69
|
1132 * The version of this function on Calendar uses an iterative algorithm to determine the
|
jpayne@69
|
1133 * actual minimum value for the field. There is almost always a more efficient way to
|
jpayne@69
|
1134 * accomplish this (in most cases, you can simply return getMinimum()). GregorianCalendar
|
jpayne@69
|
1135 * overrides this function with a more efficient implementation.
|
jpayne@69
|
1136 *
|
jpayne@69
|
1137 * @param field the field to determine the minimum of
|
jpayne@69
|
1138 * @param status Fill-in parameter which receives the status of this operation.
|
jpayne@69
|
1139 * @return the minimum of the given field for the current date of this Calendar
|
jpayne@69
|
1140 * @stable ICU 2.6.
|
jpayne@69
|
1141 */
|
jpayne@69
|
1142 virtual int32_t getActualMinimum(UCalendarDateFields field, UErrorCode& status) const;
|
jpayne@69
|
1143
|
jpayne@69
|
1144 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
1145 /**
|
jpayne@69
|
1146 * Return the maximum value that this field could have, given the current date.
|
jpayne@69
|
1147 * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
|
jpayne@69
|
1148 * maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a Hebrew calendar,
|
jpayne@69
|
1149 * for some years the actual maximum for MONTH is 12, and for others 13.
|
jpayne@69
|
1150 *
|
jpayne@69
|
1151 * The version of this function on Calendar uses an iterative algorithm to determine the
|
jpayne@69
|
1152 * actual maximum value for the field. There is almost always a more efficient way to
|
jpayne@69
|
1153 * accomplish this (in most cases, you can simply return getMaximum()). GregorianCalendar
|
jpayne@69
|
1154 * overrides this function with a more efficient implementation.
|
jpayne@69
|
1155 *
|
jpayne@69
|
1156 * @param field the field to determine the maximum of
|
jpayne@69
|
1157 * @param status Fill-in parameter which receives the status of this operation.
|
jpayne@69
|
1158 * @return the maximum of the given field for the current date of this Calendar
|
jpayne@69
|
1159 * @deprecated ICU 2.6. Use getActualMaximum(UCalendarDateFields field, UErrorCode& status) instead.
|
jpayne@69
|
1160 */
|
jpayne@69
|
1161 int32_t getActualMaximum(EDateFields field, UErrorCode& status) const;
|
jpayne@69
|
1162 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
1163
|
jpayne@69
|
1164 /**
|
jpayne@69
|
1165 * Return the maximum value that this field could have, given the current date.
|
jpayne@69
|
1166 * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
|
jpayne@69
|
1167 * maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a Hebrew calendar,
|
jpayne@69
|
1168 * for some years the actual maximum for MONTH is 12, and for others 13.
|
jpayne@69
|
1169 *
|
jpayne@69
|
1170 * The version of this function on Calendar uses an iterative algorithm to determine the
|
jpayne@69
|
1171 * actual maximum value for the field. There is almost always a more efficient way to
|
jpayne@69
|
1172 * accomplish this (in most cases, you can simply return getMaximum()). GregorianCalendar
|
jpayne@69
|
1173 * overrides this function with a more efficient implementation.
|
jpayne@69
|
1174 *
|
jpayne@69
|
1175 * @param field the field to determine the maximum of
|
jpayne@69
|
1176 * @param status Fill-in parameter which receives the status of this operation.
|
jpayne@69
|
1177 * @return the maximum of the given field for the current date of this Calendar
|
jpayne@69
|
1178 * @stable ICU 2.6.
|
jpayne@69
|
1179 */
|
jpayne@69
|
1180 virtual int32_t getActualMaximum(UCalendarDateFields field, UErrorCode& status) const;
|
jpayne@69
|
1181
|
jpayne@69
|
1182 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
1183 /**
|
jpayne@69
|
1184 * Gets the value for a given time field. Recalculate the current time field values
|
jpayne@69
|
1185 * if the time value has been changed by a call to setTime(). Return zero for unset
|
jpayne@69
|
1186 * fields if any fields have been explicitly set by a call to set(). To force a
|
jpayne@69
|
1187 * recomputation of all fields regardless of the previous state, call complete().
|
jpayne@69
|
1188 * This method is semantically const, but may alter the object in memory.
|
jpayne@69
|
1189 *
|
jpayne@69
|
1190 * @param field The given time field.
|
jpayne@69
|
1191 * @param status Fill-in parameter which receives the status of the operation.
|
jpayne@69
|
1192 * @return The value for the given time field, or zero if the field is unset,
|
jpayne@69
|
1193 * and set() has been called for any other field.
|
jpayne@69
|
1194 * @deprecated ICU 2.6. Use get(UCalendarDateFields field, UErrorCode& status) instead.
|
jpayne@69
|
1195 */
|
jpayne@69
|
1196 int32_t get(EDateFields field, UErrorCode& status) const;
|
jpayne@69
|
1197 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
1198
|
jpayne@69
|
1199 /**
|
jpayne@69
|
1200 * Gets the value for a given time field. Recalculate the current time field values
|
jpayne@69
|
1201 * if the time value has been changed by a call to setTime(). Return zero for unset
|
jpayne@69
|
1202 * fields if any fields have been explicitly set by a call to set(). To force a
|
jpayne@69
|
1203 * recomputation of all fields regardless of the previous state, call complete().
|
jpayne@69
|
1204 * This method is semantically const, but may alter the object in memory.
|
jpayne@69
|
1205 *
|
jpayne@69
|
1206 * @param field The given time field.
|
jpayne@69
|
1207 * @param status Fill-in parameter which receives the status of the operation.
|
jpayne@69
|
1208 * @return The value for the given time field, or zero if the field is unset,
|
jpayne@69
|
1209 * and set() has been called for any other field.
|
jpayne@69
|
1210 * @stable ICU 2.6.
|
jpayne@69
|
1211 */
|
jpayne@69
|
1212 int32_t get(UCalendarDateFields field, UErrorCode& status) const;
|
jpayne@69
|
1213
|
jpayne@69
|
1214 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
1215 /**
|
jpayne@69
|
1216 * Determines if the given time field has a value set. This can affect in the
|
jpayne@69
|
1217 * resolving of time in Calendar. Unset fields have a value of zero, by definition.
|
jpayne@69
|
1218 *
|
jpayne@69
|
1219 * @param field The given time field.
|
jpayne@69
|
1220 * @return True if the given time field has a value set; false otherwise.
|
jpayne@69
|
1221 * @deprecated ICU 2.6. Use isSet(UCalendarDateFields field) instead.
|
jpayne@69
|
1222 */
|
jpayne@69
|
1223 UBool isSet(EDateFields field) const;
|
jpayne@69
|
1224 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
1225
|
jpayne@69
|
1226 /**
|
jpayne@69
|
1227 * Determines if the given time field has a value set. This can affect in the
|
jpayne@69
|
1228 * resolving of time in Calendar. Unset fields have a value of zero, by definition.
|
jpayne@69
|
1229 *
|
jpayne@69
|
1230 * @param field The given time field.
|
jpayne@69
|
1231 * @return True if the given time field has a value set; false otherwise.
|
jpayne@69
|
1232 * @stable ICU 2.6.
|
jpayne@69
|
1233 */
|
jpayne@69
|
1234 UBool isSet(UCalendarDateFields field) const;
|
jpayne@69
|
1235
|
jpayne@69
|
1236 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
1237 /**
|
jpayne@69
|
1238 * Sets the given time field with the given value.
|
jpayne@69
|
1239 *
|
jpayne@69
|
1240 * @param field The given time field.
|
jpayne@69
|
1241 * @param value The value to be set for the given time field.
|
jpayne@69
|
1242 * @deprecated ICU 2.6. Use set(UCalendarDateFields field, int32_t value) instead.
|
jpayne@69
|
1243 */
|
jpayne@69
|
1244 void set(EDateFields field, int32_t value);
|
jpayne@69
|
1245 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
1246
|
jpayne@69
|
1247 /**
|
jpayne@69
|
1248 * Sets the given time field with the given value.
|
jpayne@69
|
1249 *
|
jpayne@69
|
1250 * @param field The given time field.
|
jpayne@69
|
1251 * @param value The value to be set for the given time field.
|
jpayne@69
|
1252 * @stable ICU 2.6.
|
jpayne@69
|
1253 */
|
jpayne@69
|
1254 void set(UCalendarDateFields field, int32_t value);
|
jpayne@69
|
1255
|
jpayne@69
|
1256 /**
|
jpayne@69
|
1257 * Sets the values for the fields YEAR, MONTH, and DATE. Other field values are
|
jpayne@69
|
1258 * retained; call clear() first if this is not desired.
|
jpayne@69
|
1259 *
|
jpayne@69
|
1260 * @param year The value used to set the YEAR time field.
|
jpayne@69
|
1261 * @param month The value used to set the MONTH time field. Month value is 0-based.
|
jpayne@69
|
1262 * e.g., 0 for January.
|
jpayne@69
|
1263 * @param date The value used to set the DATE time field.
|
jpayne@69
|
1264 * @stable ICU 2.0
|
jpayne@69
|
1265 */
|
jpayne@69
|
1266 void set(int32_t year, int32_t month, int32_t date);
|
jpayne@69
|
1267
|
jpayne@69
|
1268 /**
|
jpayne@69
|
1269 * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, and MINUTE. Other
|
jpayne@69
|
1270 * field values are retained; call clear() first if this is not desired.
|
jpayne@69
|
1271 *
|
jpayne@69
|
1272 * @param year The value used to set the YEAR time field.
|
jpayne@69
|
1273 * @param month The value used to set the MONTH time field. Month value is
|
jpayne@69
|
1274 * 0-based. E.g., 0 for January.
|
jpayne@69
|
1275 * @param date The value used to set the DATE time field.
|
jpayne@69
|
1276 * @param hour The value used to set the HOUR_OF_DAY time field.
|
jpayne@69
|
1277 * @param minute The value used to set the MINUTE time field.
|
jpayne@69
|
1278 * @stable ICU 2.0
|
jpayne@69
|
1279 */
|
jpayne@69
|
1280 void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute);
|
jpayne@69
|
1281
|
jpayne@69
|
1282 /**
|
jpayne@69
|
1283 * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, MINUTE, and SECOND.
|
jpayne@69
|
1284 * Other field values are retained; call clear() first if this is not desired.
|
jpayne@69
|
1285 *
|
jpayne@69
|
1286 * @param year The value used to set the YEAR time field.
|
jpayne@69
|
1287 * @param month The value used to set the MONTH time field. Month value is
|
jpayne@69
|
1288 * 0-based. E.g., 0 for January.
|
jpayne@69
|
1289 * @param date The value used to set the DATE time field.
|
jpayne@69
|
1290 * @param hour The value used to set the HOUR_OF_DAY time field.
|
jpayne@69
|
1291 * @param minute The value used to set the MINUTE time field.
|
jpayne@69
|
1292 * @param second The value used to set the SECOND time field.
|
jpayne@69
|
1293 * @stable ICU 2.0
|
jpayne@69
|
1294 */
|
jpayne@69
|
1295 void set(int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second);
|
jpayne@69
|
1296
|
jpayne@69
|
1297 /**
|
jpayne@69
|
1298 * Clears the values of all the time fields, making them both unset and assigning
|
jpayne@69
|
1299 * them a value of zero. The field values will be determined during the next
|
jpayne@69
|
1300 * resolving of time into time fields.
|
jpayne@69
|
1301 * @stable ICU 2.0
|
jpayne@69
|
1302 */
|
jpayne@69
|
1303 void clear(void);
|
jpayne@69
|
1304
|
jpayne@69
|
1305 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
1306 /**
|
jpayne@69
|
1307 * Clears the value in the given time field, both making it unset and assigning it a
|
jpayne@69
|
1308 * value of zero. This field value will be determined during the next resolving of
|
jpayne@69
|
1309 * time into time fields.
|
jpayne@69
|
1310 *
|
jpayne@69
|
1311 * @param field The time field to be cleared.
|
jpayne@69
|
1312 * @deprecated ICU 2.6. Use clear(UCalendarDateFields field) instead.
|
jpayne@69
|
1313 */
|
jpayne@69
|
1314 void clear(EDateFields field);
|
jpayne@69
|
1315 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
1316
|
jpayne@69
|
1317 /**
|
jpayne@69
|
1318 * Clears the value in the given time field, both making it unset and assigning it a
|
jpayne@69
|
1319 * value of zero. This field value will be determined during the next resolving of
|
jpayne@69
|
1320 * time into time fields.
|
jpayne@69
|
1321 *
|
jpayne@69
|
1322 * @param field The time field to be cleared.
|
jpayne@69
|
1323 * @stable ICU 2.6.
|
jpayne@69
|
1324 */
|
jpayne@69
|
1325 void clear(UCalendarDateFields field);
|
jpayne@69
|
1326
|
jpayne@69
|
1327 /**
|
jpayne@69
|
1328 * Returns a unique class ID POLYMORPHICALLY. Pure virtual method. This method is to
|
jpayne@69
|
1329 * implement a simple version of RTTI, since not all C++ compilers support genuine
|
jpayne@69
|
1330 * RTTI. Polymorphic operator==() and clone() methods call this method.
|
jpayne@69
|
1331 * <P>
|
jpayne@69
|
1332 * Concrete subclasses of Calendar must implement getDynamicClassID() and also a
|
jpayne@69
|
1333 * static method and data member:
|
jpayne@69
|
1334 *
|
jpayne@69
|
1335 * static UClassID getStaticClassID() { return (UClassID)&fgClassID; }
|
jpayne@69
|
1336 * static char fgClassID;
|
jpayne@69
|
1337 *
|
jpayne@69
|
1338 * @return The class ID for this object. All objects of a given class have the
|
jpayne@69
|
1339 * same class ID. Objects of other classes have different class IDs.
|
jpayne@69
|
1340 * @stable ICU 2.0
|
jpayne@69
|
1341 */
|
jpayne@69
|
1342 virtual UClassID getDynamicClassID(void) const = 0;
|
jpayne@69
|
1343
|
jpayne@69
|
1344 /**
|
jpayne@69
|
1345 * Returns the calendar type name string for this Calendar object.
|
jpayne@69
|
1346 * The returned string is the legacy ICU calendar attribute value,
|
jpayne@69
|
1347 * for example, "gregorian" or "japanese".
|
jpayne@69
|
1348 *
|
jpayne@69
|
1349 * See type="old type name" for the calendar attribute of locale IDs
|
jpayne@69
|
1350 * at http://www.unicode.org/reports/tr35/#Key_Type_Definitions
|
jpayne@69
|
1351 *
|
jpayne@69
|
1352 * Sample code for getting the LDML/BCP 47 calendar key value:
|
jpayne@69
|
1353 * \code
|
jpayne@69
|
1354 * const char *calType = cal->getType();
|
jpayne@69
|
1355 * if (0 == strcmp(calType, "unknown")) {
|
jpayne@69
|
1356 * // deal with unknown calendar type
|
jpayne@69
|
1357 * } else {
|
jpayne@69
|
1358 * string localeID("root@calendar=");
|
jpayne@69
|
1359 * localeID.append(calType);
|
jpayne@69
|
1360 * char langTag[100];
|
jpayne@69
|
1361 * UErrorCode errorCode = U_ZERO_ERROR;
|
jpayne@69
|
1362 * int32_t length = uloc_toLanguageTag(localeID.c_str(), langTag, (int32_t)sizeof(langTag), TRUE, &errorCode);
|
jpayne@69
|
1363 * if (U_FAILURE(errorCode)) {
|
jpayne@69
|
1364 * // deal with errors & overflow
|
jpayne@69
|
1365 * }
|
jpayne@69
|
1366 * string lang(langTag, length);
|
jpayne@69
|
1367 * size_t caPos = lang.find("-ca-");
|
jpayne@69
|
1368 * lang.erase(0, caPos + 4);
|
jpayne@69
|
1369 * // lang now contains the LDML calendar type
|
jpayne@69
|
1370 * }
|
jpayne@69
|
1371 * \endcode
|
jpayne@69
|
1372 *
|
jpayne@69
|
1373 * @return legacy calendar type name string
|
jpayne@69
|
1374 * @stable ICU 49
|
jpayne@69
|
1375 */
|
jpayne@69
|
1376 virtual const char * getType() const = 0;
|
jpayne@69
|
1377
|
jpayne@69
|
1378 /**
|
jpayne@69
|
1379 * Returns whether the given day of the week is a weekday, a weekend day,
|
jpayne@69
|
1380 * or a day that transitions from one to the other, for the locale and
|
jpayne@69
|
1381 * calendar system associated with this Calendar (the locale's region is
|
jpayne@69
|
1382 * often the most determinant factor). If a transition occurs at midnight,
|
jpayne@69
|
1383 * then the days before and after the transition will have the
|
jpayne@69
|
1384 * type UCAL_WEEKDAY or UCAL_WEEKEND. If a transition occurs at a time
|
jpayne@69
|
1385 * other than midnight, then the day of the transition will have
|
jpayne@69
|
1386 * the type UCAL_WEEKEND_ONSET or UCAL_WEEKEND_CEASE. In this case, the
|
jpayne@69
|
1387 * method getWeekendTransition() will return the point of
|
jpayne@69
|
1388 * transition.
|
jpayne@69
|
1389 * @param dayOfWeek The day of the week whose type is desired (UCAL_SUNDAY..UCAL_SATURDAY).
|
jpayne@69
|
1390 * @param status The error code for the operation.
|
jpayne@69
|
1391 * @return The UCalendarWeekdayType for the day of the week.
|
jpayne@69
|
1392 * @stable ICU 4.4
|
jpayne@69
|
1393 */
|
jpayne@69
|
1394 virtual UCalendarWeekdayType getDayOfWeekType(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
|
jpayne@69
|
1395
|
jpayne@69
|
1396 /**
|
jpayne@69
|
1397 * Returns the time during the day at which the weekend begins or ends in
|
jpayne@69
|
1398 * this calendar system. If getDayOfWeekType() returns UCAL_WEEKEND_ONSET
|
jpayne@69
|
1399 * for the specified dayOfWeek, return the time at which the weekend begins.
|
jpayne@69
|
1400 * If getDayOfWeekType() returns UCAL_WEEKEND_CEASE for the specified dayOfWeek,
|
jpayne@69
|
1401 * return the time at which the weekend ends. If getDayOfWeekType() returns
|
jpayne@69
|
1402 * some other UCalendarWeekdayType for the specified dayOfWeek, is it an error condition
|
jpayne@69
|
1403 * (U_ILLEGAL_ARGUMENT_ERROR).
|
jpayne@69
|
1404 * @param dayOfWeek The day of the week for which the weekend transition time is
|
jpayne@69
|
1405 * desired (UCAL_SUNDAY..UCAL_SATURDAY).
|
jpayne@69
|
1406 * @param status The error code for the operation.
|
jpayne@69
|
1407 * @return The milliseconds after midnight at which the weekend begins or ends.
|
jpayne@69
|
1408 * @stable ICU 4.4
|
jpayne@69
|
1409 */
|
jpayne@69
|
1410 virtual int32_t getWeekendTransition(UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const;
|
jpayne@69
|
1411
|
jpayne@69
|
1412 /**
|
jpayne@69
|
1413 * Returns TRUE if the given UDate is in the weekend in
|
jpayne@69
|
1414 * this calendar system.
|
jpayne@69
|
1415 * @param date The UDate in question.
|
jpayne@69
|
1416 * @param status The error code for the operation.
|
jpayne@69
|
1417 * @return TRUE if the given UDate is in the weekend in
|
jpayne@69
|
1418 * this calendar system, FALSE otherwise.
|
jpayne@69
|
1419 * @stable ICU 4.4
|
jpayne@69
|
1420 */
|
jpayne@69
|
1421 virtual UBool isWeekend(UDate date, UErrorCode &status) const;
|
jpayne@69
|
1422
|
jpayne@69
|
1423 /**
|
jpayne@69
|
1424 * Returns TRUE if this Calendar's current date-time is in the weekend in
|
jpayne@69
|
1425 * this calendar system.
|
jpayne@69
|
1426 * @return TRUE if this Calendar's current date-time is in the weekend in
|
jpayne@69
|
1427 * this calendar system, FALSE otherwise.
|
jpayne@69
|
1428 * @stable ICU 4.4
|
jpayne@69
|
1429 */
|
jpayne@69
|
1430 virtual UBool isWeekend(void) const;
|
jpayne@69
|
1431
|
jpayne@69
|
1432 protected:
|
jpayne@69
|
1433
|
jpayne@69
|
1434 /**
|
jpayne@69
|
1435 * Constructs a Calendar with the default time zone as returned by
|
jpayne@69
|
1436 * TimeZone::createInstance(), and the default locale.
|
jpayne@69
|
1437 *
|
jpayne@69
|
1438 * @param success Indicates the status of Calendar object construction. Returns
|
jpayne@69
|
1439 * U_ZERO_ERROR if constructed successfully.
|
jpayne@69
|
1440 * @stable ICU 2.0
|
jpayne@69
|
1441 */
|
jpayne@69
|
1442 Calendar(UErrorCode& success);
|
jpayne@69
|
1443
|
jpayne@69
|
1444 /**
|
jpayne@69
|
1445 * Copy constructor
|
jpayne@69
|
1446 *
|
jpayne@69
|
1447 * @param source Calendar object to be copied from
|
jpayne@69
|
1448 * @stable ICU 2.0
|
jpayne@69
|
1449 */
|
jpayne@69
|
1450 Calendar(const Calendar& source);
|
jpayne@69
|
1451
|
jpayne@69
|
1452 /**
|
jpayne@69
|
1453 * Default assignment operator
|
jpayne@69
|
1454 *
|
jpayne@69
|
1455 * @param right Calendar object to be copied
|
jpayne@69
|
1456 * @stable ICU 2.0
|
jpayne@69
|
1457 */
|
jpayne@69
|
1458 Calendar& operator=(const Calendar& right);
|
jpayne@69
|
1459
|
jpayne@69
|
1460 /**
|
jpayne@69
|
1461 * Constructs a Calendar with the given time zone and locale. Clients are no longer
|
jpayne@69
|
1462 * responsible for deleting the given time zone object after it's adopted.
|
jpayne@69
|
1463 *
|
jpayne@69
|
1464 * @param zone The given time zone.
|
jpayne@69
|
1465 * @param aLocale The given locale.
|
jpayne@69
|
1466 * @param success Indicates the status of Calendar object construction. Returns
|
jpayne@69
|
1467 * U_ZERO_ERROR if constructed successfully.
|
jpayne@69
|
1468 * @stable ICU 2.0
|
jpayne@69
|
1469 */
|
jpayne@69
|
1470 Calendar(TimeZone* zone, const Locale& aLocale, UErrorCode& success);
|
jpayne@69
|
1471
|
jpayne@69
|
1472 /**
|
jpayne@69
|
1473 * Constructs a Calendar with the given time zone and locale.
|
jpayne@69
|
1474 *
|
jpayne@69
|
1475 * @param zone The given time zone.
|
jpayne@69
|
1476 * @param aLocale The given locale.
|
jpayne@69
|
1477 * @param success Indicates the status of Calendar object construction. Returns
|
jpayne@69
|
1478 * U_ZERO_ERROR if constructed successfully.
|
jpayne@69
|
1479 * @stable ICU 2.0
|
jpayne@69
|
1480 */
|
jpayne@69
|
1481 Calendar(const TimeZone& zone, const Locale& aLocale, UErrorCode& success);
|
jpayne@69
|
1482
|
jpayne@69
|
1483 /**
|
jpayne@69
|
1484 * Converts Calendar's time field values to GMT as milliseconds.
|
jpayne@69
|
1485 *
|
jpayne@69
|
1486 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
1487 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
1488 * leniency, this will be set to an error status.
|
jpayne@69
|
1489 * @stable ICU 2.0
|
jpayne@69
|
1490 */
|
jpayne@69
|
1491 virtual void computeTime(UErrorCode& status);
|
jpayne@69
|
1492
|
jpayne@69
|
1493 /**
|
jpayne@69
|
1494 * Converts GMT as milliseconds to time field values. This allows you to sync up the
|
jpayne@69
|
1495 * time field values with a new time that is set for the calendar. This method
|
jpayne@69
|
1496 * does NOT recompute the time first; to recompute the time, then the fields, use
|
jpayne@69
|
1497 * the method complete().
|
jpayne@69
|
1498 *
|
jpayne@69
|
1499 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
1500 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
1501 * leniency, this will be set to an error status.
|
jpayne@69
|
1502 * @stable ICU 2.0
|
jpayne@69
|
1503 */
|
jpayne@69
|
1504 virtual void computeFields(UErrorCode& status);
|
jpayne@69
|
1505
|
jpayne@69
|
1506 /**
|
jpayne@69
|
1507 * Gets this Calendar's current time as a long.
|
jpayne@69
|
1508 *
|
jpayne@69
|
1509 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
1510 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
1511 * leniency, this will be set to an error status.
|
jpayne@69
|
1512 * @return the current time as UTC milliseconds from the epoch.
|
jpayne@69
|
1513 * @stable ICU 2.0
|
jpayne@69
|
1514 */
|
jpayne@69
|
1515 double getTimeInMillis(UErrorCode& status) const;
|
jpayne@69
|
1516
|
jpayne@69
|
1517 /**
|
jpayne@69
|
1518 * Sets this Calendar's current time from the given long value.
|
jpayne@69
|
1519 * @param millis the new time in UTC milliseconds from the epoch.
|
jpayne@69
|
1520 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
1521 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
1522 * leniency, this will be set to an error status.
|
jpayne@69
|
1523 * @stable ICU 2.0
|
jpayne@69
|
1524 */
|
jpayne@69
|
1525 void setTimeInMillis( double millis, UErrorCode& status );
|
jpayne@69
|
1526
|
jpayne@69
|
1527 /**
|
jpayne@69
|
1528 * Recomputes the current time from currently set fields, and then fills in any
|
jpayne@69
|
1529 * unset fields in the time field list.
|
jpayne@69
|
1530 *
|
jpayne@69
|
1531 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
1532 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
1533 * leniency, this will be set to an error status.
|
jpayne@69
|
1534 * @stable ICU 2.0
|
jpayne@69
|
1535 */
|
jpayne@69
|
1536 void complete(UErrorCode& status);
|
jpayne@69
|
1537
|
jpayne@69
|
1538 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
1539 /**
|
jpayne@69
|
1540 * Gets the value for a given time field. Subclasses can use this function to get
|
jpayne@69
|
1541 * field values without forcing recomputation of time.
|
jpayne@69
|
1542 *
|
jpayne@69
|
1543 * @param field The given time field.
|
jpayne@69
|
1544 * @return The value for the given time field.
|
jpayne@69
|
1545 * @deprecated ICU 2.6. Use internalGet(UCalendarDateFields field) instead.
|
jpayne@69
|
1546 */
|
jpayne@69
|
1547 inline int32_t internalGet(EDateFields field) const {return fFields[field];}
|
jpayne@69
|
1548 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
1549
|
jpayne@69
|
1550 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
1551 /**
|
jpayne@69
|
1552 * Gets the value for a given time field. Subclasses can use this function to get
|
jpayne@69
|
1553 * field values without forcing recomputation of time. If the field's stamp is UNSET,
|
jpayne@69
|
1554 * the defaultValue is used.
|
jpayne@69
|
1555 *
|
jpayne@69
|
1556 * @param field The given time field.
|
jpayne@69
|
1557 * @param defaultValue a default value used if the field is unset.
|
jpayne@69
|
1558 * @return The value for the given time field.
|
jpayne@69
|
1559 * @internal
|
jpayne@69
|
1560 */
|
jpayne@69
|
1561 inline int32_t internalGet(UCalendarDateFields field, int32_t defaultValue) const {return fStamp[field]>kUnset ? fFields[field] : defaultValue;}
|
jpayne@69
|
1562
|
jpayne@69
|
1563 /**
|
jpayne@69
|
1564 * Gets the value for a given time field. Subclasses can use this function to get
|
jpayne@69
|
1565 * field values without forcing recomputation of time.
|
jpayne@69
|
1566 *
|
jpayne@69
|
1567 * @param field The given time field.
|
jpayne@69
|
1568 * @return The value for the given time field.
|
jpayne@69
|
1569 * @internal
|
jpayne@69
|
1570 */
|
jpayne@69
|
1571 inline int32_t internalGet(UCalendarDateFields field) const {return fFields[field];}
|
jpayne@69
|
1572 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
1573
|
jpayne@69
|
1574 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
1575 /**
|
jpayne@69
|
1576 * Sets the value for a given time field. This is a fast internal method for
|
jpayne@69
|
1577 * subclasses. It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet
|
jpayne@69
|
1578 * flags.
|
jpayne@69
|
1579 *
|
jpayne@69
|
1580 * @param field The given time field.
|
jpayne@69
|
1581 * @param value The value for the given time field.
|
jpayne@69
|
1582 * @deprecated ICU 2.6. Use internalSet(UCalendarDateFields field, int32_t value) instead.
|
jpayne@69
|
1583 */
|
jpayne@69
|
1584 void internalSet(EDateFields field, int32_t value);
|
jpayne@69
|
1585 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
1586
|
jpayne@69
|
1587 /**
|
jpayne@69
|
1588 * Sets the value for a given time field. This is a fast internal method for
|
jpayne@69
|
1589 * subclasses. It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet
|
jpayne@69
|
1590 * flags.
|
jpayne@69
|
1591 *
|
jpayne@69
|
1592 * @param field The given time field.
|
jpayne@69
|
1593 * @param value The value for the given time field.
|
jpayne@69
|
1594 * @stable ICU 2.6.
|
jpayne@69
|
1595 */
|
jpayne@69
|
1596 inline void internalSet(UCalendarDateFields field, int32_t value);
|
jpayne@69
|
1597
|
jpayne@69
|
1598 /**
|
jpayne@69
|
1599 * Prepare this calendar for computing the actual minimum or maximum.
|
jpayne@69
|
1600 * This method modifies this calendar's fields; it is called on a
|
jpayne@69
|
1601 * temporary calendar.
|
jpayne@69
|
1602 * @internal
|
jpayne@69
|
1603 */
|
jpayne@69
|
1604 virtual void prepareGetActual(UCalendarDateFields field, UBool isMinimum, UErrorCode &status);
|
jpayne@69
|
1605
|
jpayne@69
|
1606 /**
|
jpayne@69
|
1607 * Limit enums. Not in sync with UCalendarLimitType (refers to internal fields).
|
jpayne@69
|
1608 * @internal
|
jpayne@69
|
1609 */
|
jpayne@69
|
1610 enum ELimitType {
|
jpayne@69
|
1611 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
1612 UCAL_LIMIT_MINIMUM = 0,
|
jpayne@69
|
1613 UCAL_LIMIT_GREATEST_MINIMUM,
|
jpayne@69
|
1614 UCAL_LIMIT_LEAST_MAXIMUM,
|
jpayne@69
|
1615 UCAL_LIMIT_MAXIMUM,
|
jpayne@69
|
1616 UCAL_LIMIT_COUNT
|
jpayne@69
|
1617 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
1618 };
|
jpayne@69
|
1619
|
jpayne@69
|
1620 /**
|
jpayne@69
|
1621 * Subclass API for defining limits of different types.
|
jpayne@69
|
1622 * Subclasses must implement this method to return limits for the
|
jpayne@69
|
1623 * following fields:
|
jpayne@69
|
1624 *
|
jpayne@69
|
1625 * <pre>UCAL_ERA
|
jpayne@69
|
1626 * UCAL_YEAR
|
jpayne@69
|
1627 * UCAL_MONTH
|
jpayne@69
|
1628 * UCAL_WEEK_OF_YEAR
|
jpayne@69
|
1629 * UCAL_WEEK_OF_MONTH
|
jpayne@69
|
1630 * UCAL_DATE (DAY_OF_MONTH on Java)
|
jpayne@69
|
1631 * UCAL_DAY_OF_YEAR
|
jpayne@69
|
1632 * UCAL_DAY_OF_WEEK_IN_MONTH
|
jpayne@69
|
1633 * UCAL_YEAR_WOY
|
jpayne@69
|
1634 * UCAL_EXTENDED_YEAR</pre>
|
jpayne@69
|
1635 *
|
jpayne@69
|
1636 * @param field one of the above field numbers
|
jpayne@69
|
1637 * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,
|
jpayne@69
|
1638 * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>
|
jpayne@69
|
1639 * @internal
|
jpayne@69
|
1640 */
|
jpayne@69
|
1641 virtual int32_t handleGetLimit(UCalendarDateFields field, ELimitType limitType) const = 0;
|
jpayne@69
|
1642
|
jpayne@69
|
1643 /**
|
jpayne@69
|
1644 * Return a limit for a field.
|
jpayne@69
|
1645 * @param field the field, from <code>0..UCAL_MAX_FIELD</code>
|
jpayne@69
|
1646 * @param limitType the type specifier for the limit
|
jpayne@69
|
1647 * @see #ELimitType
|
jpayne@69
|
1648 * @internal
|
jpayne@69
|
1649 */
|
jpayne@69
|
1650 virtual int32_t getLimit(UCalendarDateFields field, ELimitType limitType) const;
|
jpayne@69
|
1651
|
jpayne@69
|
1652
|
jpayne@69
|
1653 /**
|
jpayne@69
|
1654 * Return the Julian day number of day before the first day of the
|
jpayne@69
|
1655 * given month in the given extended year. Subclasses should override
|
jpayne@69
|
1656 * this method to implement their calendar system.
|
jpayne@69
|
1657 * @param eyear the extended year
|
jpayne@69
|
1658 * @param month the zero-based month, or 0 if useMonth is false
|
jpayne@69
|
1659 * @param useMonth if false, compute the day before the first day of
|
jpayne@69
|
1660 * the given year, otherwise, compute the day before the first day of
|
jpayne@69
|
1661 * the given month
|
jpayne@69
|
1662 * @return the Julian day number of the day before the first
|
jpayne@69
|
1663 * day of the given month and year
|
jpayne@69
|
1664 * @internal
|
jpayne@69
|
1665 */
|
jpayne@69
|
1666 virtual int32_t handleComputeMonthStart(int32_t eyear, int32_t month,
|
jpayne@69
|
1667 UBool useMonth) const = 0;
|
jpayne@69
|
1668
|
jpayne@69
|
1669 /**
|
jpayne@69
|
1670 * Return the number of days in the given month of the given extended
|
jpayne@69
|
1671 * year of this calendar system. Subclasses should override this
|
jpayne@69
|
1672 * method if they can provide a more correct or more efficient
|
jpayne@69
|
1673 * implementation than the default implementation in Calendar.
|
jpayne@69
|
1674 * @internal
|
jpayne@69
|
1675 */
|
jpayne@69
|
1676 virtual int32_t handleGetMonthLength(int32_t extendedYear, int32_t month) const ;
|
jpayne@69
|
1677
|
jpayne@69
|
1678 /**
|
jpayne@69
|
1679 * Return the number of days in the given extended year of this
|
jpayne@69
|
1680 * calendar system. Subclasses should override this method if they can
|
jpayne@69
|
1681 * provide a more correct or more efficient implementation than the
|
jpayne@69
|
1682 * default implementation in Calendar.
|
jpayne@69
|
1683 * @stable ICU 2.0
|
jpayne@69
|
1684 */
|
jpayne@69
|
1685 virtual int32_t handleGetYearLength(int32_t eyear) const;
|
jpayne@69
|
1686
|
jpayne@69
|
1687
|
jpayne@69
|
1688 /**
|
jpayne@69
|
1689 * Return the extended year defined by the current fields. This will
|
jpayne@69
|
1690 * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
|
jpayne@69
|
1691 * as UCAL_ERA) specific to the calendar system, depending on which set of
|
jpayne@69
|
1692 * fields is newer.
|
jpayne@69
|
1693 * @return the extended year
|
jpayne@69
|
1694 * @internal
|
jpayne@69
|
1695 */
|
jpayne@69
|
1696 virtual int32_t handleGetExtendedYear() = 0;
|
jpayne@69
|
1697
|
jpayne@69
|
1698 /**
|
jpayne@69
|
1699 * Subclasses may override this. This method calls
|
jpayne@69
|
1700 * handleGetMonthLength() to obtain the calendar-specific month
|
jpayne@69
|
1701 * length.
|
jpayne@69
|
1702 * @param bestField which field to use to calculate the date
|
jpayne@69
|
1703 * @return julian day specified by calendar fields.
|
jpayne@69
|
1704 * @internal
|
jpayne@69
|
1705 */
|
jpayne@69
|
1706 virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField);
|
jpayne@69
|
1707
|
jpayne@69
|
1708 /**
|
jpayne@69
|
1709 * Subclasses must override this to convert from week fields
|
jpayne@69
|
1710 * (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case
|
jpayne@69
|
1711 * where YEAR, EXTENDED_YEAR are not set.
|
jpayne@69
|
1712 * The Calendar implementation assumes yearWoy is in extended gregorian form
|
jpayne@69
|
1713 * @return the extended year, UCAL_EXTENDED_YEAR
|
jpayne@69
|
1714 * @internal
|
jpayne@69
|
1715 */
|
jpayne@69
|
1716 virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy, int32_t woy);
|
jpayne@69
|
1717
|
jpayne@69
|
1718 /**
|
jpayne@69
|
1719 * Validate a single field of this calendar. Subclasses should
|
jpayne@69
|
1720 * override this method to validate any calendar-specific fields.
|
jpayne@69
|
1721 * Generic fields can be handled by `Calendar::validateField()`.
|
jpayne@69
|
1722 * @internal
|
jpayne@69
|
1723 */
|
jpayne@69
|
1724 virtual void validateField(UCalendarDateFields field, UErrorCode &status);
|
jpayne@69
|
1725
|
jpayne@69
|
1726 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
1727 /**
|
jpayne@69
|
1728 * Compute the Julian day from fields. Will determine whether to use
|
jpayne@69
|
1729 * the JULIAN_DAY field directly, or other fields.
|
jpayne@69
|
1730 * @return the julian day
|
jpayne@69
|
1731 * @internal
|
jpayne@69
|
1732 */
|
jpayne@69
|
1733 int32_t computeJulianDay();
|
jpayne@69
|
1734
|
jpayne@69
|
1735 /**
|
jpayne@69
|
1736 * Compute the milliseconds in the day from the fields. This is a
|
jpayne@69
|
1737 * value from 0 to 23:59:59.999 inclusive, unless fields are out of
|
jpayne@69
|
1738 * range, in which case it can be an arbitrary value. This value
|
jpayne@69
|
1739 * reflects local zone wall time.
|
jpayne@69
|
1740 * @internal
|
jpayne@69
|
1741 */
|
jpayne@69
|
1742 double computeMillisInDay();
|
jpayne@69
|
1743
|
jpayne@69
|
1744 /**
|
jpayne@69
|
1745 * This method can assume EXTENDED_YEAR has been set.
|
jpayne@69
|
1746 * @param millis milliseconds of the date fields
|
jpayne@69
|
1747 * @param millisInDay milliseconds of the time fields; may be out
|
jpayne@69
|
1748 * or range.
|
jpayne@69
|
1749 * @param ec Output param set to failure code on function return
|
jpayne@69
|
1750 * when this function fails.
|
jpayne@69
|
1751 * @internal
|
jpayne@69
|
1752 */
|
jpayne@69
|
1753 int32_t computeZoneOffset(double millis, double millisInDay, UErrorCode &ec);
|
jpayne@69
|
1754
|
jpayne@69
|
1755
|
jpayne@69
|
1756 /**
|
jpayne@69
|
1757 * Determine the best stamp in a range.
|
jpayne@69
|
1758 * @param start first enum to look at
|
jpayne@69
|
1759 * @param end last enum to look at
|
jpayne@69
|
1760 * @param bestSoFar stamp prior to function call
|
jpayne@69
|
1761 * @return the stamp value of the best stamp
|
jpayne@69
|
1762 * @internal
|
jpayne@69
|
1763 */
|
jpayne@69
|
1764 int32_t newestStamp(UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const;
|
jpayne@69
|
1765
|
jpayne@69
|
1766 /**
|
jpayne@69
|
1767 * Values for field resolution tables
|
jpayne@69
|
1768 * @see #resolveFields
|
jpayne@69
|
1769 * @internal
|
jpayne@69
|
1770 */
|
jpayne@69
|
1771 enum {
|
jpayne@69
|
1772 /** Marker for end of resolve set (row or group). */
|
jpayne@69
|
1773 kResolveSTOP = -1,
|
jpayne@69
|
1774 /** Value to be bitwised "ORed" against resolve table field values for remapping. Example: (UCAL_DATE | kResolveRemap) in 1st column will cause 'UCAL_DATE' to be returned, but will not examine the value of UCAL_DATE. */
|
jpayne@69
|
1775 kResolveRemap = 32
|
jpayne@69
|
1776 };
|
jpayne@69
|
1777
|
jpayne@69
|
1778 /**
|
jpayne@69
|
1779 * Precedence table for Dates
|
jpayne@69
|
1780 * @see #resolveFields
|
jpayne@69
|
1781 * @internal
|
jpayne@69
|
1782 */
|
jpayne@69
|
1783 static const UFieldResolutionTable kDatePrecedence[];
|
jpayne@69
|
1784
|
jpayne@69
|
1785 /**
|
jpayne@69
|
1786 * Precedence table for Year
|
jpayne@69
|
1787 * @see #resolveFields
|
jpayne@69
|
1788 * @internal
|
jpayne@69
|
1789 */
|
jpayne@69
|
1790 static const UFieldResolutionTable kYearPrecedence[];
|
jpayne@69
|
1791
|
jpayne@69
|
1792 /**
|
jpayne@69
|
1793 * Precedence table for Day of Week
|
jpayne@69
|
1794 * @see #resolveFields
|
jpayne@69
|
1795 * @internal
|
jpayne@69
|
1796 */
|
jpayne@69
|
1797 static const UFieldResolutionTable kDOWPrecedence[];
|
jpayne@69
|
1798
|
jpayne@69
|
1799 /**
|
jpayne@69
|
1800 * Given a precedence table, return the newest field combination in
|
jpayne@69
|
1801 * the table, or UCAL_FIELD_COUNT if none is found.
|
jpayne@69
|
1802 *
|
jpayne@69
|
1803 * <p>The precedence table is a 3-dimensional array of integers. It
|
jpayne@69
|
1804 * may be thought of as an array of groups. Each group is an array of
|
jpayne@69
|
1805 * lines. Each line is an array of field numbers. Within a line, if
|
jpayne@69
|
1806 * all fields are set, then the time stamp of the line is taken to be
|
jpayne@69
|
1807 * the stamp of the most recently set field. If any field of a line is
|
jpayne@69
|
1808 * unset, then the line fails to match. Within a group, the line with
|
jpayne@69
|
1809 * the newest time stamp is selected. The first field of the line is
|
jpayne@69
|
1810 * returned to indicate which line matched.
|
jpayne@69
|
1811 *
|
jpayne@69
|
1812 * <p>In some cases, it may be desirable to map a line to field that
|
jpayne@69
|
1813 * whose stamp is NOT examined. For example, if the best field is
|
jpayne@69
|
1814 * DAY_OF_WEEK then the DAY_OF_WEEK_IN_MONTH algorithm may be used. In
|
jpayne@69
|
1815 * order to do this, insert the value <code>kResolveRemap | F</code> at
|
jpayne@69
|
1816 * the start of the line, where <code>F</code> is the desired return
|
jpayne@69
|
1817 * field value. This field will NOT be examined; it only determines
|
jpayne@69
|
1818 * the return value if the other fields in the line are the newest.
|
jpayne@69
|
1819 *
|
jpayne@69
|
1820 * <p>If all lines of a group contain at least one unset field, then no
|
jpayne@69
|
1821 * line will match, and the group as a whole will fail to match. In
|
jpayne@69
|
1822 * that case, the next group will be processed. If all groups fail to
|
jpayne@69
|
1823 * match, then UCAL_FIELD_COUNT is returned.
|
jpayne@69
|
1824 * @internal
|
jpayne@69
|
1825 */
|
jpayne@69
|
1826 UCalendarDateFields resolveFields(const UFieldResolutionTable *precedenceTable);
|
jpayne@69
|
1827 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
1828
|
jpayne@69
|
1829
|
jpayne@69
|
1830 /**
|
jpayne@69
|
1831 * @internal
|
jpayne@69
|
1832 */
|
jpayne@69
|
1833 virtual const UFieldResolutionTable* getFieldResolutionTable() const;
|
jpayne@69
|
1834
|
jpayne@69
|
1835 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
1836 /**
|
jpayne@69
|
1837 * Return the field that is newer, either defaultField, or
|
jpayne@69
|
1838 * alternateField. If neither is newer or neither is set, return defaultField.
|
jpayne@69
|
1839 * @internal
|
jpayne@69
|
1840 */
|
jpayne@69
|
1841 UCalendarDateFields newerField(UCalendarDateFields defaultField, UCalendarDateFields alternateField) const;
|
jpayne@69
|
1842 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
1843
|
jpayne@69
|
1844
|
jpayne@69
|
1845 private:
|
jpayne@69
|
1846 /**
|
jpayne@69
|
1847 * Helper function for calculating limits by trial and error
|
jpayne@69
|
1848 * @param field The field being investigated
|
jpayne@69
|
1849 * @param startValue starting (least max) value of field
|
jpayne@69
|
1850 * @param endValue ending (greatest max) value of field
|
jpayne@69
|
1851 * @param status return type
|
jpayne@69
|
1852 * @internal
|
jpayne@69
|
1853 */
|
jpayne@69
|
1854 int32_t getActualHelper(UCalendarDateFields field, int32_t startValue, int32_t endValue, UErrorCode &status) const;
|
jpayne@69
|
1855
|
jpayne@69
|
1856
|
jpayne@69
|
1857 protected:
|
jpayne@69
|
1858 /**
|
jpayne@69
|
1859 * The flag which indicates if the current time is set in the calendar.
|
jpayne@69
|
1860 * @stable ICU 2.0
|
jpayne@69
|
1861 */
|
jpayne@69
|
1862 UBool fIsTimeSet;
|
jpayne@69
|
1863
|
jpayne@69
|
1864 /**
|
jpayne@69
|
1865 * True if the fields are in sync with the currently set time of this Calendar.
|
jpayne@69
|
1866 * If false, then the next attempt to get the value of a field will
|
jpayne@69
|
1867 * force a recomputation of all fields from the current value of the time
|
jpayne@69
|
1868 * field.
|
jpayne@69
|
1869 * <P>
|
jpayne@69
|
1870 * This should really be named areFieldsInSync, but the old name is retained
|
jpayne@69
|
1871 * for backward compatibility.
|
jpayne@69
|
1872 * @stable ICU 2.0
|
jpayne@69
|
1873 */
|
jpayne@69
|
1874 UBool fAreFieldsSet;
|
jpayne@69
|
1875
|
jpayne@69
|
1876 /**
|
jpayne@69
|
1877 * True if all of the fields have been set. This is initially false, and set to
|
jpayne@69
|
1878 * true by computeFields().
|
jpayne@69
|
1879 * @stable ICU 2.0
|
jpayne@69
|
1880 */
|
jpayne@69
|
1881 UBool fAreAllFieldsSet;
|
jpayne@69
|
1882
|
jpayne@69
|
1883 /**
|
jpayne@69
|
1884 * True if all fields have been virtually set, but have not yet been
|
jpayne@69
|
1885 * computed. This occurs only in setTimeInMillis(). A calendar set
|
jpayne@69
|
1886 * to this state will compute all fields from the time if it becomes
|
jpayne@69
|
1887 * necessary, but otherwise will delay such computation.
|
jpayne@69
|
1888 * @stable ICU 3.0
|
jpayne@69
|
1889 */
|
jpayne@69
|
1890 UBool fAreFieldsVirtuallySet;
|
jpayne@69
|
1891
|
jpayne@69
|
1892 /**
|
jpayne@69
|
1893 * Get the current time without recomputing.
|
jpayne@69
|
1894 *
|
jpayne@69
|
1895 * @return the current time without recomputing.
|
jpayne@69
|
1896 * @stable ICU 2.0
|
jpayne@69
|
1897 */
|
jpayne@69
|
1898 UDate internalGetTime(void) const { return fTime; }
|
jpayne@69
|
1899
|
jpayne@69
|
1900 /**
|
jpayne@69
|
1901 * Set the current time without affecting flags or fields.
|
jpayne@69
|
1902 *
|
jpayne@69
|
1903 * @param time The time to be set
|
jpayne@69
|
1904 * @return the current time without recomputing.
|
jpayne@69
|
1905 * @stable ICU 2.0
|
jpayne@69
|
1906 */
|
jpayne@69
|
1907 void internalSetTime(UDate time) { fTime = time; }
|
jpayne@69
|
1908
|
jpayne@69
|
1909 /**
|
jpayne@69
|
1910 * The time fields containing values into which the millis is computed.
|
jpayne@69
|
1911 * @stable ICU 2.0
|
jpayne@69
|
1912 */
|
jpayne@69
|
1913 int32_t fFields[UCAL_FIELD_COUNT];
|
jpayne@69
|
1914
|
jpayne@69
|
1915 #ifndef U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
1916 /**
|
jpayne@69
|
1917 * The flags which tell if a specified time field for the calendar is set.
|
jpayne@69
|
1918 * @deprecated ICU 2.8 use (fStamp[n]!=kUnset)
|
jpayne@69
|
1919 */
|
jpayne@69
|
1920 UBool fIsSet[UCAL_FIELD_COUNT];
|
jpayne@69
|
1921 #endif // U_FORCE_HIDE_DEPRECATED_API
|
jpayne@69
|
1922
|
jpayne@69
|
1923 /** Special values of stamp[]
|
jpayne@69
|
1924 * @stable ICU 2.0
|
jpayne@69
|
1925 */
|
jpayne@69
|
1926 enum {
|
jpayne@69
|
1927 kUnset = 0,
|
jpayne@69
|
1928 kInternallySet,
|
jpayne@69
|
1929 kMinimumUserStamp
|
jpayne@69
|
1930 };
|
jpayne@69
|
1931
|
jpayne@69
|
1932 /**
|
jpayne@69
|
1933 * Pseudo-time-stamps which specify when each field was set. There
|
jpayne@69
|
1934 * are two special values, UNSET and INTERNALLY_SET. Values from
|
jpayne@69
|
1935 * MINIMUM_USER_SET to Integer.MAX_VALUE are legal user set values.
|
jpayne@69
|
1936 * @stable ICU 2.0
|
jpayne@69
|
1937 */
|
jpayne@69
|
1938 int32_t fStamp[UCAL_FIELD_COUNT];
|
jpayne@69
|
1939
|
jpayne@69
|
1940 /**
|
jpayne@69
|
1941 * Subclasses may override this method to compute several fields
|
jpayne@69
|
1942 * specific to each calendar system. These are:
|
jpayne@69
|
1943 *
|
jpayne@69
|
1944 * <ul><li>ERA
|
jpayne@69
|
1945 * <li>YEAR
|
jpayne@69
|
1946 * <li>MONTH
|
jpayne@69
|
1947 * <li>DAY_OF_MONTH
|
jpayne@69
|
1948 * <li>DAY_OF_YEAR
|
jpayne@69
|
1949 * <li>EXTENDED_YEAR</ul>
|
jpayne@69
|
1950 *
|
jpayne@69
|
1951 * Subclasses can refer to the DAY_OF_WEEK and DOW_LOCAL fields, which
|
jpayne@69
|
1952 * will be set when this method is called. Subclasses can also call
|
jpayne@69
|
1953 * the getGregorianXxx() methods to obtain Gregorian calendar
|
jpayne@69
|
1954 * equivalents for the given Julian day.
|
jpayne@69
|
1955 *
|
jpayne@69
|
1956 * <p>In addition, subclasses should compute any subclass-specific
|
jpayne@69
|
1957 * fields, that is, fields from BASE_FIELD_COUNT to
|
jpayne@69
|
1958 * getFieldCount() - 1.
|
jpayne@69
|
1959 *
|
jpayne@69
|
1960 * <p>The default implementation in <code>Calendar</code> implements
|
jpayne@69
|
1961 * a pure proleptic Gregorian calendar.
|
jpayne@69
|
1962 * @internal
|
jpayne@69
|
1963 */
|
jpayne@69
|
1964 virtual void handleComputeFields(int32_t julianDay, UErrorCode &status);
|
jpayne@69
|
1965
|
jpayne@69
|
1966 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
1967 /**
|
jpayne@69
|
1968 * Return the extended year on the Gregorian calendar as computed by
|
jpayne@69
|
1969 * <code>computeGregorianFields()</code>.
|
jpayne@69
|
1970 * @internal
|
jpayne@69
|
1971 */
|
jpayne@69
|
1972 int32_t getGregorianYear() const {
|
jpayne@69
|
1973 return fGregorianYear;
|
jpayne@69
|
1974 }
|
jpayne@69
|
1975
|
jpayne@69
|
1976 /**
|
jpayne@69
|
1977 * Return the month (0-based) on the Gregorian calendar as computed by
|
jpayne@69
|
1978 * <code>computeGregorianFields()</code>.
|
jpayne@69
|
1979 * @internal
|
jpayne@69
|
1980 */
|
jpayne@69
|
1981 int32_t getGregorianMonth() const {
|
jpayne@69
|
1982 return fGregorianMonth;
|
jpayne@69
|
1983 }
|
jpayne@69
|
1984
|
jpayne@69
|
1985 /**
|
jpayne@69
|
1986 * Return the day of year (1-based) on the Gregorian calendar as
|
jpayne@69
|
1987 * computed by <code>computeGregorianFields()</code>.
|
jpayne@69
|
1988 * @internal
|
jpayne@69
|
1989 */
|
jpayne@69
|
1990 int32_t getGregorianDayOfYear() const {
|
jpayne@69
|
1991 return fGregorianDayOfYear;
|
jpayne@69
|
1992 }
|
jpayne@69
|
1993
|
jpayne@69
|
1994 /**
|
jpayne@69
|
1995 * Return the day of month (1-based) on the Gregorian calendar as
|
jpayne@69
|
1996 * computed by <code>computeGregorianFields()</code>.
|
jpayne@69
|
1997 * @internal
|
jpayne@69
|
1998 */
|
jpayne@69
|
1999 int32_t getGregorianDayOfMonth() const {
|
jpayne@69
|
2000 return fGregorianDayOfMonth;
|
jpayne@69
|
2001 }
|
jpayne@69
|
2002 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
2003
|
jpayne@69
|
2004 /**
|
jpayne@69
|
2005 * Called by computeJulianDay. Returns the default month (0-based) for the year,
|
jpayne@69
|
2006 * taking year and era into account. Defaults to 0 for Gregorian, which doesn't care.
|
jpayne@69
|
2007 * @param eyear The extended year
|
jpayne@69
|
2008 * @internal
|
jpayne@69
|
2009 */
|
jpayne@69
|
2010 virtual int32_t getDefaultMonthInYear(int32_t eyear) ;
|
jpayne@69
|
2011
|
jpayne@69
|
2012
|
jpayne@69
|
2013 /**
|
jpayne@69
|
2014 * Called by computeJulianDay. Returns the default day (1-based) for the month,
|
jpayne@69
|
2015 * taking currently-set year and era into account. Defaults to 1 for Gregorian.
|
jpayne@69
|
2016 * @param eyear the extended year
|
jpayne@69
|
2017 * @param month the month in the year
|
jpayne@69
|
2018 * @internal
|
jpayne@69
|
2019 */
|
jpayne@69
|
2020 virtual int32_t getDefaultDayInMonth(int32_t eyear, int32_t month);
|
jpayne@69
|
2021
|
jpayne@69
|
2022 //-------------------------------------------------------------------------
|
jpayne@69
|
2023 // Protected utility methods for use by subclasses. These are very handy
|
jpayne@69
|
2024 // for implementing add, roll, and computeFields.
|
jpayne@69
|
2025 //-------------------------------------------------------------------------
|
jpayne@69
|
2026
|
jpayne@69
|
2027 /**
|
jpayne@69
|
2028 * Adjust the specified field so that it is within
|
jpayne@69
|
2029 * the allowable range for the date to which this calendar is set.
|
jpayne@69
|
2030 * For example, in a Gregorian calendar pinning the {@link #UCalendarDateFields DAY_OF_MONTH}
|
jpayne@69
|
2031 * field for a calendar set to April 31 would cause it to be set
|
jpayne@69
|
2032 * to April 30.
|
jpayne@69
|
2033 * <p>
|
jpayne@69
|
2034 * <b>Subclassing:</b>
|
jpayne@69
|
2035 * <br>
|
jpayne@69
|
2036 * This utility method is intended for use by subclasses that need to implement
|
jpayne@69
|
2037 * their own overrides of {@link #roll roll} and {@link #add add}.
|
jpayne@69
|
2038 * <p>
|
jpayne@69
|
2039 * <b>Note:</b>
|
jpayne@69
|
2040 * <code>pinField</code> is implemented in terms of
|
jpayne@69
|
2041 * {@link #getActualMinimum getActualMinimum}
|
jpayne@69
|
2042 * and {@link #getActualMaximum getActualMaximum}. If either of those methods uses
|
jpayne@69
|
2043 * a slow, iterative algorithm for a particular field, it would be
|
jpayne@69
|
2044 * unwise to attempt to call <code>pinField</code> for that field. If you
|
jpayne@69
|
2045 * really do need to do so, you should override this method to do
|
jpayne@69
|
2046 * something more efficient for that field.
|
jpayne@69
|
2047 * <p>
|
jpayne@69
|
2048 * @param field The calendar field whose value should be pinned.
|
jpayne@69
|
2049 * @param status Output param set to failure code on function return
|
jpayne@69
|
2050 * when this function fails.
|
jpayne@69
|
2051 *
|
jpayne@69
|
2052 * @see #getActualMinimum
|
jpayne@69
|
2053 * @see #getActualMaximum
|
jpayne@69
|
2054 * @stable ICU 2.0
|
jpayne@69
|
2055 */
|
jpayne@69
|
2056 virtual void pinField(UCalendarDateFields field, UErrorCode& status);
|
jpayne@69
|
2057
|
jpayne@69
|
2058 /**
|
jpayne@69
|
2059 * Return the week number of a day, within a period. This may be the week number in
|
jpayne@69
|
2060 * a year or the week number in a month. Usually this will be a value >= 1, but if
|
jpayne@69
|
2061 * some initial days of the period are excluded from week 1, because
|
jpayne@69
|
2062 * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} is > 1, then
|
jpayne@69
|
2063 * the week number will be zero for those
|
jpayne@69
|
2064 * initial days. This method requires the day number and day of week for some
|
jpayne@69
|
2065 * known date in the period in order to determine the day of week
|
jpayne@69
|
2066 * on the desired day.
|
jpayne@69
|
2067 * <p>
|
jpayne@69
|
2068 * <b>Subclassing:</b>
|
jpayne@69
|
2069 * <br>
|
jpayne@69
|
2070 * This method is intended for use by subclasses in implementing their
|
jpayne@69
|
2071 * {@link #computeTime computeTime} and/or {@link #computeFields computeFields} methods.
|
jpayne@69
|
2072 * It is often useful in {@link #getActualMinimum getActualMinimum} and
|
jpayne@69
|
2073 * {@link #getActualMaximum getActualMaximum} as well.
|
jpayne@69
|
2074 * <p>
|
jpayne@69
|
2075 * This variant is handy for computing the week number of some other
|
jpayne@69
|
2076 * day of a period (often the first or last day of the period) when its day
|
jpayne@69
|
2077 * of the week is not known but the day number and day of week for some other
|
jpayne@69
|
2078 * day in the period (e.g. the current date) <em>is</em> known.
|
jpayne@69
|
2079 * <p>
|
jpayne@69
|
2080 * @param desiredDay The {@link #UCalendarDateFields DAY_OF_YEAR} or
|
jpayne@69
|
2081 * {@link #UCalendarDateFields DAY_OF_MONTH} whose week number is desired.
|
jpayne@69
|
2082 * Should be 1 for the first day of the period.
|
jpayne@69
|
2083 *
|
jpayne@69
|
2084 * @param dayOfPeriod The {@link #UCalendarDateFields DAY_OF_YEAR}
|
jpayne@69
|
2085 * or {@link #UCalendarDateFields DAY_OF_MONTH} for a day in the period whose
|
jpayne@69
|
2086 * {@link #UCalendarDateFields DAY_OF_WEEK} is specified by the
|
jpayne@69
|
2087 * <code>knownDayOfWeek</code> parameter.
|
jpayne@69
|
2088 * Should be 1 for first day of period.
|
jpayne@69
|
2089 *
|
jpayne@69
|
2090 * @param dayOfWeek The {@link #UCalendarDateFields DAY_OF_WEEK} for the day
|
jpayne@69
|
2091 * corresponding to the <code>knownDayOfPeriod</code> parameter.
|
jpayne@69
|
2092 * 1-based with 1=Sunday.
|
jpayne@69
|
2093 *
|
jpayne@69
|
2094 * @return The week number (one-based), or zero if the day falls before
|
jpayne@69
|
2095 * the first week because
|
jpayne@69
|
2096 * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek}
|
jpayne@69
|
2097 * is more than one.
|
jpayne@69
|
2098 *
|
jpayne@69
|
2099 * @stable ICU 2.8
|
jpayne@69
|
2100 */
|
jpayne@69
|
2101 int32_t weekNumber(int32_t desiredDay, int32_t dayOfPeriod, int32_t dayOfWeek);
|
jpayne@69
|
2102
|
jpayne@69
|
2103
|
jpayne@69
|
2104 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
2105 /**
|
jpayne@69
|
2106 * Return the week number of a day, within a period. This may be the week number in
|
jpayne@69
|
2107 * a year, or the week number in a month. Usually this will be a value >= 1, but if
|
jpayne@69
|
2108 * some initial days of the period are excluded from week 1, because
|
jpayne@69
|
2109 * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek} is > 1,
|
jpayne@69
|
2110 * then the week number will be zero for those
|
jpayne@69
|
2111 * initial days. This method requires the day of week for the given date in order to
|
jpayne@69
|
2112 * determine the result.
|
jpayne@69
|
2113 * <p>
|
jpayne@69
|
2114 * <b>Subclassing:</b>
|
jpayne@69
|
2115 * <br>
|
jpayne@69
|
2116 * This method is intended for use by subclasses in implementing their
|
jpayne@69
|
2117 * {@link #computeTime computeTime} and/or {@link #computeFields computeFields} methods.
|
jpayne@69
|
2118 * It is often useful in {@link #getActualMinimum getActualMinimum} and
|
jpayne@69
|
2119 * {@link #getActualMaximum getActualMaximum} as well.
|
jpayne@69
|
2120 * <p>
|
jpayne@69
|
2121 * @param dayOfPeriod The {@link #UCalendarDateFields DAY_OF_YEAR} or
|
jpayne@69
|
2122 * {@link #UCalendarDateFields DAY_OF_MONTH} whose week number is desired.
|
jpayne@69
|
2123 * Should be 1 for the first day of the period.
|
jpayne@69
|
2124 *
|
jpayne@69
|
2125 * @param dayOfWeek The {@link #UCalendarDateFields DAY_OF_WEEK} for the day
|
jpayne@69
|
2126 * corresponding to the <code>dayOfPeriod</code> parameter.
|
jpayne@69
|
2127 * 1-based with 1=Sunday.
|
jpayne@69
|
2128 *
|
jpayne@69
|
2129 * @return The week number (one-based), or zero if the day falls before
|
jpayne@69
|
2130 * the first week because
|
jpayne@69
|
2131 * {@link #getMinimalDaysInFirstWeek getMinimalDaysInFirstWeek}
|
jpayne@69
|
2132 * is more than one.
|
jpayne@69
|
2133 * @internal
|
jpayne@69
|
2134 */
|
jpayne@69
|
2135 inline int32_t weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek);
|
jpayne@69
|
2136
|
jpayne@69
|
2137 /**
|
jpayne@69
|
2138 * returns the local DOW, valid range 0..6
|
jpayne@69
|
2139 * @internal
|
jpayne@69
|
2140 */
|
jpayne@69
|
2141 int32_t getLocalDOW();
|
jpayne@69
|
2142 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
2143
|
jpayne@69
|
2144 private:
|
jpayne@69
|
2145
|
jpayne@69
|
2146 /**
|
jpayne@69
|
2147 * The next available value for fStamp[]
|
jpayne@69
|
2148 */
|
jpayne@69
|
2149 int32_t fNextStamp;// = MINIMUM_USER_STAMP;
|
jpayne@69
|
2150
|
jpayne@69
|
2151 /**
|
jpayne@69
|
2152 * Recalculates the time stamp array (fStamp).
|
jpayne@69
|
2153 * Resets fNextStamp to lowest next stamp value.
|
jpayne@69
|
2154 */
|
jpayne@69
|
2155 void recalculateStamp();
|
jpayne@69
|
2156
|
jpayne@69
|
2157 /**
|
jpayne@69
|
2158 * The current time set for the calendar.
|
jpayne@69
|
2159 */
|
jpayne@69
|
2160 UDate fTime;
|
jpayne@69
|
2161
|
jpayne@69
|
2162 /**
|
jpayne@69
|
2163 * @see #setLenient
|
jpayne@69
|
2164 */
|
jpayne@69
|
2165 UBool fLenient;
|
jpayne@69
|
2166
|
jpayne@69
|
2167 /**
|
jpayne@69
|
2168 * Time zone affects the time calculation done by Calendar. Calendar subclasses use
|
jpayne@69
|
2169 * the time zone data to produce the local time. Always set; never NULL.
|
jpayne@69
|
2170 */
|
jpayne@69
|
2171 TimeZone* fZone;
|
jpayne@69
|
2172
|
jpayne@69
|
2173 /**
|
jpayne@69
|
2174 * Option for repeated wall time
|
jpayne@69
|
2175 * @see #setRepeatedWallTimeOption
|
jpayne@69
|
2176 */
|
jpayne@69
|
2177 UCalendarWallTimeOption fRepeatedWallTime;
|
jpayne@69
|
2178
|
jpayne@69
|
2179 /**
|
jpayne@69
|
2180 * Option for skipped wall time
|
jpayne@69
|
2181 * @see #setSkippedWallTimeOption
|
jpayne@69
|
2182 */
|
jpayne@69
|
2183 UCalendarWallTimeOption fSkippedWallTime;
|
jpayne@69
|
2184
|
jpayne@69
|
2185 /**
|
jpayne@69
|
2186 * Both firstDayOfWeek and minimalDaysInFirstWeek are locale-dependent. They are
|
jpayne@69
|
2187 * used to figure out the week count for a specific date for a given locale. These
|
jpayne@69
|
2188 * must be set when a Calendar is constructed. For example, in US locale,
|
jpayne@69
|
2189 * firstDayOfWeek is SUNDAY; minimalDaysInFirstWeek is 1. They are used to figure
|
jpayne@69
|
2190 * out the week count for a specific date for a given locale. These must be set when
|
jpayne@69
|
2191 * a Calendar is constructed.
|
jpayne@69
|
2192 */
|
jpayne@69
|
2193 UCalendarDaysOfWeek fFirstDayOfWeek;
|
jpayne@69
|
2194 uint8_t fMinimalDaysInFirstWeek;
|
jpayne@69
|
2195 UCalendarDaysOfWeek fWeekendOnset;
|
jpayne@69
|
2196 int32_t fWeekendOnsetMillis;
|
jpayne@69
|
2197 UCalendarDaysOfWeek fWeekendCease;
|
jpayne@69
|
2198 int32_t fWeekendCeaseMillis;
|
jpayne@69
|
2199
|
jpayne@69
|
2200 /**
|
jpayne@69
|
2201 * Sets firstDayOfWeek and minimalDaysInFirstWeek. Called at Calendar construction
|
jpayne@69
|
2202 * time.
|
jpayne@69
|
2203 *
|
jpayne@69
|
2204 * @param desiredLocale The given locale.
|
jpayne@69
|
2205 * @param type The calendar type identifier, e.g: gregorian, buddhist, etc.
|
jpayne@69
|
2206 * @param success Indicates the status of setting the week count data from
|
jpayne@69
|
2207 * the resource for the given locale. Returns U_ZERO_ERROR if
|
jpayne@69
|
2208 * constructed successfully.
|
jpayne@69
|
2209 */
|
jpayne@69
|
2210 void setWeekData(const Locale& desiredLocale, const char *type, UErrorCode& success);
|
jpayne@69
|
2211
|
jpayne@69
|
2212 /**
|
jpayne@69
|
2213 * Recompute the time and update the status fields isTimeSet
|
jpayne@69
|
2214 * and areFieldsSet. Callers should check isTimeSet and only
|
jpayne@69
|
2215 * call this method if isTimeSet is false.
|
jpayne@69
|
2216 *
|
jpayne@69
|
2217 * @param status Output param set to success/failure code on exit. If any value
|
jpayne@69
|
2218 * previously set in the time field is invalid or restricted by
|
jpayne@69
|
2219 * leniency, this will be set to an error status.
|
jpayne@69
|
2220 */
|
jpayne@69
|
2221 void updateTime(UErrorCode& status);
|
jpayne@69
|
2222
|
jpayne@69
|
2223 /**
|
jpayne@69
|
2224 * The Gregorian year, as computed by computeGregorianFields() and
|
jpayne@69
|
2225 * returned by getGregorianYear().
|
jpayne@69
|
2226 * @see #computeGregorianFields
|
jpayne@69
|
2227 */
|
jpayne@69
|
2228 int32_t fGregorianYear;
|
jpayne@69
|
2229
|
jpayne@69
|
2230 /**
|
jpayne@69
|
2231 * The Gregorian month, as computed by computeGregorianFields() and
|
jpayne@69
|
2232 * returned by getGregorianMonth().
|
jpayne@69
|
2233 * @see #computeGregorianFields
|
jpayne@69
|
2234 */
|
jpayne@69
|
2235 int32_t fGregorianMonth;
|
jpayne@69
|
2236
|
jpayne@69
|
2237 /**
|
jpayne@69
|
2238 * The Gregorian day of the year, as computed by
|
jpayne@69
|
2239 * computeGregorianFields() and returned by getGregorianDayOfYear().
|
jpayne@69
|
2240 * @see #computeGregorianFields
|
jpayne@69
|
2241 */
|
jpayne@69
|
2242 int32_t fGregorianDayOfYear;
|
jpayne@69
|
2243
|
jpayne@69
|
2244 /**
|
jpayne@69
|
2245 * The Gregorian day of the month, as computed by
|
jpayne@69
|
2246 * computeGregorianFields() and returned by getGregorianDayOfMonth().
|
jpayne@69
|
2247 * @see #computeGregorianFields
|
jpayne@69
|
2248 */
|
jpayne@69
|
2249 int32_t fGregorianDayOfMonth;
|
jpayne@69
|
2250
|
jpayne@69
|
2251 /* calculations */
|
jpayne@69
|
2252
|
jpayne@69
|
2253 /**
|
jpayne@69
|
2254 * Compute the Gregorian calendar year, month, and day of month from
|
jpayne@69
|
2255 * the given Julian day. These values are not stored in fields, but in
|
jpayne@69
|
2256 * member variables gregorianXxx. Also compute the DAY_OF_WEEK and
|
jpayne@69
|
2257 * DOW_LOCAL fields.
|
jpayne@69
|
2258 */
|
jpayne@69
|
2259 void computeGregorianAndDOWFields(int32_t julianDay, UErrorCode &ec);
|
jpayne@69
|
2260
|
jpayne@69
|
2261 protected:
|
jpayne@69
|
2262
|
jpayne@69
|
2263 /**
|
jpayne@69
|
2264 * Compute the Gregorian calendar year, month, and day of month from the
|
jpayne@69
|
2265 * Julian day. These values are not stored in fields, but in member
|
jpayne@69
|
2266 * variables gregorianXxx. They are used for time zone computations and by
|
jpayne@69
|
2267 * subclasses that are Gregorian derivatives. Subclasses may call this
|
jpayne@69
|
2268 * method to perform a Gregorian calendar millis->fields computation.
|
jpayne@69
|
2269 */
|
jpayne@69
|
2270 void computeGregorianFields(int32_t julianDay, UErrorCode &ec);
|
jpayne@69
|
2271
|
jpayne@69
|
2272 private:
|
jpayne@69
|
2273
|
jpayne@69
|
2274 /**
|
jpayne@69
|
2275 * Compute the fields WEEK_OF_YEAR, YEAR_WOY, WEEK_OF_MONTH,
|
jpayne@69
|
2276 * DAY_OF_WEEK_IN_MONTH, and DOW_LOCAL from EXTENDED_YEAR, YEAR,
|
jpayne@69
|
2277 * DAY_OF_WEEK, and DAY_OF_YEAR. The latter fields are computed by the
|
jpayne@69
|
2278 * subclass based on the calendar system.
|
jpayne@69
|
2279 *
|
jpayne@69
|
2280 * <p>The YEAR_WOY field is computed simplistically. It is equal to YEAR
|
jpayne@69
|
2281 * most of the time, but at the year boundary it may be adjusted to YEAR-1
|
jpayne@69
|
2282 * or YEAR+1 to reflect the overlap of a week into an adjacent year. In
|
jpayne@69
|
2283 * this case, a simple increment or decrement is performed on YEAR, even
|
jpayne@69
|
2284 * though this may yield an invalid YEAR value. For instance, if the YEAR
|
jpayne@69
|
2285 * is part of a calendar system with an N-year cycle field CYCLE, then
|
jpayne@69
|
2286 * incrementing the YEAR may involve incrementing CYCLE and setting YEAR
|
jpayne@69
|
2287 * back to 0 or 1. This is not handled by this code, and in fact cannot be
|
jpayne@69
|
2288 * simply handled without having subclasses define an entire parallel set of
|
jpayne@69
|
2289 * fields for fields larger than or equal to a year. This additional
|
jpayne@69
|
2290 * complexity is not warranted, since the intention of the YEAR_WOY field is
|
jpayne@69
|
2291 * to support ISO 8601 notation, so it will typically be used with a
|
jpayne@69
|
2292 * proleptic Gregorian calendar, which has no field larger than a year.
|
jpayne@69
|
2293 */
|
jpayne@69
|
2294 void computeWeekFields(UErrorCode &ec);
|
jpayne@69
|
2295
|
jpayne@69
|
2296
|
jpayne@69
|
2297 /**
|
jpayne@69
|
2298 * Ensure that each field is within its valid range by calling {@link
|
jpayne@69
|
2299 * #validateField(int, int&)} on each field that has been set. This method
|
jpayne@69
|
2300 * should only be called if this calendar is not lenient.
|
jpayne@69
|
2301 * @see #isLenient
|
jpayne@69
|
2302 * @see #validateField(int, int&)
|
jpayne@69
|
2303 */
|
jpayne@69
|
2304 void validateFields(UErrorCode &status);
|
jpayne@69
|
2305
|
jpayne@69
|
2306 /**
|
jpayne@69
|
2307 * Validate a single field of this calendar given its minimum and
|
jpayne@69
|
2308 * maximum allowed value. If the field is out of range,
|
jpayne@69
|
2309 * <code>U_ILLEGAL_ARGUMENT_ERROR</code> will be set. Subclasses may
|
jpayne@69
|
2310 * use this method in their implementation of {@link
|
jpayne@69
|
2311 * #validateField(int, int&)}.
|
jpayne@69
|
2312 */
|
jpayne@69
|
2313 void validateField(UCalendarDateFields field, int32_t min, int32_t max, UErrorCode& status);
|
jpayne@69
|
2314
|
jpayne@69
|
2315 protected:
|
jpayne@69
|
2316 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
2317 /**
|
jpayne@69
|
2318 * Convert a quasi Julian date to the day of the week. The Julian date used here is
|
jpayne@69
|
2319 * not a true Julian date, since it is measured from midnight, not noon. Return
|
jpayne@69
|
2320 * value is one-based.
|
jpayne@69
|
2321 *
|
jpayne@69
|
2322 * @param julian The given Julian date number.
|
jpayne@69
|
2323 * @return Day number from 1..7 (SUN..SAT).
|
jpayne@69
|
2324 * @internal
|
jpayne@69
|
2325 */
|
jpayne@69
|
2326 static uint8_t julianDayToDayOfWeek(double julian);
|
jpayne@69
|
2327 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
2328
|
jpayne@69
|
2329 private:
|
jpayne@69
|
2330 char validLocale[ULOC_FULLNAME_CAPACITY];
|
jpayne@69
|
2331 char actualLocale[ULOC_FULLNAME_CAPACITY];
|
jpayne@69
|
2332
|
jpayne@69
|
2333 public:
|
jpayne@69
|
2334 #if !UCONFIG_NO_SERVICE
|
jpayne@69
|
2335 /**
|
jpayne@69
|
2336 * INTERNAL FOR 2.6 -- Registration.
|
jpayne@69
|
2337 */
|
jpayne@69
|
2338
|
jpayne@69
|
2339 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
2340 /**
|
jpayne@69
|
2341 * Return a StringEnumeration over the locales available at the time of the call,
|
jpayne@69
|
2342 * including registered locales.
|
jpayne@69
|
2343 * @return a StringEnumeration over the locales available at the time of the call
|
jpayne@69
|
2344 * @internal
|
jpayne@69
|
2345 */
|
jpayne@69
|
2346 static StringEnumeration* getAvailableLocales(void);
|
jpayne@69
|
2347
|
jpayne@69
|
2348 /**
|
jpayne@69
|
2349 * Register a new Calendar factory. The factory will be adopted.
|
jpayne@69
|
2350 * INTERNAL in 2.6
|
jpayne@69
|
2351 *
|
jpayne@69
|
2352 * Because ICU may choose to cache Calendars internally, this must
|
jpayne@69
|
2353 * be called at application startup, prior to any calls to
|
jpayne@69
|
2354 * Calendar::createInstance to avoid undefined behavior.
|
jpayne@69
|
2355 *
|
jpayne@69
|
2356 * @param toAdopt the factory instance to be adopted
|
jpayne@69
|
2357 * @param status the in/out status code, no special meanings are assigned
|
jpayne@69
|
2358 * @return a registry key that can be used to unregister this factory
|
jpayne@69
|
2359 * @internal
|
jpayne@69
|
2360 */
|
jpayne@69
|
2361 static URegistryKey registerFactory(ICUServiceFactory* toAdopt, UErrorCode& status);
|
jpayne@69
|
2362
|
jpayne@69
|
2363 /**
|
jpayne@69
|
2364 * Unregister a previously-registered CalendarFactory using the key returned from the
|
jpayne@69
|
2365 * register call. Key becomes invalid after a successful call and should not be used again.
|
jpayne@69
|
2366 * The CalendarFactory corresponding to the key will be deleted.
|
jpayne@69
|
2367 * INTERNAL in 2.6
|
jpayne@69
|
2368 *
|
jpayne@69
|
2369 * Because ICU may choose to cache Calendars internally, this should
|
jpayne@69
|
2370 * be called during application shutdown, after all calls to
|
jpayne@69
|
2371 * Calendar::createInstance to avoid undefined behavior.
|
jpayne@69
|
2372 *
|
jpayne@69
|
2373 * @param key the registry key returned by a previous call to registerFactory
|
jpayne@69
|
2374 * @param status the in/out status code, no special meanings are assigned
|
jpayne@69
|
2375 * @return TRUE if the factory for the key was successfully unregistered
|
jpayne@69
|
2376 * @internal
|
jpayne@69
|
2377 */
|
jpayne@69
|
2378 static UBool unregister(URegistryKey key, UErrorCode& status);
|
jpayne@69
|
2379 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
2380
|
jpayne@69
|
2381 /**
|
jpayne@69
|
2382 * Multiple Calendar Implementation
|
jpayne@69
|
2383 * @internal
|
jpayne@69
|
2384 */
|
jpayne@69
|
2385 friend class CalendarFactory;
|
jpayne@69
|
2386
|
jpayne@69
|
2387 /**
|
jpayne@69
|
2388 * Multiple Calendar Implementation
|
jpayne@69
|
2389 * @internal
|
jpayne@69
|
2390 */
|
jpayne@69
|
2391 friend class CalendarService;
|
jpayne@69
|
2392
|
jpayne@69
|
2393 /**
|
jpayne@69
|
2394 * Multiple Calendar Implementation
|
jpayne@69
|
2395 * @internal
|
jpayne@69
|
2396 */
|
jpayne@69
|
2397 friend class DefaultCalendarFactory;
|
jpayne@69
|
2398 #endif /* !UCONFIG_NO_SERVICE */
|
jpayne@69
|
2399
|
jpayne@69
|
2400 /**
|
jpayne@69
|
2401 * @return TRUE if this calendar has a default century (i.e. 03 -> 2003)
|
jpayne@69
|
2402 * @internal
|
jpayne@69
|
2403 */
|
jpayne@69
|
2404 virtual UBool haveDefaultCentury() const = 0;
|
jpayne@69
|
2405
|
jpayne@69
|
2406 /**
|
jpayne@69
|
2407 * @return the start of the default century, as a UDate
|
jpayne@69
|
2408 * @internal
|
jpayne@69
|
2409 */
|
jpayne@69
|
2410 virtual UDate defaultCenturyStart() const = 0;
|
jpayne@69
|
2411 /**
|
jpayne@69
|
2412 * @return the beginning year of the default century, as a year
|
jpayne@69
|
2413 * @internal
|
jpayne@69
|
2414 */
|
jpayne@69
|
2415 virtual int32_t defaultCenturyStartYear() const = 0;
|
jpayne@69
|
2416
|
jpayne@69
|
2417 /** Get the locale for this calendar object. You can choose between valid and actual locale.
|
jpayne@69
|
2418 * @param type type of the locale we're looking for (valid or actual)
|
jpayne@69
|
2419 * @param status error code for the operation
|
jpayne@69
|
2420 * @return the locale
|
jpayne@69
|
2421 * @stable ICU 2.8
|
jpayne@69
|
2422 */
|
jpayne@69
|
2423 Locale getLocale(ULocDataLocaleType type, UErrorCode &status) const;
|
jpayne@69
|
2424
|
jpayne@69
|
2425 /**
|
jpayne@69
|
2426 * @return The related Gregorian year; will be obtained by modifying the value
|
jpayne@69
|
2427 * obtained by get from UCAL_EXTENDED_YEAR field
|
jpayne@69
|
2428 * @internal
|
jpayne@69
|
2429 */
|
jpayne@69
|
2430 virtual int32_t getRelatedYear(UErrorCode &status) const;
|
jpayne@69
|
2431
|
jpayne@69
|
2432 /**
|
jpayne@69
|
2433 * @param year The related Gregorian year to set; will be modified as necessary then
|
jpayne@69
|
2434 * set in UCAL_EXTENDED_YEAR field
|
jpayne@69
|
2435 * @internal
|
jpayne@69
|
2436 */
|
jpayne@69
|
2437 virtual void setRelatedYear(int32_t year);
|
jpayne@69
|
2438
|
jpayne@69
|
2439 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
2440 /** Get the locale for this calendar object. You can choose between valid and actual locale.
|
jpayne@69
|
2441 * @param type type of the locale we're looking for (valid or actual)
|
jpayne@69
|
2442 * @param status error code for the operation
|
jpayne@69
|
2443 * @return the locale
|
jpayne@69
|
2444 * @internal
|
jpayne@69
|
2445 */
|
jpayne@69
|
2446 const char* getLocaleID(ULocDataLocaleType type, UErrorCode &status) const;
|
jpayne@69
|
2447 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
2448
|
jpayne@69
|
2449 private:
|
jpayne@69
|
2450 /**
|
jpayne@69
|
2451 * Cast TimeZone used by this object to BasicTimeZone, or NULL if the TimeZone
|
jpayne@69
|
2452 * is not an instance of BasicTimeZone.
|
jpayne@69
|
2453 */
|
jpayne@69
|
2454 BasicTimeZone* getBasicTimeZone() const;
|
jpayne@69
|
2455
|
jpayne@69
|
2456 /**
|
jpayne@69
|
2457 * Find the previous zone transition near the given time.
|
jpayne@69
|
2458 * @param base The base time, inclusive
|
jpayne@69
|
2459 * @param transitionTime Receives the result time
|
jpayne@69
|
2460 * @param status The error status
|
jpayne@69
|
2461 * @return TRUE if a transition is found.
|
jpayne@69
|
2462 */
|
jpayne@69
|
2463 UBool getImmediatePreviousZoneTransition(UDate base, UDate *transitionTime, UErrorCode& status) const;
|
jpayne@69
|
2464
|
jpayne@69
|
2465 public:
|
jpayne@69
|
2466 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
2467 /**
|
jpayne@69
|
2468 * Creates a new Calendar from a Locale for the cache.
|
jpayne@69
|
2469 * This method does not set the time or timezone in returned calendar.
|
jpayne@69
|
2470 * @param locale the locale.
|
jpayne@69
|
2471 * @param status any error returned here.
|
jpayne@69
|
2472 * @return the new Calendar object with no time or timezone set.
|
jpayne@69
|
2473 * @internal For ICU use only.
|
jpayne@69
|
2474 */
|
jpayne@69
|
2475 static Calendar * U_EXPORT2 makeInstance(
|
jpayne@69
|
2476 const Locale &locale, UErrorCode &status);
|
jpayne@69
|
2477
|
jpayne@69
|
2478 /**
|
jpayne@69
|
2479 * Get the calendar type for given locale.
|
jpayne@69
|
2480 * @param locale the locale
|
jpayne@69
|
2481 * @param typeBuffer calendar type returned here
|
jpayne@69
|
2482 * @param typeBufferSize The size of typeBuffer in bytes. If the type
|
jpayne@69
|
2483 * can't fit in the buffer, this method sets status to
|
jpayne@69
|
2484 * U_BUFFER_OVERFLOW_ERROR
|
jpayne@69
|
2485 * @param status error, if any, returned here.
|
jpayne@69
|
2486 * @internal For ICU use only.
|
jpayne@69
|
2487 */
|
jpayne@69
|
2488 static void U_EXPORT2 getCalendarTypeFromLocale(
|
jpayne@69
|
2489 const Locale &locale,
|
jpayne@69
|
2490 char *typeBuffer,
|
jpayne@69
|
2491 int32_t typeBufferSize,
|
jpayne@69
|
2492 UErrorCode &status);
|
jpayne@69
|
2493 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
2494 };
|
jpayne@69
|
2495
|
jpayne@69
|
2496 // -------------------------------------
|
jpayne@69
|
2497
|
jpayne@69
|
2498 inline Calendar*
|
jpayne@69
|
2499 Calendar::createInstance(TimeZone* zone, UErrorCode& errorCode)
|
jpayne@69
|
2500 {
|
jpayne@69
|
2501 // since the Locale isn't specified, use the default locale
|
jpayne@69
|
2502 return createInstance(zone, Locale::getDefault(), errorCode);
|
jpayne@69
|
2503 }
|
jpayne@69
|
2504
|
jpayne@69
|
2505 // -------------------------------------
|
jpayne@69
|
2506
|
jpayne@69
|
2507 inline void
|
jpayne@69
|
2508 Calendar::roll(UCalendarDateFields field, UBool up, UErrorCode& status)
|
jpayne@69
|
2509 {
|
jpayne@69
|
2510 roll(field, (int32_t)(up ? +1 : -1), status);
|
jpayne@69
|
2511 }
|
jpayne@69
|
2512
|
jpayne@69
|
2513 #ifndef U_HIDE_DEPRECATED_API
|
jpayne@69
|
2514 inline void
|
jpayne@69
|
2515 Calendar::roll(EDateFields field, UBool up, UErrorCode& status)
|
jpayne@69
|
2516 {
|
jpayne@69
|
2517 roll((UCalendarDateFields) field, up, status);
|
jpayne@69
|
2518 }
|
jpayne@69
|
2519 #endif /* U_HIDE_DEPRECATED_API */
|
jpayne@69
|
2520
|
jpayne@69
|
2521
|
jpayne@69
|
2522 // -------------------------------------
|
jpayne@69
|
2523
|
jpayne@69
|
2524 /**
|
jpayne@69
|
2525 * Fast method for subclasses. The caller must maintain fUserSetDSTOffset and
|
jpayne@69
|
2526 * fUserSetZoneOffset, as well as the isSet[] array.
|
jpayne@69
|
2527 */
|
jpayne@69
|
2528
|
jpayne@69
|
2529 inline void
|
jpayne@69
|
2530 Calendar::internalSet(UCalendarDateFields field, int32_t value)
|
jpayne@69
|
2531 {
|
jpayne@69
|
2532 fFields[field] = value;
|
jpayne@69
|
2533 fStamp[field] = kInternallySet;
|
jpayne@69
|
2534 fIsSet[field] = TRUE; // Remove later
|
jpayne@69
|
2535 }
|
jpayne@69
|
2536
|
jpayne@69
|
2537
|
jpayne@69
|
2538 #ifndef U_HIDE_INTERNAL_API
|
jpayne@69
|
2539 inline int32_t Calendar::weekNumber(int32_t dayOfPeriod, int32_t dayOfWeek)
|
jpayne@69
|
2540 {
|
jpayne@69
|
2541 return weekNumber(dayOfPeriod, dayOfPeriod, dayOfWeek);
|
jpayne@69
|
2542 }
|
jpayne@69
|
2543 #endif /* U_HIDE_INTERNAL_API */
|
jpayne@69
|
2544
|
jpayne@69
|
2545 U_NAMESPACE_END
|
jpayne@69
|
2546
|
jpayne@69
|
2547 #endif /* #if !UCONFIG_NO_FORMATTING */
|
jpayne@69
|
2548
|
jpayne@69
|
2549 #endif /* U_SHOW_CPLUSPLUS_API */
|
jpayne@69
|
2550
|
jpayne@69
|
2551 #endif // _CALENDAR
|