2 ********************************************************************************
3 * Copyright (C) 1997-2003, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************************
9 * Modification History:
11 * Date Name Description
12 * 04/22/97 aliu Expanded and corrected comments and other header
14 * 05/01/97 aliu Made equals(), before(), after() arguments const.
15 * 05/20/97 aliu Replaced fAreFieldsSet with fAreFieldsInSync and
17 * 07/27/98 stephen Sync up with JDK 1.2
18 * 11/15/99 weiv added YEAR_WOY and DOW_LOCAL
20 * 8/19/2002 srl Removed Javaisms
21 ********************************************************************************
27 #include "unicode/utypes.h"
29 #if !UCONFIG_NO_FORMATTING
31 #include "unicode/uobject.h"
32 #include "unicode/locid.h"
33 #include "unicode/timezone.h"
34 #include "unicode/ucal.h"
38 class ICUServiceFactory
;
43 typedef const void* URegistryKey
;
46 * <code>Calendar</code> is an abstract base class for converting between
47 * a <code>UDate</code> object and a set of integer fields such as
48 * <code>YEAR</code>, <code>MONTH</code>, <code>DAY</code>, <code>HOUR</code>,
49 * and so on. (A <code>UDate</code> object represents a specific instant in
50 * time with millisecond precision. See UDate
51 * for information about the <code>UDate</code> class.)
54 * Subclasses of <code>Calendar</code> interpret a <code>UDate</code>
55 * according to the rules of a specific calendar system.
56 * The most commonly used subclass of <code>Calendar</code> is
57 * <code>GregorianCalendar</code>. Other subclasses could represent
58 * the various types of lunar calendars in use in many parts of the world.
61 * <b>NOTE</b>: (ICU 2.6) The subclass interface should be considered unstable
65 * Like other locale-sensitive classes, <code>Calendar</code> provides a
66 * static method, <code>createInstance</code>, for getting a generally useful
67 * object of this type. <code>Calendar</code>'s <code>createInstance</code> method
68 * returns the appropriate <code>Calendar</code> subclass whose
69 * time fields have been initialized with the current date and time:
72 * Calendar *rightNow = Calendar::createInstance(errCode);
77 * A <code>Calendar</code> object can produce all the time field values
78 * needed to implement the date-time formatting for a particular language
79 * and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
82 * When computing a <code>UDate</code> from time fields, two special circumstances
83 * may arise: there may be insufficient information to compute the
84 * <code>UDate</code> (such as only year and month but no day in the month),
85 * or there may be inconsistent information (such as "Tuesday, July 15, 1996"
86 * -- July 15, 1996 is actually a Monday).
89 * <strong>Insufficient information.</strong> The calendar will use default
90 * information to specify the missing fields. This may vary by calendar; for
91 * the Gregorian calendar, the default for a field is the same as that of the
92 * start of the epoch: i.e., YEAR = 1970, MONTH = JANUARY, DATE = 1, etc.
95 * <strong>Inconsistent information.</strong> If fields conflict, the calendar
96 * will give preference to fields set more recently. For example, when
97 * determining the day, the calendar will look for one of the following
98 * combinations of fields. The most recent combination, as determined by the
99 * most recently set single field, will be used.
103 * MONTH + DAY_OF_MONTH
104 * MONTH + WEEK_OF_MONTH + DAY_OF_WEEK
105 * MONTH + DAY_OF_WEEK_IN_MONTH + DAY_OF_WEEK
107 * DAY_OF_WEEK + WEEK_OF_YEAR
111 * For the time of day:
121 * <strong>Note:</strong> for some non-Gregorian calendars, different
122 * fields may be necessary for complete disambiguation. For example, a full
123 * specification of the historial Arabic astronomical calendar requires year,
124 * month, day-of-month <em>and</em> day-of-week in some cases.
127 * <strong>Note:</strong> There are certain possible ambiguities in
128 * interpretation of certain singular times, which are resolved in the
131 * <li> 24:00:00 "belongs" to the following day. That is,
132 * 23:59 on Dec 31, 1969 < 24:00 on Jan 1, 1970 < 24:01:00 on Jan 1, 1970
134 * <li> Although historically not precise, midnight also belongs to "am",
135 * and noon belongs to "pm", so on the same day,
136 * 12:00 am (midnight) < 12:01 am, and 12:00 pm (noon) < 12:01 pm
140 * The date or time format strings are not part of the definition of a
141 * calendar, as those must be modifiable or overridable by the user at
142 * runtime. Use {@link DateFormat}
146 * <code>Calendar</code> provides an API for field "rolling", where fields
147 * can be incremented or decremented, but wrap around. For example, rolling the
148 * month up in the date <code>December 12, <b>1996</b></code> results in
149 * <code>January 12, <b>1996</b></code>.
152 * <code>Calendar</code> also provides a date arithmetic function for
153 * adding the specified (signed) amount of time to a particular time field.
154 * For example, subtracting 5 days from the date <code>September 12, 1996</code>
155 * results in <code>September 7, 1996</code>.
159 class U_I18N_API Calendar
: public UObject
{
163 * Field IDs for date and time. Used to specify date/time fields. ERA is calendar
164 * specific. Example ranges given are for illustration only; see specific Calendar
165 * subclasses for actual ranges.
166 * @deprecated ICU 2.6. Use C enum UCalendarDateFields defined in ucal.h
169 ERA
, // Example: 0..1
170 YEAR
, // Example: 1..big number
171 MONTH
, // Example: 0..11
172 WEEK_OF_YEAR
, // Example: 1..53
173 WEEK_OF_MONTH
, // Example: 1..4
174 DATE
, // Example: 1..31
175 DAY_OF_YEAR
, // Example: 1..365
176 DAY_OF_WEEK
, // Example: 1..7
177 DAY_OF_WEEK_IN_MONTH
, // Example: 1..4, may be specified as -1
178 AM_PM
, // Example: 0..1
179 HOUR
, // Example: 0..11
180 HOUR_OF_DAY
, // Example: 0..23
181 MINUTE
, // Example: 0..59
182 SECOND
, // Example: 0..59
183 MILLISECOND
, // Example: 0..999
184 ZONE_OFFSET
, // Example: -12*U_MILLIS_PER_HOUR..12*U_MILLIS_PER_HOUR
185 DST_OFFSET
, // Example: 0 or U_MILLIS_PER_HOUR
186 // here will go names for 'Y' and 'e'
187 YEAR_WOY
, // 'Y' Example: 1..big number
188 DOW_LOCAL
, // 'e' Example: 1..7
191 DAY_OF_MONTH
= DATE
// Synonyms
195 * Useful constant for days of week. Note: Calendar day-of-week is 1-based. Clients
196 * who create locale resources for the field of first-day-of-week should be aware of
197 * this. For instance, in US locale, first-day-of-week is set to 1, i.e., SUNDAY.
198 * @deprecated ICU 2.6. Use C enum UCalendarDaysOfWeek defined in ucal.h
211 * Useful constants for month. Note: Calendar month is 0-based.
212 * @deprecated ICU 2.6. Use C enum UCalendarMonths defined in ucal.h
231 * Useful constants for hour in 12-hour clock. Used in GregorianCalendar.
232 * @deprecated ICU 2.6. Use C enum UCalendarAMPMs defined in ucal.h
246 * Create and return a polymorphic copy of this calendar.
248 * @return a polymorphic copy of this calendar.
251 virtual Calendar
* clone(void) const = 0;
254 * Creates a Calendar using the default timezone and locale. Clients are responsible
255 * for deleting the object returned.
257 * @param success Indicates the success/failure of Calendar creation. Filled in
258 * with U_ZERO_ERROR if created successfully, set to a failure result
259 * otherwise. U_MISSING_RESOURCE_ERROR will be returned if the resource data
260 * requests a calendar type which has not been installed.
261 * @return A Calendar if created successfully. NULL otherwise.
264 static Calendar
* createInstance(UErrorCode
& success
);
267 * Creates a Calendar using the given timezone and the default locale.
268 * The Calendar takes ownership of zoneToAdopt; the
269 * client must not delete it.
271 * @param zoneToAdopt The given timezone to be adopted.
272 * @param success Indicates the success/failure of Calendar creation. Filled in
273 * with U_ZERO_ERROR if created successfully, set to a failure result
275 * @return A Calendar if created successfully. NULL otherwise.
278 static Calendar
* createInstance(TimeZone
* zoneToAdopt
, UErrorCode
& success
);
281 * Creates a Calendar using the given timezone and the default locale. The TimeZone
282 * is _not_ adopted; the client is still responsible for deleting it.
284 * @param zone The timezone.
285 * @param success Indicates the success/failure of Calendar creation. Filled in
286 * with U_ZERO_ERROR if created successfully, set to a failure result
288 * @return A Calendar if created successfully. NULL otherwise.
291 static Calendar
* createInstance(const TimeZone
& zone
, UErrorCode
& success
);
294 * Creates a Calendar using the default timezone and the given locale.
296 * @param aLocale The given locale.
297 * @param success Indicates the success/failure of Calendar creation. Filled in
298 * with U_ZERO_ERROR if created successfully, set to a failure result
300 * @return A Calendar if created successfully. NULL otherwise.
303 static Calendar
* createInstance(const Locale
& aLocale
, UErrorCode
& success
);
306 * Creates a Calendar using the given timezone and given locale.
307 * The Calendar takes ownership of zoneToAdopt; the
308 * client must not delete it.
310 * @param zoneToAdopt The given timezone to be adopted.
311 * @param aLocale The given locale.
312 * @param success Indicates the success/failure of Calendar creation. Filled in
313 * with U_ZERO_ERROR if created successfully, set to a failure result
315 * @return A Calendar if created successfully. NULL otherwise.
318 static Calendar
* createInstance(TimeZone
* zoneToAdopt
, const Locale
& aLocale
, UErrorCode
& success
);
321 * Gets a Calendar using the given timezone and given locale. The TimeZone
322 * is _not_ adopted; the client is still responsible for deleting it.
324 * @param zoneToAdopt The given timezone to be adopted.
325 * @param aLocale The given locale.
326 * @param success Indicates the success/failure of Calendar creation. Filled in
327 * with U_ZERO_ERROR if created successfully, set to a failure result
329 * @return A Calendar if created successfully. NULL otherwise.
332 static Calendar
* createInstance(const TimeZone
& zoneToAdopt
, const Locale
& aLocale
, UErrorCode
& success
);
335 * Returns a list of the locales for which Calendars are installed.
337 * @param count Number of locales returned.
338 * @return An array of Locale objects representing the set of locales for which
339 * Calendars are installed. The system retains ownership of this list;
340 * the caller must NOT delete it. Does not include user-registered Calendars.
343 static const Locale
* getAvailableLocales(int32_t& count
);
346 * Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70
347 * (derived from the system time).
349 * @return The current UTC time in milliseconds.
352 static UDate
getNow(void);
355 * Gets this Calendar's time as milliseconds. May involve recalculation of time due
356 * to previous calls to set time field values. The time specified is non-local UTC
357 * (GMT) time. Although this method is const, this object may actually be changed
358 * (semantically const).
360 * @param status Output param set to success/failure code on exit. If any value
361 * previously set in the time field is invalid or restricted by
362 * leniency, this will be set to an error status.
363 * @return The current time in UTC (GMT) time, or zero if the operation
367 inline UDate
getTime(UErrorCode
& status
) const { return getTimeInMillis(status
); }
370 * Sets this Calendar's current time with the given UDate. The time specified should
371 * be in non-local UTC (GMT) time.
373 * @param date The given UDate in UTC (GMT) time.
374 * @param status Output param set to success/failure code on exit. If any value
375 * set in the time field is invalid or restricted by
376 * leniency, this will be set to an error status.
379 inline void setTime(UDate date
, UErrorCode
& status
) { setTimeInMillis(date
, status
); }
382 * Compares the equality of two Calendar objects. Objects of different subclasses
383 * are considered unequal. This comparison is very exacting; two Calendar objects
384 * must be in exactly the same state to be considered equal. To compare based on the
385 * represented time, use equals() instead.
387 * @param that The Calendar object to be compared with.
388 * @return True if the given Calendar is the same as this Calendar; false
392 virtual UBool
operator==(const Calendar
& that
) const;
395 * Compares the inequality of two Calendar objects.
397 * @param that The Calendar object to be compared with.
398 * @return True if the given Calendar is not the same as this Calendar; false
402 UBool
operator!=(const Calendar
& that
) const {return !operator==(that
);}
405 * Returns TRUE if the given Calendar object is equivalent to this
406 * one. An equivalent Calendar will behave exactly as this one
407 * does, but it may be set to a different time. By contrast, for
408 * the operator==() method to return TRUE, the other Calendar must
409 * be set to the same time.
411 * @param other the Calendar to be compared with this Calendar
414 virtual UBool
isEquivalentTo(const Calendar
& other
) const;
417 * Compares the Calendar time, whereas Calendar::operator== compares the equality of
420 * @param when The Calendar to be compared with this Calendar. Although this is a
421 * const parameter, the object may be modified physically
422 * (semantically const).
423 * @param status Output param set to success/failure code on exit. If any value
424 * previously set in the time field is invalid or restricted by
425 * leniency, this will be set to an error status.
426 * @return True if the current time of this Calendar is equal to the time of
427 * Calendar when; false otherwise.
430 UBool
equals(const Calendar
& when
, UErrorCode
& status
) const;
433 * Returns true if this Calendar's current time is before "when"'s current time.
435 * @param when The Calendar to be compared with this Calendar. Although this is a
436 * const parameter, the object may be modified physically
437 * (semantically const).
438 * @param status Output param set to success/failure code on exit. If any value
439 * previously set in the time field is invalid or restricted by
440 * leniency, this will be set to an error status.
441 * @return True if the current time of this Calendar is before the time of
442 * Calendar when; false otherwise.
445 UBool
before(const Calendar
& when
, UErrorCode
& status
) const;
448 * Returns true if this Calendar's current time is after "when"'s current time.
450 * @param when The Calendar to be compared with this Calendar. Although this is a
451 * const parameter, the object may be modified physically
452 * (semantically const).
453 * @param status Output param set to success/failure code on exit. If any value
454 * previously set in the time field is invalid or restricted by
455 * leniency, this will be set to an error status.
456 * @return True if the current time of this Calendar is after the time of
457 * Calendar when; false otherwise.
460 UBool
after(const Calendar
& when
, UErrorCode
& status
) const;
463 * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
464 * time field, based on the calendar's rules. For example, to subtract 5 days from
465 * the current time of the calendar, call add(Calendar::DATE, -5). When adding on
466 * the month or Calendar::MONTH field, other fields like date might conflict and
467 * need to be changed. For instance, adding 1 month on the date 01/31/96 will result
470 * @param field Specifies which date field to modify.
471 * @param amount The amount of time to be added to the field, in the natural unit
472 * for that field (e.g., days for the day fields, hours for the hour
474 * @param status Output param set to success/failure code on exit. If any value
475 * previously set in the time field is invalid or restricted by
476 * leniency, this will be set to an error status.
477 * @deprecated ICU 2.6. use add(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
479 virtual void add(EDateFields field
, int32_t amount
, UErrorCode
& status
) = 0;
482 * UDate Arithmetic function. Adds the specified (signed) amount of time to the given
483 * time field, based on the calendar's rules. For example, to subtract 5 days from
484 * the current time of the calendar, call add(Calendar::DATE, -5). When adding on
485 * the month or Calendar::MONTH field, other fields like date might conflict and
486 * need to be changed. For instance, adding 1 month on the date 01/31/96 will result
489 * @param field Specifies which date field to modify.
490 * @param amount The amount of time to be added to the field, in the natural unit
491 * for that field (e.g., days for the day fields, hours for the hour
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.
498 virtual void add(UCalendarDateFields field
, int32_t amount
, UErrorCode
& status
) = 0;
501 * Time Field Rolling function. Rolls (up/down) a single unit of time on the given
502 * time field. For example, to roll the current date up by one day, call
503 * roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it
504 * will roll the year value in the range between getMinimum(Calendar::YEAR) and the
505 * value returned by getMaximum(Calendar::YEAR). When rolling on the month or
506 * Calendar::MONTH field, other fields like date might conflict and, need to be
507 * changed. For instance, rolling the month up on the date 01/31/96 will result in
508 * 02/29/96. Rolling up always means rolling forward in time; e.g., rolling the year
509 * up on "100 BC" will result in "99 BC", for Gregorian calendar. When rolling on the
510 * hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the hour value in the range
511 * between 0 and 23, which is zero-based.
513 * NOTE: Do not use this method -- use roll(EDateFields, int, UErrorCode&) instead.
515 * @param field The time field.
516 * @param up Indicates if the value of the specified time field is to be rolled
517 * up or rolled down. Use true if rolling up, false otherwise.
518 * @param status Output param set to success/failure code on exit. If any value
519 * previously set in the time field is invalid or restricted by
520 * leniency, this will be set to an error status.
521 * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, UBool up, UErrorCode& status) instead.
523 inline void roll(EDateFields field
, UBool up
, UErrorCode
& status
);
526 * Time Field Rolling function. Rolls (up/down) a single unit of time on the given
527 * time field. For example, to roll the current date up by one day, call
528 * roll(Calendar::DATE, true). When rolling on the year or Calendar::YEAR field, it
529 * will roll the year value in the range between getMinimum(Calendar::YEAR) and the
530 * value returned by getMaximum(Calendar::YEAR). When rolling on the month or
531 * Calendar::MONTH field, other fields like date might conflict and, need to be
532 * changed. For instance, rolling the month up on the date 01/31/96 will result in
533 * 02/29/96. Rolling up always means rolling forward in time; e.g., rolling the year
534 * up on "100 BC" will result in "99 BC", for Gregorian calendar. When rolling on the
535 * hour-in-day or Calendar::HOUR_OF_DAY field, it will roll the hour value in the range
536 * between 0 and 23, which is zero-based.
538 * NOTE: Do not use this method -- use roll(UCalendarDateFields, int, UErrorCode&) instead.
540 * @param field The time field.
541 * @param up Indicates if the value of the specified time field is to be rolled
542 * up or rolled down. Use true if rolling up, false otherwise.
543 * @param status Output param set to success/failure code on exit. If any value
544 * previously set in the time field is invalid or restricted by
545 * leniency, this will be set to an error status.
548 inline void roll(UCalendarDateFields field
, UBool up
, UErrorCode
& status
);
551 * Time Field Rolling function. Rolls by the given amount on the given
552 * time field. For example, to roll the current date up by one day, call
553 * roll(Calendar::DATE, +1, status). When rolling on the month or
554 * Calendar::MONTH field, other fields like date might conflict and, need to be
555 * changed. For instance, rolling the month up on the date 01/31/96 will result in
556 * 02/29/96. Rolling by a positive value always means rolling forward in time;
557 * e.g., rolling the year by +1 on "100 BC" will result in "99 BC", for Gregorian
558 * calendar. When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will
559 * roll the hour value in the range between 0 and 23, which is zero-based.
561 * The only difference between roll() and add() is that roll() does not change
562 * the value of more significant fields when it reaches the minimum or maximum
563 * of its range, whereas add() does.
565 * @param field The time field.
566 * @param amount Indicates amount to roll.
567 * @param status Output param set to success/failure code on exit. If any value
568 * previously set in the time field is invalid, this will be set to
570 * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
572 virtual void roll(EDateFields field
, int32_t amount
, UErrorCode
& status
) = 0;
575 * Time Field Rolling function. Rolls by the given amount on the given
576 * time field. For example, to roll the current date up by one day, call
577 * roll(Calendar::DATE, +1, status). When rolling on the month or
578 * Calendar::MONTH field, other fields like date might conflict and, need to be
579 * changed. For instance, rolling the month up on the date 01/31/96 will result in
580 * 02/29/96. Rolling by a positive value always means rolling forward in time;
581 * e.g., rolling the year by +1 on "100 BC" will result in "99 BC", for Gregorian
582 * calendar. When rolling on the hour-in-day or Calendar::HOUR_OF_DAY field, it will
583 * roll the hour value in the range between 0 and 23, which is zero-based.
585 * The only difference between roll() and add() is that roll() does not change
586 * the value of more significant fields when it reaches the minimum or maximum
587 * of its range, whereas add() does.
589 * @param field The time field.
590 * @param amount Indicates amount to roll.
591 * @param status Output param set to success/failure code on exit. If any value
592 * previously set in the time field is invalid, this will be set to
596 virtual void roll(UCalendarDateFields field
, int32_t amount
, UErrorCode
& status
) = 0;
599 * Return the difference between the given time and the time this
600 * calendar object is set to. If this calendar is set
601 * <em>before</em> the given time, the returned value will be
602 * positive. If this calendar is set <em>after</em> the given
603 * time, the returned value will be negative. The
604 * <code>field</code> parameter specifies the units of the return
605 * value. For example, if <code>fieldDifference(when,
606 * Calendar::MONTH)</code> returns 3, then this calendar is set to
607 * 3 months before <code>when</code>, and possibly some addition
608 * time less than one month.
610 * <p>As a side effect of this call, this calendar is advanced
611 * toward <code>when</code> by the given amount. That is, calling
612 * this method has the side effect of calling <code>add(field,
613 * n)</code>, where <code>n</code> is the return value.
615 * <p>Usage: To use this method, call it first with the largest
616 * field of interest, then with progressively smaller fields. For
620 * int y = cal->fieldDifference(when, Calendar::YEAR, err);
621 * int m = cal->fieldDifference(when, Calendar::MONTH, err);
622 * int d = cal->fieldDifference(when, Calendar::DATE, err);</pre>
624 * computes the difference between <code>cal</code> and
625 * <code>when</code> in years, months, and days.
627 * <p>Note: <code>fieldDifference()</code> is
628 * <em>asymmetrical</em>. That is, in the following code:
631 * cal->setTime(date1, err);
632 * int m1 = cal->fieldDifference(date2, Calendar::MONTH, err);
633 * int d1 = cal->fieldDifference(date2, Calendar::DATE, err);
634 * cal->setTime(date2, err);
635 * int m2 = cal->fieldDifference(date1, Calendar::MONTH, err);
636 * int d2 = cal->fieldDifference(date1, Calendar::DATE, err);</pre>
638 * one might expect that <code>m1 == -m2 && d1 == -d2</code>.
639 * However, this is not generally the case, because of
640 * irregularities in the underlying calendar system (e.g., the
641 * Gregorian calendar has a varying number of days per month).
643 * @param when the date to compare this calendar's time to
644 * @param field the field in which to compute the result
645 * @param status Output param set to success/failure code on exit. If any value
646 * previously set in the time field is invalid, this will be set to
648 * @return the difference, either positive or negative, between
649 * this calendar's time and <code>when</code>, in terms of
650 * <code>field</code>.
651 * @deprecated ICU 2.6. Use fieldDifference(UDate when, UCalendarDateFields field, UErrorCode& status).
653 virtual int32_t fieldDifference(UDate when
, EDateFields field
, UErrorCode
& status
);
656 * Return the difference between the given time and the time this
657 * calendar object is set to. If this calendar is set
658 * <em>before</em> the given time, the returned value will be
659 * positive. If this calendar is set <em>after</em> the given
660 * time, the returned value will be negative. The
661 * <code>field</code> parameter specifies the units of the return
662 * value. For example, if <code>fieldDifference(when,
663 * Calendar::MONTH)</code> returns 3, then this calendar is set to
664 * 3 months before <code>when</code>, and possibly some addition
665 * time less than one month.
667 * <p>As a side effect of this call, this calendar is advanced
668 * toward <code>when</code> by the given amount. That is, calling
669 * this method has the side effect of calling <code>add(field,
670 * n)</code>, where <code>n</code> is the return value.
672 * <p>Usage: To use this method, call it first with the largest
673 * field of interest, then with progressively smaller fields. For
677 * int y = cal->fieldDifference(when, Calendar::YEAR, err);
678 * int m = cal->fieldDifference(when, Calendar::MONTH, err);
679 * int d = cal->fieldDifference(when, Calendar::DATE, err);</pre>
681 * computes the difference between <code>cal</code> and
682 * <code>when</code> in years, months, and days.
684 * <p>Note: <code>fieldDifference()</code> is
685 * <em>asymmetrical</em>. That is, in the following code:
688 * cal->setTime(date1, err);
689 * int m1 = cal->fieldDifference(date2, Calendar::MONTH, err);
690 * int d1 = cal->fieldDifference(date2, Calendar::DATE, err);
691 * cal->setTime(date2, err);
692 * int m2 = cal->fieldDifference(date1, Calendar::MONTH, err);
693 * int d2 = cal->fieldDifference(date1, Calendar::DATE, err);</pre>
695 * one might expect that <code>m1 == -m2 && d1 == -d2</code>.
696 * However, this is not generally the case, because of
697 * irregularities in the underlying calendar system (e.g., the
698 * Gregorian calendar has a varying number of days per month).
700 * @param when the date to compare this calendar's time to
701 * @param field the field in which to compute the result
702 * @param status Output param set to success/failure code on exit. If any value
703 * previously set in the time field is invalid, this will be set to
705 * @return the difference, either positive or negative, between
706 * this calendar's time and <code>when</code>, in terms of
707 * <code>field</code>.
710 virtual int32_t fieldDifference(UDate when
, UCalendarDateFields field
, UErrorCode
& status
);
713 * Sets the calendar's time zone to be the one passed in. The Calendar takes ownership
714 * of the TimeZone; the caller is no longer responsible for deleting it. If the
715 * given time zone is NULL, this function has no effect.
717 * @param value The given time zone.
720 void adoptTimeZone(TimeZone
* value
);
723 * Sets the calendar's time zone to be the same as the one passed in. The TimeZone
724 * passed in is _not_ adopted; the client is still responsible for deleting it.
726 * @param zone The given time zone.
729 void setTimeZone(const TimeZone
& zone
);
732 * Returns a reference to the time zone owned by this calendar. The returned reference
733 * is only valid until clients make another call to adoptTimeZone or setTimeZone,
734 * or this Calendar is destroyed.
736 * @return The time zone object associated with this calendar.
739 const TimeZone
& getTimeZone(void) const;
742 * Returns the time zone owned by this calendar. The caller owns the returned object
743 * and must delete it when done. After this call, the new time zone associated
744 * with this Calendar is the default TimeZone as returned by TimeZone::createDefault().
746 * @return The time zone object which was associated with this calendar.
749 TimeZone
* orphanTimeZone(void);
752 * Queries if the current date for this Calendar is in Daylight Savings Time.
754 * @param status Fill-in parameter which receives the status of this operation.
755 * @return True if the current date for this Calendar is in Daylight Savings Time,
759 virtual UBool
inDaylightTime(UErrorCode
& status
) const = 0;
762 * Specifies whether or not date/time interpretation is to be lenient. With lenient
763 * interpretation, a date such as "February 942, 1996" will be treated as being
764 * equivalent to the 941st day after February 1, 1996. With strict interpretation,
765 * such dates will cause an error when computing time from the time field values
766 * representing the dates.
768 * @param lenient True specifies date/time interpretation to be lenient.
770 * @see DateFormat#setLenient
773 void setLenient(UBool lenient
);
776 * Tells whether date/time interpretation is to be lenient.
778 * @return True tells that date/time interpretation is to be lenient.
781 UBool
isLenient(void) const;
784 * Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
786 * @param value The given first day of the week.
787 * @deprecated ICU 2.6. Use setFirstDayOfWeek(UCalendarDaysOfWeek value) instead.
789 void setFirstDayOfWeek(EDaysOfWeek value
);
792 * Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
794 * @param value The given first day of the week.
797 void setFirstDayOfWeek(UCalendarDaysOfWeek value
);
800 * Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
802 * @return The first day of the week.
803 * @deprecated ICU 2.6 use the overload with error code
805 EDaysOfWeek
getFirstDayOfWeek(void) const;
808 * Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
810 * @param status error code
811 * @return The first day of the week.
814 UCalendarDaysOfWeek
getFirstDayOfWeek(UErrorCode
&status
) const;
817 * Sets what the minimal days required in the first week of the year are; For
818 * example, if the first week is defined as one that contains the first day of the
819 * first month of a year, call the method with value 1. If it must be a full week,
822 * @param value The given minimal days required in the first week of the year.
825 void setMinimalDaysInFirstWeek(uint8_t value
);
828 * Gets what the minimal days required in the first week of the year are; e.g., if
829 * the first week is defined as one that contains the first day of the first month
830 * of a year, getMinimalDaysInFirstWeek returns 1. If the minimal days required must
831 * be a full week, getMinimalDaysInFirstWeek returns 7.
833 * @return The minimal days required in the first week of the year.
836 uint8_t getMinimalDaysInFirstWeek(void) const;
839 * Gets the minimum value for the given time field. e.g., for Gregorian
842 * @param field The given time field.
843 * @return The minimum value for the given time field.
844 * @deprecated ICU 2.6. Use getMinimum(UCalendarDateFields field) instead.
846 virtual int32_t getMinimum(EDateFields field
) const = 0;
849 * Gets the minimum value for the given time field. e.g., for Gregorian
852 * @param field The given time field.
853 * @return The minimum value for the given time field.
856 virtual int32_t getMinimum(UCalendarDateFields field
) const = 0;
859 * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
862 * @param field The given time field.
863 * @return The maximum value for the given time field.
864 * @deprecated ICU 2.6. Use getMaximum(UCalendarDateFields field) instead.
866 virtual int32_t getMaximum(EDateFields field
) const = 0;
869 * Gets the maximum value for the given time field. e.g. for Gregorian DAY_OF_MONTH,
872 * @param field The given time field.
873 * @return The maximum value for the given time field.
876 virtual int32_t getMaximum(UCalendarDateFields field
) const = 0;
879 * Gets the highest minimum value for the given field if varies. Otherwise same as
880 * getMinimum(). For Gregorian, no difference.
882 * @param field The given time field.
883 * @return The highest minimum value for the given time field.
884 * @deprecated ICU 2.6. Use getGreatestMinimum(UCalendarDateFields field) instead.
886 virtual int32_t getGreatestMinimum(EDateFields field
) const = 0;
889 * Gets the highest minimum value for the given field if varies. Otherwise same as
890 * getMinimum(). For Gregorian, no difference.
892 * @param field The given time field.
893 * @return The highest minimum value for the given time field.
896 virtual int32_t getGreatestMinimum(UCalendarDateFields field
) const = 0;
899 * Gets the lowest maximum value for the given field if varies. Otherwise same as
900 * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
902 * @param field The given time field.
903 * @return The lowest maximum value for the given time field.
904 * @deprecated ICU 2.6. Use getLeastMaximum(UCalendarDateFields field) instead.
906 virtual int32_t getLeastMaximum(EDateFields field
) const = 0;
909 * Gets the lowest maximum value for the given field if varies. Otherwise same as
910 * getMaximum(). e.g., for Gregorian DAY_OF_MONTH, 28.
912 * @param field The given time field.
913 * @return The lowest maximum value for the given time field.
916 virtual int32_t getLeastMaximum(UCalendarDateFields field
) const = 0;
919 * Return the minimum value that this field could have, given the current date.
920 * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
922 * The version of this function on Calendar uses an iterative algorithm to determine the
923 * actual minimum value for the field. There is almost always a more efficient way to
924 * accomplish this (in most cases, you can simply return getMinimum()). GregorianCalendar
925 * overrides this function with a more efficient implementation.
927 * @param field the field to determine the minimum of
928 * @param status Fill-in parameter which receives the status of this operation.
929 * @return the minimum of the given field for the current date of this Calendar
930 * @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field, UErrorCode& status) instead.
932 int32_t getActualMinimum(EDateFields field
, UErrorCode
& status
) const;
935 * Return the minimum value that this field could have, given the current date.
936 * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
938 * The version of this function on Calendar uses an iterative algorithm to determine the
939 * actual minimum value for the field. There is almost always a more efficient way to
940 * accomplish this (in most cases, you can simply return getMinimum()). GregorianCalendar
941 * overrides this function with a more efficient implementation.
943 * @param field the field to determine the minimum of
944 * @param status Fill-in parameter which receives the status of this operation.
945 * @return the minimum of the given field for the current date of this Calendar
948 int32_t getActualMinimum(UCalendarDateFields field
, UErrorCode
& status
) const;
951 * Return the maximum value that this field could have, given the current date.
952 * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
953 * maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a Hebrew calendar,
954 * for some years the actual maximum for MONTH is 12, and for others 13.
956 * The version of this function on Calendar uses an iterative algorithm to determine the
957 * actual maximum value for the field. There is almost always a more efficient way to
958 * accomplish this (in most cases, you can simply return getMaximum()). GregorianCalendar
959 * overrides this function with a more efficient implementation.
961 * @param field the field to determine the maximum of
962 * @param status Fill-in parameter which receives the status of this operation.
963 * @return the maximum of the given field for the current date of this Calendar
964 * @deprecated ICU 2.6. Use getActualMaximum(UCalendarDateFields field, UErrorCode& status) instead.
966 int32_t getActualMaximum(EDateFields field
, UErrorCode
& status
) const;
969 * Return the maximum value that this field could have, given the current date.
970 * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
971 * maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a Hebrew calendar,
972 * for some years the actual maximum for MONTH is 12, and for others 13.
974 * The version of this function on Calendar uses an iterative algorithm to determine the
975 * actual maximum value for the field. There is almost always a more efficient way to
976 * accomplish this (in most cases, you can simply return getMaximum()). GregorianCalendar
977 * overrides this function with a more efficient implementation.
979 * @param field the field to determine the maximum of
980 * @param status Fill-in parameter which receives the status of this operation.
981 * @return the maximum of the given field for the current date of this Calendar
984 int32_t getActualMaximum(UCalendarDateFields field
, UErrorCode
& status
) const;
987 * Gets the value for a given time field. Recalculate the current time field values
988 * if the time value has been changed by a call to setTime(). Return zero for unset
989 * fields if any fields have been explicitly set by a call to set(). To force a
990 * recomputation of all fields regardless of the previous state, call complete().
991 * This method is semantically const, but may alter the object in memory.
993 * @param field The given time field.
994 * @param status Fill-in parameter which receives the status of the operation.
995 * @return The value for the given time field, or zero if the field is unset,
996 * and set() has been called for any other field.
997 * @deprecated ICU 2.6. Use get(UCalendarDateFields field, UErrorCode& status) instead.
999 int32_t get(EDateFields field
, UErrorCode
& status
) const;
1002 * Gets the value for a given time field. Recalculate the current time field values
1003 * if the time value has been changed by a call to setTime(). Return zero for unset
1004 * fields if any fields have been explicitly set by a call to set(). To force a
1005 * recomputation of all fields regardless of the previous state, call complete().
1006 * This method is semantically const, but may alter the object in memory.
1008 * @param field The given time field.
1009 * @param status Fill-in parameter which receives the status of the operation.
1010 * @return The value for the given time field, or zero if the field is unset,
1011 * and set() has been called for any other field.
1014 int32_t get(UCalendarDateFields field
, UErrorCode
& status
) const;
1017 * Determines if the given time field has a value set. This can affect in the
1018 * resolving of time in Calendar. Unset fields have a value of zero, by definition.
1020 * @param field The given time field.
1021 * @return True if the given time field has a value set; false otherwise.
1022 * @deprecated ICU 2.6. Use isSet(UCalendarDateFields field) instead.
1024 UBool
isSet(EDateFields field
) const;
1027 * Determines if the given time field has a value set. This can affect in the
1028 * resolving of time in Calendar. Unset fields have a value of zero, by definition.
1030 * @param field The given time field.
1031 * @return True if the given time field has a value set; false otherwise.
1034 UBool
isSet(UCalendarDateFields field
) const;
1037 * Sets the given time field with the given value.
1039 * @param field The given time field.
1040 * @param value The value to be set for the given time field.
1041 * @deprecated ICU 2.6. Use set(UCalendarDateFields field, int32_t value) instead.
1043 void set(EDateFields field
, int32_t value
);
1046 * Sets the given time field with the given value.
1048 * @param field The given time field.
1049 * @param value The value to be set for the given time field.
1052 void set(UCalendarDateFields field
, int32_t value
);
1055 * Sets the values for the fields YEAR, MONTH, and DATE. Other field values are
1056 * retained; call clear() first if this is not desired.
1058 * @param year The value used to set the YEAR time field.
1059 * @param month The value used to set the MONTH time field. Month value is 0-based.
1060 * e.g., 0 for January.
1061 * @param date The value used to set the DATE time field.
1064 void set(int32_t year
, int32_t month
, int32_t date
);
1067 * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, and MINUTE. Other
1068 * field values are retained; call clear() first if this is not desired.
1070 * @param year The value used to set the YEAR time field.
1071 * @param month The value used to set the MONTH time field. Month value is
1072 * 0-based. E.g., 0 for January.
1073 * @param date The value used to set the DATE time field.
1074 * @param hour The value used to set the HOUR_OF_DAY time field.
1075 * @param minute The value used to set the MINUTE time field.
1078 void set(int32_t year
, int32_t month
, int32_t date
, int32_t hour
, int32_t minute
);
1081 * Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, MINUTE, and SECOND.
1082 * Other field values are retained; call clear() first if this is not desired.
1084 * @param year The value used to set the YEAR time field.
1085 * @param month The value used to set the MONTH time field. Month value is
1086 * 0-based. E.g., 0 for January.
1087 * @param date The value used to set the DATE time field.
1088 * @param hour The value used to set the HOUR_OF_DAY time field.
1089 * @param minute The value used to set the MINUTE time field.
1090 * @param second The value used to set the SECOND time field.
1093 void set(int32_t year
, int32_t month
, int32_t date
, int32_t hour
, int32_t minute
, int32_t second
);
1096 * Clears the values of all the time fields, making them both unset and assigning
1097 * them a value of zero. The field values will be determined during the next
1098 * resolving of time into time fields.
1104 * Clears the value in the given time field, both making it unset and assigning it a
1105 * value of zero. This field value will be determined during the next resolving of
1106 * time into time fields.
1108 * @param field The time field to be cleared.
1109 * @deprecated ICU 2.6. Use clear(UCalendarDateFields field) instead.
1111 void clear(EDateFields field
);
1114 * Clears the value in the given time field, both making it unset and assigning it a
1115 * value of zero. This field value will be determined during the next resolving of
1116 * time into time fields.
1118 * @param field The time field to be cleared.
1121 void clear(UCalendarDateFields field
);
1124 * Returns a unique class ID POLYMORPHICALLY. Pure virtual method. This method is to
1125 * implement a simple version of RTTI, since not all C++ compilers support genuine
1126 * RTTI. Polymorphic operator==() and clone() methods call this method.
1128 * Concrete subclasses of Calendar must implement getDynamicClassID() and also a
1129 * static method and data member:
1131 * static UClassID getStaticClassID() { return (UClassID)&fgClassID; }
1132 * static char fgClassID;
1134 * @return The class ID for this object. All objects of a given class have the
1135 * same class ID. Objects of other classes have different class IDs.
1138 virtual UClassID
getDynamicClassID(void) const = 0;
1141 * Returns the resource key string used for this calendar type.
1142 * For example, prepending "Eras_" to this string could return "Eras_japanese"
1143 * or "Eras_gregorian".
1145 * @returns static string, for example, "gregorian" or "japanese"
1148 virtual const char * getType() const = 0;
1153 * Constructs a Calendar with the default time zone as returned by
1154 * TimeZone::createInstance(), and the default locale.
1156 * @param success Indicates the status of Calendar object construction. Returns
1157 * U_ZERO_ERROR if constructed successfully.
1160 Calendar(UErrorCode
& success
);
1165 * @param source Calendar object to be copied from
1168 Calendar(const Calendar
& source
);
1171 * Default assignment operator
1173 * @param right Calendar object to be copied
1176 Calendar
& operator=(const Calendar
& right
);
1179 * Constructs a Calendar with the given time zone and locale. Clients are no longer
1180 * responsible for deleting the given time zone object after it's adopted.
1182 * @param zone The given time zone.
1183 * @param aLocale The given locale.
1184 * @param success Indicates the status of Calendar object construction. Returns
1185 * U_ZERO_ERROR if constructed successfully.
1188 Calendar(TimeZone
* zone
, const Locale
& aLocale
, UErrorCode
& success
);
1191 * Constructs a Calendar with the given time zone and locale.
1193 * @param zone The given time zone.
1194 * @param aLocale The given locale.
1195 * @param success Indicates the status of Calendar object construction. Returns
1196 * U_ZERO_ERROR if constructed successfully.
1199 Calendar(const TimeZone
& zone
, const Locale
& aLocale
, UErrorCode
& success
);
1202 * Converts Calendar's time field values to GMT as milliseconds.
1204 * @param status Output param set to success/failure code on exit. If any value
1205 * previously set in the time field is invalid or restricted by
1206 * leniency, this will be set to an error status.
1209 virtual void computeTime(UErrorCode
& status
) = 0;
1212 * Converts GMT as milliseconds to time field values. This allows you to sync up the
1213 * time field values with a new time that is set for the calendar. This method
1214 * does NOT recompute the time first; to recompute the time, then the fields, use
1215 * the method complete().
1217 * @param status Output param set to success/failure code on exit. If any value
1218 * previously set in the time field is invalid or restricted by
1219 * leniency, this will be set to an error status.
1222 virtual void computeFields(UErrorCode
& status
) = 0;
1225 * Gets this Calendar's current time as a long.
1227 * @param status Output param set to success/failure code on exit. If any value
1228 * previously set in the time field is invalid or restricted by
1229 * leniency, this will be set to an error status.
1230 * @return the current time as UTC milliseconds from the epoch.
1233 double getTimeInMillis(UErrorCode
& status
) const;
1236 * Sets this Calendar's current time from the given long value.
1237 * @param millis the new time in UTC milliseconds from the epoch.
1238 * @param status Output param set to success/failure code on exit. If any value
1239 * previously set in the time field is invalid or restricted by
1240 * leniency, this will be set to an error status.
1243 void setTimeInMillis( double millis
, UErrorCode
& status
);
1246 * Recomputes the current time from currently set fields, and then fills in any
1247 * unset fields in the time field list.
1249 * @param status Output param set to success/failure code on exit. If any value
1250 * previously set in the time field is invalid or restricted by
1251 * leniency, this will be set to an error status.
1254 void complete(UErrorCode
& status
);
1257 * Gets the value for a given time field. Subclasses can use this function to get
1258 * field values without forcing recomputation of time.
1260 * @param field The given time field.
1261 * @return The value for the given time field.
1262 * @deprecated ICU 2.6. Use internalGet(UCalendarDateFields field) instead.
1264 inline int32_t internalGet(EDateFields field
) const {return fFields
[field
];}
1267 * Gets the value for a given time field. Subclasses can use this function to get
1268 * field values without forcing recomputation of time.
1270 * @param field The given time field.
1271 * @return The value for the given time field.
1274 inline int32_t internalGet(UCalendarDateFields field
) const {return fFields
[field
];}
1277 * Sets the value for a given time field. This is a fast internal method for
1278 * subclasses. It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet
1281 * @param field The given time field.
1282 * @param value The value for the given time field.
1283 * @deprecated ICU 2.6. Use internalSet(UCalendarDateFields field, int32_t value) instead.
1285 void internalSet(EDateFields field
, int32_t value
);
1288 * Sets the value for a given time field. This is a fast internal method for
1289 * subclasses. It does not affect the areFieldsInSync, isTimeSet, or areAllFieldsSet
1292 * @param field The given time field.
1293 * @param value The value for the given time field.
1296 inline void internalSet(UCalendarDateFields field
, int32_t value
);
1300 * The flag which indicates if the current time is set in the calendar.
1306 * True if the fields are in sync with the currently set time of this Calendar.
1307 * If false, then the next attempt to get the value of a field will
1308 * force a recomputation of all fields from the current value of the time
1311 * This should really be named areFieldsInSync, but the old name is retained
1312 * for backward compatibility.
1315 UBool fAreFieldsSet
;
1318 * True if all of the fields have been set. This is initially false, and set to
1319 * true by computeFields().
1322 UBool fAreAllFieldsSet
;
1325 * Get the current time without recomputing.
1327 * @return the current time without recomputing.
1330 UDate
internalGetTime(void) const { return fTime
; }
1333 * Set the current time without affecting flags or fields.
1335 * @param time The time to be set
1336 * @return the current time without recomputing.
1339 void internalSetTime(UDate time
) { fTime
= time
; }
1342 * The time fields containing values into which the millis is computed.
1345 int32_t fFields
[UCAL_FIELD_COUNT
];
1348 * The flags which tell if a specified time field for the calendar is set.
1351 UBool fIsSet
[UCAL_FIELD_COUNT
];
1353 /** Special values of stamp[]
1363 * Pseudo-time-stamps which specify when each field was set. There
1364 * are two special values, UNSET and INTERNALLY_SET. Values from
1365 * MINIMUM_USER_SET to Integer.MAX_VALUE are legal user set values.
1368 int32_t fStamp
[UCAL_FIELD_COUNT
];
1372 // The next available value for stampp[]
1373 int32_t fNextStamp
;// = MINIMUM_USER_STAMP;
1376 * The current time set for the calendar.
1386 * Time zone affects the time calculation done by Calendar. Calendar subclasses use
1387 * the time zone data to produce the local time.
1392 * Both firstDayOfWeek and minimalDaysInFirstWeek are locale-dependent. They are
1393 * used to figure out the week count for a specific date for a given locale. These
1394 * must be set when a Calendar is constructed. For example, in US locale,
1395 * firstDayOfWeek is SUNDAY; minimalDaysInFirstWeek is 1. They are used to figure
1396 * out the week count for a specific date for a given locale. These must be set when
1397 * a Calendar is constructed.
1399 UCalendarDaysOfWeek fFirstDayOfWeek
;
1400 uint8_t fMinimalDaysInFirstWeek
;
1403 * Sets firstDayOfWeek and minimalDaysInFirstWeek. Called at Calendar construction
1406 * @param desiredLocale The given locale.
1407 * @param success Indicates the status of setting the week count data from
1408 * the resource for the given locale. Returns U_ZERO_ERROR if
1409 * constructed successfully.
1411 void setWeekCountData(const Locale
& desiredLocale
, UErrorCode
& success
);
1414 * Recompute the time and update the status fields isTimeSet
1415 * and areFieldsSet. Callers should check isTimeSet and only
1416 * call this method if isTimeSet is false.
1418 * @param status Output param set to success/failure code on exit. If any value
1419 * previously set in the time field is invalid or restricted by
1420 * leniency, this will be set to an error status.
1422 void updateTime(UErrorCode
& status
);
1425 * The resource tag for the resource where the week-count data is stored.
1427 static const char kDateTimeElements
[];
1430 * The resource tag where the default calendar is stored.
1432 static const char kDefaultCalendar
[];
1436 * INTERNAL FOR 2.6 -- Registration.
1440 * Return a StringEnumeration over the locales available at the time of the call,
1441 * including registered locales.
1442 * @return a StringEnumeration over the locales available at the time of the call
1445 static StringEnumeration
* getAvailableLocales(void);
1448 * Register a new Calendar factory. The factory will be adopted.
1450 * @param toAdopt the factory instance to be adopted
1451 * @param status the in/out status code, no special meanings are assigned
1452 * @return a registry key that can be used to unregister this factory
1455 static URegistryKey
registerFactory(ICUServiceFactory
* toAdopt
, UErrorCode
& status
);
1458 * Unregister a previously-registered CalendarFactory using the key returned from the
1459 * register call. Key becomes invalid after a successful call and should not be used again.
1460 * The CalendarFactory corresponding to the key will be deleted.
1462 * @param key the registry key returned by a previous call to registerFactory
1463 * @param status the in/out status code, no special meanings are assigned
1464 * @return TRUE if the factory for the key was successfully unregistered
1467 static UBool
unregister(URegistryKey key
, UErrorCode
& status
);
1470 * Multiple Calendar Implementation
1473 friend class CalendarFactory
;
1476 * Multiple Calendar Implementation
1479 friend class CalendarService
;
1482 * Multiple Calendar Implementation
1485 friend class DefaultCalendarFactory
;
1489 * @return TRUE if this calendar has a default century (i.e. 03 -> 2003)
1491 virtual UBool
haveDefaultCentury() const = 0;
1495 * @return the start of the default century, as a UDate
1497 virtual UDate
defaultCenturyStart() const = 0;
1500 * @return the beginning year of the default century, as a year
1502 virtual int32_t defaultCenturyStartYear() const = 0;
1506 // -------------------------------------
1509 Calendar::createInstance(TimeZone
* zone
, UErrorCode
& errorCode
)
1511 // since the Locale isn't specified, use the default locale
1512 return createInstance(zone
, Locale::getDefault(), errorCode
);
1515 // -------------------------------------
1518 Calendar::roll(UCalendarDateFields field
, UBool up
, UErrorCode
& status
)
1520 roll(field
, (int32_t)(up
? +1 : -1), status
);
1524 Calendar::roll(EDateFields field
, UBool up
, UErrorCode
& status
)
1526 roll((UCalendarDateFields
) field
, up
, status
);
1529 // -------------------------------------
1532 * Fast method for subclasses. The caller must maintain fUserSetDSTOffset and
1533 * fUserSetZoneOffset, as well as the isSet[] array.
1537 Calendar::internalSet(UCalendarDateFields field
, int32_t value
)
1539 fFields
[field
] = value
;
1543 Calendar::internalSet(EDateFields field
, int32_t value
)
1545 internalSet((UCalendarDateFields
) field
, value
);
1550 #endif /* #if !UCONFIG_NO_FORMATTING */