2 * Copyright (C) {1997-2004}, International Business Machines Corporation and others. All Rights Reserved.
3 ********************************************************************************
7 * Modification History:
9 * Date Name Description
10 * 04/22/97 aliu Overhauled header.
11 * 07/28/98 stephen Sync with JDK 1.2
12 * 09/04/98 stephen Re-sync with JDK 8/31 putback
13 * 09/14/98 stephen Changed type of kOneDay, kOneWeek to double.
15 * 10/15/99 aliu Fixed j31, incorrect WEEK_OF_YEAR computation.
16 * Added documentation of WEEK_OF_YEAR computation.
17 * 10/15/99 aliu Fixed j32, cannot set date to Feb 29 2000 AD.
18 * {JDK bug 4210209 4209272}
19 * 11/07/2003 srl Update, clean up documentation.
20 ********************************************************************************
26 #include "unicode/utypes.h"
28 #if !UCONFIG_NO_FORMATTING
30 #include "unicode/calendar.h"
35 * Concrete class which provides the standard calendar used by most of the world.
37 * The standard (Gregorian) calendar has 2 eras, BC and AD.
39 * This implementation handles a single discontinuity, which corresponds by default to
40 * the date the Gregorian calendar was originally instituted (October 15, 1582). Not all
41 * countries adopted the Gregorian calendar then, so this cutover date may be changed by
44 * Prior to the institution of the Gregorian Calendar, New Year's Day was March 25. To
45 * avoid confusion, this Calendar always uses January 1. A manual adjustment may be made
46 * if desired for dates that are prior to the Gregorian changeover and which fall
47 * between January 1 and March 24.
49 * <p>Values calculated for the <code>WEEK_OF_YEAR</code> field range from 1 to
50 * 53. Week 1 for a year is the first week that contains at least
51 * <code>getMinimalDaysInFirstWeek()</code> days from that year. It thus
52 * depends on the values of <code>getMinimalDaysInFirstWeek()</code>,
53 * <code>getFirstDayOfWeek()</code>, and the day of the week of January 1.
54 * Weeks between week 1 of one year and week 1 of the following year are
55 * numbered sequentially from 2 to 52 or 53 (as needed).
57 * <p>For example, January 1, 1998 was a Thursday. If
58 * <code>getFirstDayOfWeek()</code> is <code>MONDAY</code> and
59 * <code>getMinimalDaysInFirstWeek()</code> is 4 (these are the values
60 * reflecting ISO 8601 and many national standards), then week 1 of 1998 starts
61 * on December 29, 1997, and ends on January 4, 1998. If, however,
62 * <code>getFirstDayOfWeek()</code> is <code>SUNDAY</code>, then week 1 of 1998
63 * starts on January 4, 1998, and ends on January 10, 1998; the first three days
64 * of 1998 then are part of week 53 of 1997.
66 * <p>Example for using GregorianCalendar:
69 * // get the supported ids for GMT-08:00 (Pacific Standard Time)
70 * UErrorCode success = U_ZERO_ERROR;
71 * const StringEnumeration *ids = TimeZone::createEnumeration(-8 * 60 * 60 * 1000);
72 * // if no ids were returned, something is wrong. get out.
73 * if (ids == 0 || ids->count(success) == 0) {
78 * cout << "Current Time" << endl;
80 * // create a Pacific Standard Time time zone
81 * SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids->unext(NULL, success)));
83 * // set up rules for daylight savings time
84 * pdt->setStartRule(Calendar::APRIL, 1, Calendar::SUNDAY, 2 * 60 * 60 * 1000);
85 * pdt->setEndRule(Calendar::OCTOBER, -1, Calendar::SUNDAY, 2 * 60 * 60 * 1000);
87 * // create a GregorianCalendar with the Pacific Daylight time zone
88 * // and the current date and time
89 * Calendar* calendar = new GregorianCalendar( pdt, success );
91 * // print out a bunch of interesting things
92 * cout << "ERA: " << calendar->get( Calendar::ERA, success ) << endl;
93 * cout << "YEAR: " << calendar->get( Calendar::YEAR, success ) << endl;
94 * cout << "MONTH: " << calendar->get( Calendar::MONTH, success ) << endl;
95 * cout << "WEEK_OF_YEAR: " << calendar->get( Calendar::WEEK_OF_YEAR, success ) << endl;
96 * cout << "WEEK_OF_MONTH: " << calendar->get( Calendar::WEEK_OF_MONTH, success ) << endl;
97 * cout << "DATE: " << calendar->get( Calendar::DATE, success ) << endl;
98 * cout << "DAY_OF_MONTH: " << calendar->get( Calendar::DAY_OF_MONTH, success ) << endl;
99 * cout << "DAY_OF_YEAR: " << calendar->get( Calendar::DAY_OF_YEAR, success ) << endl;
100 * cout << "DAY_OF_WEEK: " << calendar->get( Calendar::DAY_OF_WEEK, success ) << endl;
101 * cout << "DAY_OF_WEEK_IN_MONTH: " << calendar->get( Calendar::DAY_OF_WEEK_IN_MONTH, success ) << endl;
102 * cout << "AM_PM: " << calendar->get( Calendar::AM_PM, success ) << endl;
103 * cout << "HOUR: " << calendar->get( Calendar::HOUR, success ) << endl;
104 * cout << "HOUR_OF_DAY: " << calendar->get( Calendar::HOUR_OF_DAY, success ) << endl;
105 * cout << "MINUTE: " << calendar->get( Calendar::MINUTE, success ) << endl;
106 * cout << "SECOND: " << calendar->get( Calendar::SECOND, success ) << endl;
107 * cout << "MILLISECOND: " << calendar->get( Calendar::MILLISECOND, success ) << endl;
108 * cout << "ZONE_OFFSET: " << (calendar->get( Calendar::ZONE_OFFSET, success )/(60*60*1000)) << endl;
109 * cout << "DST_OFFSET: " << (calendar->get( Calendar::DST_OFFSET, success )/(60*60*1000)) << endl;
111 * cout << "Current Time, with hour reset to 3" << endl;
112 * calendar->clear(Calendar::HOUR_OF_DAY); // so doesn't override
113 * calendar->set(Calendar::HOUR, 3);
114 * cout << "ERA: " << calendar->get( Calendar::ERA, success ) << endl;
115 * cout << "YEAR: " << calendar->get( Calendar::YEAR, success ) << endl;
116 * cout << "MONTH: " << calendar->get( Calendar::MONTH, success ) << endl;
117 * cout << "WEEK_OF_YEAR: " << calendar->get( Calendar::WEEK_OF_YEAR, success ) << endl;
118 * cout << "WEEK_OF_MONTH: " << calendar->get( Calendar::WEEK_OF_MONTH, success ) << endl;
119 * cout << "DATE: " << calendar->get( Calendar::DATE, success ) << endl;
120 * cout << "DAY_OF_MONTH: " << calendar->get( Calendar::DAY_OF_MONTH, success ) << endl;
121 * cout << "DAY_OF_YEAR: " << calendar->get( Calendar::DAY_OF_YEAR, success ) << endl;
122 * cout << "DAY_OF_WEEK: " << calendar->get( Calendar::DAY_OF_WEEK, success ) << endl;
123 * cout << "DAY_OF_WEEK_IN_MONTH: " << calendar->get( Calendar::DAY_OF_WEEK_IN_MONTH, success ) << endl;
124 * cout << "AM_PM: " << calendar->get( Calendar::AM_PM, success ) << endl;
125 * cout << "HOUR: " << calendar->get( Calendar::HOUR, success ) << endl;
126 * cout << "HOUR_OF_DAY: " << calendar->get( Calendar::HOUR_OF_DAY, success ) << endl;
127 * cout << "MINUTE: " << calendar->get( Calendar::MINUTE, success ) << endl;
128 * cout << "SECOND: " << calendar->get( Calendar::SECOND, success ) << endl;
129 * cout << "MILLISECOND: " << calendar->get( Calendar::MILLISECOND, success ) << endl;
130 * cout << "ZONE_OFFSET: " << (calendar->get( Calendar::ZONE_OFFSET, success )/(60*60*1000)) << endl; // in hours
131 * cout << "DST_OFFSET: " << (calendar->get( Calendar::DST_OFFSET, success )/(60*60*1000)) << endl; // in hours
133 * if (U_FAILURE(success)) {
134 * cout << "An error occured. success=" << u_errorName(success) << endl;
138 * delete calendar; // also deletes pdt
143 class U_I18N_API GregorianCalendar
: public Calendar
{
147 * Useful constants for GregorianCalendar and TimeZone.
156 * Constructs a default GregorianCalendar using the current time in the default time
157 * zone with the default locale.
159 * @param success Indicates the status of GregorianCalendar object construction.
160 * Returns U_ZERO_ERROR if constructed successfully.
163 GregorianCalendar(UErrorCode
& success
);
166 * Constructs a GregorianCalendar based on the current time in the given time zone
167 * with the default locale. Clients are no longer responsible for deleting the given
168 * time zone object after it's adopted.
170 * @param zoneToAdopt The given timezone.
171 * @param success Indicates the status of GregorianCalendar object construction.
172 * Returns U_ZERO_ERROR if constructed successfully.
175 GregorianCalendar(TimeZone
* zoneToAdopt
, UErrorCode
& success
);
178 * Constructs a GregorianCalendar based on the current time in the given time zone
179 * with the default locale.
181 * @param zone The given timezone.
182 * @param success Indicates the status of GregorianCalendar object construction.
183 * Returns U_ZERO_ERROR if constructed successfully.
186 GregorianCalendar(const TimeZone
& zone
, UErrorCode
& success
);
189 * Constructs a GregorianCalendar based on the current time in the default time zone
190 * with the given locale.
192 * @param aLocale The given locale.
193 * @param success Indicates the status of GregorianCalendar object construction.
194 * Returns U_ZERO_ERROR if constructed successfully.
197 GregorianCalendar(const Locale
& aLocale
, UErrorCode
& success
);
200 * Constructs a GregorianCalendar based on the current time in the given time zone
201 * with the given locale. Clients are no longer responsible for deleting the given
202 * time zone object after it's adopted.
204 * @param zoneToAdopt The given timezone.
205 * @param aLocale The given locale.
206 * @param success Indicates the status of GregorianCalendar object construction.
207 * Returns U_ZERO_ERROR if constructed successfully.
210 GregorianCalendar(TimeZone
* zoneToAdopt
, const Locale
& aLocale
, UErrorCode
& success
);
213 * Constructs a GregorianCalendar based on the current time in the given time zone
214 * with the given locale.
216 * @param zone The given timezone.
217 * @param aLocale The given locale.
218 * @param success Indicates the status of GregorianCalendar object construction.
219 * Returns U_ZERO_ERROR if constructed successfully.
222 GregorianCalendar(const TimeZone
& zone
, const Locale
& aLocale
, UErrorCode
& success
);
225 * Constructs a GregorianCalendar with the given AD date set in the default time
226 * zone with the default locale.
228 * @param year The value used to set the YEAR time field in the calendar.
229 * @param month The value used to set the MONTH time field in the calendar. Month
230 * value is 0-based. e.g., 0 for January.
231 * @param date The value used to set the DATE time field in the calendar.
232 * @param success Indicates the status of GregorianCalendar object construction.
233 * Returns U_ZERO_ERROR if constructed successfully.
236 GregorianCalendar(int32_t year
, int32_t month
, int32_t date
, UErrorCode
& success
);
239 * Constructs a GregorianCalendar with the given AD date and time set for the
240 * default time zone with the default locale.
242 * @param year The value used to set the YEAR time field in the calendar.
243 * @param month The value used to set the MONTH time field in the calendar. Month
244 * value is 0-based. e.g., 0 for January.
245 * @param date The value used to set the DATE time field in the calendar.
246 * @param hour The value used to set the HOUR_OF_DAY time field in the calendar.
247 * @param minute The value used to set the MINUTE time field in the calendar.
248 * @param success Indicates the status of GregorianCalendar object construction.
249 * Returns U_ZERO_ERROR if constructed successfully.
252 GregorianCalendar(int32_t year
, int32_t month
, int32_t date
, int32_t hour
, int32_t minute
, UErrorCode
& success
);
255 * Constructs a GregorianCalendar with the given AD date and time set for the
256 * default time zone with the default locale.
258 * @param year The value used to set the YEAR time field in the calendar.
259 * @param month The value used to set the MONTH time field in the calendar. Month
260 * value is 0-based. e.g., 0 for January.
261 * @param date The value used to set the DATE time field in the calendar.
262 * @param hour The value used to set the HOUR_OF_DAY time field in the calendar.
263 * @param minute The value used to set the MINUTE time field in the calendar.
264 * @param second The value used to set the SECOND time field in the calendar.
265 * @param success Indicates the status of GregorianCalendar object construction.
266 * Returns U_ZERO_ERROR if constructed successfully.
269 GregorianCalendar(int32_t year
, int32_t month
, int32_t date
, int32_t hour
, int32_t minute
, int32_t second
, UErrorCode
& success
);
275 virtual ~GregorianCalendar();
279 * @param source the object to be copied.
282 GregorianCalendar(const GregorianCalendar
& source
);
285 * Default assignment operator
286 * @param right the object to be copied.
289 GregorianCalendar
& operator=(const GregorianCalendar
& right
);
292 * Create and return a polymorphic copy of this calendar.
293 * @return return a polymorphic copy of this calendar.
296 virtual Calendar
* clone(void) const;
299 * Sets the GregorianCalendar change date. This is the point when the switch from
300 * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October
301 * 15, 1582. Previous to this time and date will be Julian dates.
303 * @param date The given Gregorian cutover date.
304 * @param success Output param set to success/failure code on exit.
307 void setGregorianChange(UDate date
, UErrorCode
& success
);
310 * Gets the Gregorian Calendar change date. This is the point when the switch from
311 * Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October
312 * 15, 1582. Previous to this time and date will be Julian dates.
314 * @return The Gregorian cutover time for this calendar.
317 UDate
getGregorianChange(void) const;
320 * Return true if the given year is a leap year. Determination of whether a year is
321 * a leap year is actually very complicated. We do something crude and mostly
322 * correct here, but for a real determination you need a lot of contextual
323 * information. For example, in Sweden, the change from Julian to Gregorian happened
324 * in a complex way resulting in missed leap years and double leap years between
325 * 1700 and 1753. Another example is that after the start of the Julian calendar in
326 * 45 B.C., the leap years did not regularize until 8 A.D. This method ignores these
327 * quirks, and pays attention only to the Julian onset date and the Gregorian
328 * cutover (which can be changed).
330 * @param year The given year.
331 * @return True if the given year is a leap year; false otherwise.
334 UBool
isLeapYear(int32_t year
) const;
337 * Returns TRUE if the given Calendar object is equivalent to this
338 * one. Calendar override.
340 * @param other the Calendar to be compared with this Calendar
343 virtual UBool
isEquivalentTo(const Calendar
& other
) const;
346 * (Overrides Calendar) Rolls up or down by the given amount in the specified field.
347 * For more information, see the documentation for Calendar::roll().
349 * @param field The time field.
350 * @param amount Indicates amount to roll.
351 * @param status Output param set to success/failure code on exit. If any value
352 * previously set in the time field is invalid, this will be set to
354 * @deprecated ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.
356 virtual void roll(EDateFields field
, int32_t amount
, UErrorCode
& status
);
359 * (Overrides Calendar) Rolls up or down by the given amount in the specified field.
360 * For more information, see the documentation for Calendar::roll().
362 * @param field The time field.
363 * @param amount Indicates amount to roll.
364 * @param status Output param set to success/failure code on exit. If any value
365 * previously set in the time field is invalid, this will be set to
369 virtual void roll(UCalendarDateFields field
, int32_t amount
, UErrorCode
& status
);
372 * Return the minimum value that this field could have, given the current date.
373 * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
374 * @param field the time field.
375 * @return the minimum value that this field could have, given the current date.
376 * @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field) instead.
378 int32_t getActualMinimum(EDateFields field
) const;
381 * Return the minimum value that this field could have, given the current date.
382 * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
383 * @param field the time field.
385 * @return the minimum value that this field could have, given the current date.
386 * @deprecated ICU 2.6. Use getActualMinimum(UCalendarDateFields field) instead. (Added to ICU 3.0 for signature consistency)
388 int32_t getActualMinimum(EDateFields field
, UErrorCode
& status
) const;
391 * Return the minimum value that this field could have, given the current date.
392 * For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().
393 * @param field the time field.
394 * @param status error result.
395 * @return the minimum value that this field could have, given the current date.
398 int32_t getActualMinimum(UCalendarDateFields field
, UErrorCode
&status
) const;
401 * Return the maximum value that this field could have, given the current date.
402 * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
403 * maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a Hebrew calendar,
404 * for some years the actual maximum for MONTH is 12, and for others 13.
405 * @param field the time field.
406 * @return the maximum value that this field could have, given the current date.
407 * @deprecated ICU 2.6. Use getActualMaximum(UCalendarDateFields field) instead.
409 int32_t getActualMaximum(EDateFields field
) const;
412 * Return the maximum value that this field could have, given the current date.
413 * For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual
414 * maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a Hebrew calendar,
415 * for some years the actual maximum for MONTH is 12, and for others 13.
416 * @param field the time field.
417 * @param status returns any errors that may result from this function call.
418 * @return the maximum value that this field could have, given the current date.
421 virtual int32_t getActualMaximum(UCalendarDateFields field
, UErrorCode
& status
) const;
424 * (Overrides Calendar) Return true if the current date for this Calendar is in
425 * Daylight Savings Time. Recognizes DST_OFFSET, if it is set.
427 * @param status Fill-in parameter which receives the status of this operation.
428 * @return True if the current date for this Calendar is in Daylight Savings Time,
432 virtual UBool
inDaylightTime(UErrorCode
& status
) const;
437 * Override Calendar Returns a unique class ID POLYMORPHICALLY. Pure virtual
438 * override. This method is to implement a simple version of RTTI, since not all C++
439 * compilers support genuine RTTI. Polymorphic operator==() and clone() methods call
442 * @return The class ID for this object. All objects of a given class have the
443 * same class ID. Objects of other classes have different class IDs.
446 virtual UClassID
getDynamicClassID(void) const;
449 * Return the class ID for this class. This is useful only for comparing to a return
450 * value from getDynamicClassID(). For example:
452 * Base* polymorphic_pointer = createPolymorphicObject();
453 * if (polymorphic_pointer->getDynamicClassID() ==
454 * Derived::getStaticClassID()) ...
456 * @return The class ID for all objects of this class.
459 static UClassID U_EXPORT2
getStaticClassID(void);
462 * Get the calendar type, "gregorian", for use in DateFormatSymbols.
464 * @return calendar type
467 virtual const char * getType() const;
472 * (Overrides Calendar) Converts GMT as milliseconds to time field values.
473 * @param status Fill-in parameter which receives the status of this operation.
478 GregorianCalendar(); // default constructor not implemented
482 * Return the ERA. We need a special method for this because the
483 * default ERA is AD, but a zero (unset) ERA is BC.
487 virtual int32_t internalGetEra() const;
490 * Return the Julian day number of day before the first day of the
491 * given month in the given extended year. Subclasses should override
492 * this method to implement their calendar system.
493 * @param eyear the extended year
494 * @param month the zero-based month, or 0 if useMonth is false
495 * @param useMonth if false, compute the day before the first day of
496 * the given year, otherwise, compute the day before the first day of
498 * @return the Julian day number of the day before the first
499 * day of the given month and year
502 virtual int32_t handleComputeMonthStart(int32_t eyear
, int32_t month
,
503 UBool useMonth
) const;
506 * Subclasses may override this. This method calls
507 * handleGetMonthLength() to obtain the calendar-specific month
509 * @param bestField which field to use to calculate the date
510 * @return julian day specified by calendar fields.
513 virtual int32_t handleComputeJulianDay(UCalendarDateFields bestField
) ;
516 * Return the number of days in the given month of the given extended
517 * year of this calendar system. Subclasses should override this
518 * method if they can provide a more correct or more efficient
519 * implementation than the default implementation in Calendar.
522 virtual int32_t handleGetMonthLength(int32_t extendedYear
, int32_t month
) const;
525 * Return the number of days in the given extended year of this
526 * calendar system. Subclasses should override this method if they can
527 * provide a more correct or more efficient implementation than the
528 * default implementation in Calendar.
531 virtual int32_t handleGetYearLength(int32_t eyear
) const;
534 * return the length of the given month.
535 * @param month the given month.
536 * @return the length of the given month.
539 virtual int32_t monthLength(int32_t month
) const;
542 * return the length of the month according to the given year.
543 * @param month the given month.
544 * @param year the given year.
545 * @return the length of the month
548 virtual int32_t monthLength(int32_t month
, int32_t year
) const;
551 * return the length of the given year.
552 * @param year the given year.
553 * @return the length of the given year.
556 int32_t yearLength(int32_t year
) const;
559 * return the length of the year field.
560 * @return the length of the year field
563 int32_t yearLength(void) const;
566 * After adjustments such as add(MONTH), add(YEAR), we don't want the
567 * month to jump around. E.g., we don't want Jan 31 + 1 month to go to Mar
568 * 3, we want it to go to Feb 28. Adjustments which might run into this
569 * problem call this method to retain the proper month.
572 void pinDayOfMonth(void);
575 * Return the day number with respect to the epoch. January 1, 1970 (Gregorian)
577 * @param status Fill-in parameter which receives the status of this operation.
578 * @return the day number with respect to the epoch.
581 virtual UDate
getEpochDay(UErrorCode
& status
);
584 * Subclass API for defining limits of different types.
585 * Subclasses must implement this method to return limits for the
593 * UCAL_DATE (DAY_OF_MONTH on Java)
595 * UCAL_DAY_OF_WEEK_IN_MONTH
597 * UCAL_EXTENDED_YEAR</pre>
599 * @param field one of the above field numbers
600 * @param limitType one of <code>MINIMUM</code>, <code>GREATEST_MINIMUM</code>,
601 * <code>LEAST_MAXIMUM</code>, or <code>MAXIMUM</code>
604 virtual int32_t handleGetLimit(UCalendarDateFields field
, ELimitType limitType
) const;
607 * Return the extended year defined by the current fields. This will
608 * use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such
609 * as UCAL_ERA) specific to the calendar system, depending on which set of
611 * @return the extended year
614 virtual int32_t handleGetExtendedYear();
617 * Subclasses may override this to convert from week fields
618 * (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case
619 * where YEAR, EXTENDED_YEAR are not set.
620 * The Gregorian implementation assumes a yearWoy in gregorian format, according to the current era.
621 * @return the extended year, UCAL_EXTENDED_YEAR
624 virtual int32_t handleGetExtendedYearFromWeekFields(int32_t yearWoy
, int32_t woy
);
628 * Subclasses may override this method to compute several fields
629 * specific to each calendar system. These are:
636 * <li>EXTENDED_YEAR</ul>
638 * <p>The GregorianCalendar implementation implements
639 * a calendar with the specified Julian/Gregorian cutover date.
642 virtual void handleComputeFields(int32_t julianDay
, UErrorCode
&status
);
646 * Compute the julian day number of the given year.
647 * @param isGregorian if true, using Gregorian calendar, otherwise using Julian calendar
648 * @param year the given year.
649 * @param isLeap true if the year is a leap year.
652 static double computeJulianDayOfYear(UBool isGregorian
, int32_t year
,
656 * Validates the values of the set time fields. True if they're all valid.
657 * @return True if the set time fields are all valid.
659 UBool
validateFields(void) const;
662 * Validates the value of the given time field. True if it's valid.
664 UBool
boundsCheck(int32_t value
, UCalendarDateFields field
) const;
667 * Return the pseudo-time-stamp for two fields, given their
668 * individual pseudo-time-stamps. If either of the fields
669 * is unset, then the aggregate is unset. Otherwise, the
670 * aggregate is the later of the two stamps.
671 * @param stamp_a One given field.
672 * @param stamp_b Another given field.
673 * @return the pseudo-time-stamp for two fields
675 int32_t aggregateStamp(int32_t stamp_a
, int32_t stamp_b
);
678 * The point at which the Gregorian calendar rules are used, measured in
679 * milliseconds from the standard epoch. Default is October 15, 1582
680 * (Gregorian) 00:00:00 UTC, that is, October 4, 1582 (Julian) is followed
681 * by October 15, 1582 (Gregorian). This corresponds to Julian day number
682 * 2299161. This is measured from the standard epoch, not in Julian Days.
685 UDate fGregorianCutover
;
688 * Julian day number of the Gregorian cutover
690 int32_t fCutoverJulianDay
;
693 * Midnight, local time (using this Calendar's TimeZone) at or before the
694 * gregorianCutover. This is a pure date value with no time of day or
695 * timezone component.
697 UDate fNormalizedGregorianCutover
;// = gregorianCutover;
700 * The year of the gregorianCutover, with 0 representing
701 * 1 BC, -1 representing 2 BC, etc.
703 int32_t fGregorianCutoverYear
;// = 1582;
706 * The year of the gregorianCutover, with 0 representing
707 * 1 BC, -1 representing 2 BC, etc.
709 int32_t fGregorianCutoverJulianDay
;// = 2299161;
712 * Converts time as milliseconds to Julian date. The Julian date used here is not a
713 * true Julian date, since it is measured from midnight, not noon.
715 * @param millis The given milliseconds.
716 * @return The Julian date number.
718 static double millisToJulianDay(UDate millis
);
721 * Converts Julian date to time as milliseconds. The Julian date used here is not a
722 * true Julian date, since it is measured from midnight, not noon.
724 * @param julian The given Julian date number.
725 * @return Time as milliseconds.
727 static UDate
julianDayToMillis(double julian
);
730 * Used by handleComputeJulianDay() and handleComputeMonthStart().
731 * Temporary field indicating whether the calendar is currently Gregorian as opposed to Julian.
736 * Used by handleComputeJulianDay() and handleComputeMonthStart().
737 * Temporary field indicating that the sense of the gregorian cutover should be inverted
738 * to handle certain calculations on and around the cutover date.
740 UBool fInvertGregorian
;
743 public: // internal implementation
747 * @return TRUE if this calendar has the notion of a default century
749 virtual UBool
haveDefaultCentury() const;
753 * @return the start of the default century
755 virtual UDate
defaultCenturyStart() const;
759 * @return the beginning year of the default century
761 virtual int32_t defaultCenturyStartYear() const;
765 * The system maintains a static default century start date. This is initialized
766 * the first time it is used. Before then, it is set to SYSTEM_DEFAULT_CENTURY to
767 * indicate an uninitialized state. Once the system default century date and year
768 * are set, they do not change.
770 static UDate fgSystemDefaultCenturyStart
;
773 * See documentation for systemDefaultCenturyStart.
775 static int32_t fgSystemDefaultCenturyStartYear
;
778 * Default value that indicates the defaultCenturyStartYear is unitialized
780 static const int32_t fgSystemDefaultCenturyYear
;
783 * Default value that indicates the UDate of the beginning of the system default century
785 static const UDate fgSystemDefaultCentury
;
788 * Returns the beginning date of the 100-year window that dates with 2-digit years
789 * are considered to fall within.
790 * @return the beginning date of the 100-year window that dates with 2-digit years
791 * are considered to fall within.
793 UDate
internalGetDefaultCenturyStart(void) const;
796 * Returns the first year of the 100-year window that dates with 2-digit years
797 * are considered to fall within.
798 * @return the first year of the 100-year window that dates with 2-digit years
799 * are considered to fall within.
801 int32_t internalGetDefaultCenturyStartYear(void) const;
804 * Initializes the 100-year window that dates with 2-digit years are considered
805 * to fall within so that its start date is 80 years before the current time.
807 static void initializeSystemDefaultCentury(void);
813 #endif /* #if !UCONFIG_NO_FORMATTING */