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