ICU 74.2 74.2

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
icu::GregorianCalendar Class Reference

Concrete class which provides the standard calendar used by most of the world. More...

`#include <gregocal.h>`

Inheritance diagram for icu::GregorianCalendar:

## Public Types
enum | EEras { BC , AD }
| Useful constants for GregorianCalendar and TimeZone. More...
Public Types inherited from icu::Calendar
enum | EDateFields { ERA , YEAR , MONTH , WEEK_OF_YEAR , WEEK_OF_MONTH , DATE , DAY_OF_YEAR , DAY_OF_WEEK , DAY_OF_WEEK_IN_MONTH , AM_PM , HOUR , HOUR_OF_DAY , MINUTE , SECOND , MILLISECOND , ZONE_OFFSET , DST_OFFSET , YEAR_WOY , DOW_LOCAL , EXTENDED_YEAR , JULIAN_DAY , MILLISECONDS_IN_DAY , IS_LEAP_MONTH , FIELD_COUNT = UCAL_FIELD_COUNT }
| Field IDs for date and time. More...
enum | EDaysOfWeek { SUNDAY = 1 , MONDAY , TUESDAY , WEDNESDAY , THURSDAY , FRIDAY , SATURDAY }
| Useful constant for days of week. More...
enum | EMonths { JANUARY , FEBRUARY , MARCH , APRIL , MAY , JUNE , JULY , AUGUST , SEPTEMBER , OCTOBER , NOVEMBER , DECEMBER , UNDECIMBER }
| Useful constants for month. More...
enum | EAmpm { AM , PM }
| Useful constants for hour in 12-hour clock. More...

## Public Member Functions
| GregorianCalendar (UErrorCode &success)
| Constructs a default GregorianCalendar using the current time in the default time zone with the default locale.
| GregorianCalendar (TimeZone *zoneToAdopt, UErrorCode &success)
| Constructs a GregorianCalendar based on the current time in the given time zone with the default locale.
| GregorianCalendar (const TimeZone &zone, UErrorCode &success)
| Constructs a GregorianCalendar based on the current time in the given time zone with the default locale.
| GregorianCalendar (const Locale &aLocale, UErrorCode &success)
| Constructs a GregorianCalendar based on the current time in the default time zone with the given locale.
| GregorianCalendar (TimeZone *zoneToAdopt, const Locale &aLocale, UErrorCode &success)
| Constructs a GregorianCalendar based on the current time in the given time zone with the given locale.
| GregorianCalendar (const TimeZone &zone, const Locale &aLocale, UErrorCode &success)
| Constructs a GregorianCalendar based on the current time in the given time zone with the given locale.
| GregorianCalendar (int32_t year, int32_t month, int32_t date, UErrorCode &success)
| Constructs a GregorianCalendar with the given AD date set in the default time zone with the default locale.
| GregorianCalendar (int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, UErrorCode &success)
| Constructs a GregorianCalendar with the given AD date and time set for the default time zone with the default locale.
| GregorianCalendar (int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second, UErrorCode &success)
| Constructs a GregorianCalendar with the given AD date and time set for the default time zone with the default locale.
virtual | ~GregorianCalendar ()
| Destructor.
| GregorianCalendar (const GregorianCalendar &source)
| Copy constructor.
GregorianCalendar & | operator= (const GregorianCalendar &right)
| Default assignment operator.
virtual GregorianCalendar * | clone () const override
| Create and return a polymorphic copy of this calendar.
void | setGregorianChange (UDate date, UErrorCode &success)
| Sets the GregorianCalendar change date.
UDate | getGregorianChange (void) const
| Gets the Gregorian Calendar change date.
UBool | isLeapYear (int32_t year) const
| Return true if the given year is a leap year.
virtual UBool | isEquivalentTo (const Calendar &other) const override
| Returns true if the given Calendar object is equivalent to this one.
virtual void | roll (EDateFields field, int32_t amount, UErrorCode &status) override
| (Overrides Calendar) Rolls up or down by the given amount in the specified field.
virtual void | roll (UCalendarDateFields field, int32_t amount, UErrorCode &status) override
| (Overrides Calendar) Rolls up or down by the given amount in the specified field.
int32_t | getActualMinimum (EDateFields field) const
| Return the minimum value that this field could have, given the current date.
int32_t | getActualMinimum (EDateFields field, UErrorCode &status) const
| Return the minimum value that this field could have, given the current date.
int32_t | getActualMinimum (UCalendarDateFields field, UErrorCode &status) const override
| Return the minimum value that this field could have, given the current date.
virtual int32_t | getActualMaximum (UCalendarDateFields field, UErrorCode &status) const override
| Return the maximum value that this field could have, given the current date.
virtual UClassID | getDynamicClassID (void) const override
| Override Calendar Returns a unique class ID POLYMORPHICALLY.
virtual const char * | getType () const override
| Returns the calendar type name string for this Calendar object.
virtual UBool | haveDefaultCentury () const override
virtual UDate | defaultCenturyStart () const override
virtual int32_t | defaultCenturyStartYear () const override
Public Member Functions inherited from icu::Calendar
virtual | ~Calendar ()
| destructor
virtual Calendar * | clone () const =0
| Create and return a polymorphic copy of this calendar.
UDate | getTime (UErrorCode &status) const
| Gets this Calendar's time as milliseconds.
void | setTime (UDate date, UErrorCode &status)
| Sets this Calendar's current time with the given UDate.
virtual bool | operator== (const Calendar &that) const
| Compares the equality of two Calendar objects.
bool | operator!= (const Calendar &that) const
| Compares the inequality of two Calendar objects.
virtual UBool | isEquivalentTo (const Calendar &other) const
| Returns true if the given Calendar object is equivalent to this one.
UBool | equals (const Calendar &when, UErrorCode &status) const
| Compares the Calendar time, whereas Calendar::operator== compares the equality of Calendar objects.
UBool | before (const Calendar &when, UErrorCode &status) const
| Returns true if this Calendar's current time is before "when"'s current time.
UBool | after (const Calendar &when, UErrorCode &status) const
| Returns true if this Calendar's current time is after "when"'s current time.
virtual void | add (EDateFields field, int32_t amount, UErrorCode &status)
| UDate Arithmetic function.
virtual void | add (UCalendarDateFields field, int32_t amount, UErrorCode &status)
| UDate Arithmetic function.
void | roll (EDateFields field, UBool up, UErrorCode &status)
| Time Field Rolling function.
void | roll (UCalendarDateFields field, UBool up, UErrorCode &status)
| Time Field Rolling function.
virtual void | roll (EDateFields field, int32_t amount, UErrorCode &status)
| Time Field Rolling function.
virtual void | roll (UCalendarDateFields field, int32_t amount, UErrorCode &status)
| Time Field Rolling function.
virtual int32_t | fieldDifference (UDate when, EDateFields field, UErrorCode &status)
| Return the difference between the given time and the time this calendar object is set to.
virtual int32_t | fieldDifference (UDate when, UCalendarDateFields field, UErrorCode &status)
| Return the difference between the given time and the time this calendar object is set to.
void | adoptTimeZone (TimeZone *value)
| Sets the calendar's time zone to be the one passed in.
void | setTimeZone (const TimeZone &zone)
| Sets the calendar's time zone to be the same as the one passed in.
const TimeZone & | getTimeZone (void) const
| Returns a reference to the time zone owned by this calendar.
TimeZone * | orphanTimeZone (void)
| Returns the time zone owned by this calendar.
virtual UBool | inDaylightTime (UErrorCode &status) const
| Queries if the current date for this Calendar is in Daylight Savings Time.
void | setLenient (UBool lenient)
| Specifies whether or not date/time interpretation is to be lenient.
UBool | isLenient (void) const
| Tells whether date/time interpretation is to be lenient.
void | setRepeatedWallTimeOption (UCalendarWallTimeOption option)
| Sets the behavior for handling wall time repeating multiple times at negative time zone offset transitions.
UCalendarWallTimeOption | getRepeatedWallTimeOption (void) const
| Gets the behavior for handling wall time repeating multiple times at negative time zone offset transitions.
void | setSkippedWallTimeOption (UCalendarWallTimeOption option)
| Sets the behavior for handling skipped wall time at positive time zone offset transitions.
UCalendarWallTimeOption | getSkippedWallTimeOption (void) const
| Gets the behavior for handling skipped wall time at positive time zone offset transitions.
void | setFirstDayOfWeek (UCalendarDaysOfWeek value)
| Sets what the first day of the week is; e.g., Sunday in US, Monday in France.
EDaysOfWeek | getFirstDayOfWeek (void) const
| Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
UCalendarDaysOfWeek | getFirstDayOfWeek (UErrorCode &status) const
| Gets what the first day of the week is; e.g., Sunday in US, Monday in France.
void | setMinimalDaysInFirstWeek (uint8_t value)
| Sets what the minimal days required in the first week of the year are; For example, if the first week is defined as one that contains the first day of the first month of a year, call the method with value 1.
uint8_t | getMinimalDaysInFirstWeek (void) const
| Gets what the minimal days required in the first week of the year are; e.g., if the first week is defined as one that contains the first day of the first month of a year, getMinimalDaysInFirstWeek returns 1.
virtual int32_t | getMinimum (EDateFields field) const
| Gets the minimum value for the given time field.
virtual int32_t | getMinimum (UCalendarDateFields field) const
| Gets the minimum value for the given time field.
virtual int32_t | getMaximum (EDateFields field) const
| Gets the maximum value for the given time field.
virtual int32_t | getMaximum (UCalendarDateFields field) const
| Gets the maximum value for the given time field.
virtual int32_t | getGreatestMinimum (EDateFields field) const
| Gets the highest minimum value for the given field if varies.
virtual int32_t | getGreatestMinimum (UCalendarDateFields field) const
| Gets the highest minimum value for the given field if varies.
virtual int32_t | getLeastMaximum (EDateFields field) const
| Gets the lowest maximum value for the given field if varies.
virtual int32_t | getLeastMaximum (UCalendarDateFields field) const
| Gets the lowest maximum value for the given field if varies.
int32_t | getActualMinimum (EDateFields field, UErrorCode &status) const
| Return the minimum value that this field could have, given the current date.
virtual int32_t | getActualMinimum (UCalendarDateFields field, UErrorCode &status) const
| Return the minimum value that this field could have, given the current date.
virtual int32_t | getActualMaximum (UCalendarDateFields field, UErrorCode &status) const
| Return the maximum value that this field could have, given the current date.
int32_t | get (UCalendarDateFields field, UErrorCode &status) const
| Gets the value for a given time field.
UBool | isSet (UCalendarDateFields field) const
| Determines if the given time field has a value set.
void | set (UCalendarDateFields field, int32_t value)
| Sets the given time field with the given value.
void | set (int32_t year, int32_t month, int32_t date)
| Sets the values for the fields YEAR, MONTH, and DATE.
void | set (int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute)
| Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, and MINUTE.
void | set (int32_t year, int32_t month, int32_t date, int32_t hour, int32_t minute, int32_t second)
| Sets the values for the fields YEAR, MONTH, DATE, HOUR_OF_DAY, MINUTE, and SECOND.
void | clear (void)
| Clears the values of all the time fields, making them both unset and assigning them a value of zero.
void | clear (UCalendarDateFields field)
| Clears the value in the given time field, both making it unset and assigning it a value of zero.
virtual UClassID | getDynamicClassID (void) const override=0
| Returns a unique class ID POLYMORPHICALLY.
virtual const char * | getType () const =0
| Returns the calendar type name string for this Calendar object.
virtual UCalendarWeekdayType | getDayOfWeekType (UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const
| Returns whether the given day of the week is a weekday, a weekend day, or a day that transitions from one to the other, for the locale and calendar system associated with this Calendar (the locale's region is often the most determinant factor).
virtual int32_t | getWeekendTransition (UCalendarDaysOfWeek dayOfWeek, UErrorCode &status) const
| Returns the time during the day at which the weekend begins or ends in this calendar system.
virtual UBool | isWeekend (UDate date, UErrorCode &status) const
| Returns true if the given UDate is in the weekend in this calendar system.
virtual UBool | isWeekend (void) const
| Returns true if this Calendar's current date-time is in the weekend in this calendar system.
virtual bool | inTemporalLeapYear (UErrorCode &status) const
| Returns true if the date is in a leap year.
virtual const char * | getTemporalMonthCode (UErrorCode &status) const
| Gets The Temporal monthCode value corresponding to the month for the date.
virtual void | setTemporalMonthCode (const char *temporalMonth, UErrorCode &status)
| Sets The Temporal monthCode which is a string identifier that starts with the literal grapheme "M" followed by two graphemes representing the zero-padded month number of the current month in a normal (non-leap) year and suffixed by an optional literal grapheme "L" if this is a leap month in a lunisolar calendar.
virtual UBool | haveDefaultCentury () const =0
virtual UDate | defaultCenturyStart () const =0
virtual int32_t | defaultCenturyStartYear () const =0
Locale | getLocale (ULocDataLocaleType type, UErrorCode &status) const
| Get the locale for this calendar object.
virtual int32_t | getRelatedYear (UErrorCode &status) const
virtual void | setRelatedYear (int32_t year)
const char * | getLocaleID (ULocDataLocaleType type, UErrorCode &status) const
| Get the locale for this calendar object.
Public Member Functions inherited from icu::UObject
virtual | ~UObject ()
| Destructor.
virtual UClassID | getDynamicClassID () const
| ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.

## Static Public Member Functions
static UClassID | getStaticClassID (void)
| Return the class ID for this class.
Static Public Member Functions inherited from icu::Calendar
static Calendar * | createInstance (UErrorCode &success)
| Creates a Calendar using the default timezone and locale.
static Calendar * | createInstance (TimeZone *zoneToAdopt, UErrorCode &success)
| Creates a Calendar using the given timezone and the default locale.
static Calendar * | createInstance (const TimeZone &zone, UErrorCode &success)
| Creates a Calendar using the given timezone and the default locale.
static Calendar * | createInstance (const Locale &aLocale, UErrorCode &success)
| Creates a Calendar using the default timezone and the given locale.
static Calendar * | createInstance (TimeZone *zoneToAdopt, const Locale &aLocale, UErrorCode &success)
| Creates a Calendar using the given timezone and given locale.
static Calendar * | createInstance (const TimeZone &zone, const Locale &aLocale, UErrorCode &success)
| Gets a Calendar using the given timezone and given locale.
static const Locale * | getAvailableLocales (int32_t &count)
| Returns a list of the locales for which Calendars are installed.
static StringEnumeration * | getKeywordValuesForLocale (const char *key, const Locale &locale, UBool commonlyUsed, UErrorCode &status)
| Given a key and a locale, returns an array of string values in a preferred order that would make a difference.
static UDate | getNow (void)
| Returns the current UTC (GMT) time measured in milliseconds since 0:00:00 on 1/1/70 (derived from the system time).
static StringEnumeration * | getAvailableLocales (void)
| INTERNAL FOR 2.6 – Registration.
static URegistryKey | registerFactory (ICUServiceFactory *toAdopt, UErrorCode &status)
| Register a new Calendar factory.
static UBool | unregister (URegistryKey key, UErrorCode &status)
| Unregister a previously-registered CalendarFactory using the key returned from the register call.
static Calendar * | makeInstance (const Locale &locale, UErrorCode &status)
| Creates a new Calendar from a Locale for the cache.
static void | getCalendarTypeFromLocale (const Locale &locale, char *typeBuffer, int32_t typeBufferSize, UErrorCode &status)
| Get the calendar type for given locale.

## Protected Member Functions
virtual int32_t | internalGetEra () const
| Return the ERA.
virtual int32_t | handleComputeMonthStart (int32_t eyear, int32_t month, UBool useMonth) const override
| Return the Julian day number of day before the first day of the given month in the given extended year.
virtual int32_t | handleComputeJulianDay (UCalendarDateFields bestField) override
| Subclasses may override this.
virtual int32_t | handleGetMonthLength (int32_t extendedYear, int32_t month) const override
| Return the number of days in the given month of the given extended year of this calendar system.
virtual int32_t | handleGetYearLength (int32_t eyear) const override
| Return the number of days in the given extended year of this calendar system.
virtual int32_t | monthLength (int32_t month) const
| return the length of the given month.
virtual int32_t | monthLength (int32_t month, int32_t year) const
| return the length of the month according to the given year.
int32_t | yearLength (void) const
| return the length of the year field.
virtual UDate | getEpochDay (UErrorCode &status)
| Return the day number with respect to the epoch.
virtual int32_t | handleGetLimit (UCalendarDateFields field, ELimitType limitType) const override
| Subclass API for defining limits of different types.
virtual int32_t | handleGetExtendedYear () override
| Return the extended year defined by the current fields.
virtual int32_t | handleGetExtendedYearFromWeekFields (int32_t yearWoy, int32_t woy) override
| Subclasses may override this to convert from week fields (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case where YEAR, EXTENDED_YEAR are not set.
virtual void | handleComputeFields (int32_t julianDay, UErrorCode &status) override
| Subclasses may override this method to compute several fields specific to each calendar system.
Protected Member Functions inherited from icu::Calendar
| Calendar (UErrorCode &success)
| Constructs a Calendar with the default time zone as returned by TimeZone::createInstance(), and the default locale.
| Calendar (const Calendar &source)
| Copy constructor.
Calendar & | operator= (const Calendar &right)
| Default assignment operator.
| Calendar (TimeZone *zone, const Locale &aLocale, UErrorCode &success)
| Constructs a Calendar with the given time zone and locale.
| Calendar (const TimeZone &zone, const Locale &aLocale, UErrorCode &success)
| Constructs a Calendar with the given time zone and locale.
virtual void | computeTime (UErrorCode &status)
| Converts Calendar's time field values to GMT as milliseconds.
virtual void | computeFields (UErrorCode &status)
| Converts GMT as milliseconds to time field values.
double | getTimeInMillis (UErrorCode &status) const
| Gets this Calendar's current time as a long.
void | setTimeInMillis (double millis, UErrorCode &status)
| Sets this Calendar's current time from the given long value.
void | complete (UErrorCode &status)
| Recomputes the current time from currently set fields, and then fills in any unset fields in the time field list.
int32_t | internalGet (EDateFields field) const
| Gets the value for a given time field.
int32_t | internalGet (UCalendarDateFields field, int32_t defaultValue) const
| Gets the value for a given time field.
int32_t | internalGet (UCalendarDateFields field) const
| Gets the value for a given time field.
virtual int32_t | internalGetMonth () const
| Use this function instead of internalGet(UCAL_MONTH).
virtual int32_t | internalGetMonth (int32_t defaultValue) const
| Use this function instead of internalGet(UCAL_MONTH, defaultValue).
void | internalSet (EDateFields field, int32_t value)
| Sets the value for a given time field.
void | internalSet (UCalendarDateFields field, int32_t value)
| Sets the value for a given time field.
virtual void | prepareGetActual (UCalendarDateFields field, UBool isMinimum, UErrorCode &status)
| Prepare this calendar for computing the actual minimum or maximum.
virtual int32_t | handleGetLimit (UCalendarDateFields field, ELimitType limitType) const =0
| Subclass API for defining limits of different types.
virtual int32_t | getLimit (UCalendarDateFields field, ELimitType limitType) const
| Return a limit for a field.
virtual int32_t | handleComputeMonthStart (int32_t eyear, int32_t month, UBool useMonth) const =0
| Return the Julian day number of day before the first day of the given month in the given extended year.
virtual int32_t | handleGetMonthLength (int32_t extendedYear, int32_t month) const
| Return the number of days in the given month of the given extended year of this calendar system.
virtual int32_t | handleGetYearLength (int32_t eyear) const
| Return the number of days in the given extended year of this calendar system.
virtual int32_t | handleGetExtendedYear ()=0
| Return the extended year defined by the current fields.
virtual int32_t | handleComputeJulianDay (UCalendarDateFields bestField)
| Subclasses may override this.
virtual int32_t | handleGetExtendedYearFromWeekFields (int32_t yearWoy, int32_t woy)
| Subclasses must override this to convert from week fields (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case where YEAR, EXTENDED_YEAR are not set.
virtual void | validateField (UCalendarDateFields field, UErrorCode &status)
| Validate a single field of this calendar.
int32_t | computeJulianDay ()
| Compute the Julian day from fields.
double | computeMillisInDay ()
| Compute the milliseconds in the day from the fields.
int32_t | computeZoneOffset (double millis, double millisInDay, UErrorCode &ec)
| This method can assume EXTENDED_YEAR has been set.
int32_t | newestStamp (UCalendarDateFields start, UCalendarDateFields end, int32_t bestSoFar) const
| Determine the best stamp in a range.
UCalendarDateFields | resolveFields (const UFieldResolutionTable *precedenceTable) const
| Given a precedence table, return the newest field combination in the table, or UCAL_FIELD_COUNT if none is found.
virtual const UFieldResolutionTable * | getFieldResolutionTable () const
UCalendarDateFields | newerField (UCalendarDateFields defaultField, UCalendarDateFields alternateField) const
| Return the field that is newer, either defaultField, or alternateField.
UDate | internalGetTime (void) const
| Get the current time without recomputing.
void | internalSetTime (UDate time)
| Set the current time without affecting flags or fields.
virtual void | handleComputeFields (int32_t julianDay, UErrorCode &status)
| Subclasses may override this method to compute several fields specific to each calendar system.
int32_t | getGregorianYear () const
| Return the extended year on the Gregorian calendar as computed by `computeGregorianFields()`.
int32_t | getGregorianMonth () const
| Return the month (0-based) on the Gregorian calendar as computed by `computeGregorianFields()`.
int32_t | getGregorianDayOfYear () const
| Return the day of year (1-based) on the Gregorian calendar as computed by `computeGregorianFields()`.
int32_t | getGregorianDayOfMonth () const
| Return the day of month (1-based) on the Gregorian calendar as computed by `computeGregorianFields()`.
virtual int32_t | getDefaultMonthInYear (int32_t eyear)
| Called by computeJulianDay.
virtual int32_t | getDefaultDayInMonth (int32_t eyear, int32_t month)
| Called by computeJulianDay.
virtual void | pinField (UCalendarDateFields field, UErrorCode &status)
| Adjust the specified field so that it is within the allowable range for the date to which this calendar is set.
int32_t | weekNumber (int32_t desiredDay, int32_t dayOfPeriod, int32_t dayOfWeek)
| Return the week number of a day, within a period.
int32_t | weekNumber (int32_t dayOfPeriod, int32_t dayOfWeek)
| Return the week number of a day, within a period.
int32_t | getLocalDOW ()
| returns the local DOW, valid range 0..6
void | computeGregorianFields (int32_t julianDay, UErrorCode &ec)
| Compute the Gregorian calendar year, month, and day of month from the Julian day.

## Additional Inherited Members
Protected Types inherited from icu::Calendar
enum | ELimitType { UCAL_LIMIT_MINIMUM = 0 , UCAL_LIMIT_GREATEST_MINIMUM , UCAL_LIMIT_LEAST_MAXIMUM , UCAL_LIMIT_MAXIMUM , UCAL_LIMIT_COUNT }
| Limit enums. More...
enum | { kUnset = 0 , kInternallySet , kMinimumUserStamp }
| Special values of stamp[]. More...
Static Protected Member Functions inherited from icu::Calendar
static uint8_t | julianDayToDayOfWeek (double julian)
| Convert a quasi Julian date to the day of the week.
Protected Attributes inherited from icu::Calendar
UBool | fIsTimeSet
| The flag which indicates if the current time is set in the calendar.
UBool | fAreFieldsSet
| True if the fields are in sync with the currently set time of this Calendar.
UBool | fAreAllFieldsSet
| True if all of the fields have been set.
UBool | fAreFieldsVirtuallySet
| True if all fields have been virtually set, but have not yet been computed.
int32_t | fFields [UCAL_FIELD_COUNT]
| The time fields containing values into which the millis is computed.
UBool | fIsSet [UCAL_FIELD_COUNT]
| The flags which tell if a specified time field for the calendar is set.
int32_t | fStamp [UCAL_FIELD_COUNT]
| Pseudo-time-stamps which specify when each field was set.
Static Protected Attributes inherited from icu::Calendar
static constexpr int32_t | kResolveSTOP = -1
| Marker for end of resolve set (row or group).
static constexpr int32_t | kResolveRemap = 32
| Value to be bitwised "ORed" against resolve table field values for remapping.
static const UFieldResolutionTable | kDatePrecedence []
| Precedence table for Dates.
static const UFieldResolutionTable | kYearPrecedence []
| Precedence table for Year.
static const UFieldResolutionTable | kDOWPrecedence []
| Precedence table for Day of Week.
static const UFieldResolutionTable | kMonthPrecedence []
| Precedence table for Months.

## Detailed Description

Concrete class which provides the standard calendar used by most of the world.

The standard (Gregorian) calendar has 2 eras, BC and AD.

This implementation handles a single discontinuity, which corresponds by default to the date the Gregorian calendar was originally instituted (October 15, 1582). Not all countries adopted the Gregorian calendar then, so this cutover date may be changed by the caller.

Prior to the institution of the Gregorian Calendar, New Year's Day was March 25. To avoid confusion, this Calendar always uses January 1. A manual adjustment may be made if desired for dates that are prior to the Gregorian changeover and which fall between January 1 and March 24.

Values calculated for the `WEEK_OF_YEAR` field range from 1 to

1. Week 1 for a year is the first week that contains at least `getMinimalDaysInFirstWeek()` days from that year. It thus depends on the values of `getMinimalDaysInFirstWeek()`, `getFirstDayOfWeek()`, and the day of the week of January 1. Weeks between week 1 of one year and week 1 of the following year are numbered sequentially from 2 to 52 or 53 (as needed).

For example, January 1, 1998 was a Thursday. If `getFirstDayOfWeek()` is `MONDAY` and `getMinimalDaysInFirstWeek()` is 4 (these are the values reflecting ISO 8601 and many national standards), then week 1 of 1998 starts on December 29, 1997, and ends on January 4, 1998. If, however, `getFirstDayOfWeek()` is `SUNDAY`, then week 1 of 1998 starts on January 4, 1998, and ends on January 10, 1998; the first three days of 1998 then are part of week 53 of 1997.

Example for using GregorianCalendar:

    // get the supported ids for GMT-08:00 (Pacific Standard Time)
    UErrorCode success = U_ZERO_ERROR;
    const StringEnumeration *ids = TimeZone::createEnumeration(-8 * 60 * 60 * 1000, success);
    // if no ids were returned, something is wrong. get out.
    if (U_FAILURE(success)) {
        return;
    }

    // begin output
    cout << "Current Time" << endl;

    // create a Pacific Standard Time time zone
    SimpleTimeZone* pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids->unext(nullptr, success)));

    // set up rules for daylight savings time
    pdt->setStartRule(UCAL_MARCH, 1, UCAL_SUNDAY, 2 * 60 * 60 * 1000);
    pdt->setEndRule(UCAL_NOVEMBER, 2, UCAL_SUNDAY, 2 * 60 * 60 * 1000);

    // create a GregorianCalendar with the Pacific Daylight time zone
    // and the current date and time
    Calendar* calendar = new GregorianCalendar( pdt, success );

    // print out a bunch of interesting things
    cout << "ERA: " << calendar->get( UCAL_ERA, success ) << endl;
    cout << "YEAR: " << calendar->get( UCAL_YEAR, success ) << endl;
    cout << "MONTH: " << calendar->get( UCAL_MONTH, success ) << endl;
    cout << "WEEK_OF_YEAR: " << calendar->get( UCAL_WEEK_OF_YEAR, success ) << endl;
    cout << "WEEK_OF_MONTH: " << calendar->get( UCAL_WEEK_OF_MONTH, success ) << endl;
    cout << "DATE: " << calendar->get( UCAL_DATE, success ) << endl;
    cout << "DAY_OF_MONTH: " << calendar->get( UCAL_DAY_OF_MONTH, success ) << endl;
    cout << "DAY_OF_YEAR: " << calendar->get( UCAL_DAY_OF_YEAR, success ) << endl;
    cout << "DAY_OF_WEEK: " << calendar->get( UCAL_DAY_OF_WEEK, success ) << endl;
    cout << "DAY_OF_WEEK_IN_MONTH: " << calendar->get( UCAL_DAY_OF_WEEK_IN_MONTH, success ) << endl;
    cout << "AM_PM: " << calendar->get( UCAL_AM_PM, success ) << endl;
    cout << "HOUR: " << calendar->get( UCAL_HOUR, success ) << endl;
    cout << "HOUR_OF_DAY: " << calendar->get( UCAL_HOUR_OF_DAY, success ) << endl;
    cout << "MINUTE: " << calendar->get( UCAL_MINUTE, success ) << endl;
    cout << "SECOND: " << calendar->get( UCAL_SECOND, success ) << endl;
    cout << "MILLISECOND: " << calendar->get( UCAL_MILLISECOND, success ) << endl;
    cout << "ZONE_OFFSET: " << (calendar->get( UCAL_ZONE_OFFSET, success )/(60*60*1000)) << endl;
    cout << "DST_OFFSET: " << (calendar->get( UCAL_DST_OFFSET, success )/(60*60*1000)) << endl;

    cout << "Current Time, with hour reset to 3" << endl;
    calendar->clear(UCAL_HOUR_OF_DAY); // so doesn't override
    calendar->set(UCAL_HOUR, 3);
    cout << "ERA: " << calendar->get( UCAL_ERA, success ) << endl;
    cout << "YEAR: " << calendar->get( UCAL_YEAR, success ) << endl;
    cout << "MONTH: " << calendar->get( UCAL_MONTH, success ) << endl;
    cout << "WEEK_OF_YEAR: " << calendar->get( UCAL_WEEK_OF_YEAR, success ) << endl;
    cout << "WEEK_OF_MONTH: " << calendar->get( UCAL_WEEK_OF_MONTH, success ) << endl;
    cout << "DATE: " << calendar->get( UCAL_DATE, success ) << endl;
    cout << "DAY_OF_MONTH: " << calendar->get( UCAL_DAY_OF_MONTH, success ) << endl;
    cout << "DAY_OF_YEAR: " << calendar->get( UCAL_DAY_OF_YEAR, success ) << endl;
    cout << "DAY_OF_WEEK: " << calendar->get( UCAL_DAY_OF_WEEK, success ) << endl;
    cout << "DAY_OF_WEEK_IN_MONTH: " << calendar->get( UCAL_DAY_OF_WEEK_IN_MONTH, success ) << endl;
    cout << "AM_PM: " << calendar->get( UCAL_AM_PM, success ) << endl;
    cout << "HOUR: " << calendar->get( UCAL_HOUR, success ) << endl;
    cout << "HOUR_OF_DAY: " << calendar->get( UCAL_HOUR_OF_DAY, success ) << endl;
    cout << "MINUTE: " << calendar->get( UCAL_MINUTE, success ) << endl;
    cout << "SECOND: " << calendar->get( UCAL_SECOND, success ) << endl;
    cout << "MILLISECOND: " << calendar->get( UCAL_MILLISECOND, success ) << endl;
    cout << "ZONE_OFFSET: " << (calendar->get( UCAL_ZONE_OFFSET, success )/(60*60*1000)) << endl; // in hours
    cout << "DST_OFFSET: " << (calendar->get( UCAL_DST_OFFSET, success )/(60*60*1000)) << endl; // in hours

    if (U_FAILURE(success)) {
        cout << "An error occurred. success=" << u_errorName(success) << endl;
    }

    delete ids;
    delete calendar; // also deletes pdt
    icu::CalendarCalendar is an abstract base class for converting between a UDate object and a set of integer fields ...Definition calendar.h:189
    icu::Calendar::setvoid set(UCalendarDateFields field, int32_t value)Sets the given time field with the given value.
    icu::Calendar::getint32_t get(UCalendarDateFields field, UErrorCode &status) constGets the value for a given time field.
    icu::Calendar::clearvoid clear(void)Clears the values of all the time fields, making them both unset and assigning them a value of zero.
    icu::GregorianCalendarConcrete class which provides the standard calendar used by most of the world.Definition gregocal.h:153
    icu::SimpleTimeZoneSimpleTimeZone is a concrete subclass of TimeZone that represents a time zone for use with a Gregoria...Definition simpletz.h:65
    icu::SimpleTimeZone::setEndRulevoid setEndRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, int32_t time, UErrorCode &status)Sets the daylight savings ending rule.Definition simpletz.h:912
    icu::SimpleTimeZone::setStartRulevoid setStartRule(int32_t month, int32_t dayOfWeekInMonth, int32_t dayOfWeek, int32_t time, UErrorCode &status)Sets the daylight savings starting rule.Definition simpletz.h:894
    icu::StringEnumerationBase class for 'pure' C++ implementations of uenum api.Definition strenum.h:61
    icu::StringEnumeration::unextvirtual const char16_t * unext(int32_t *resultLength, UErrorCode &status)
    icu::TimeZone::createEnumerationstatic StringEnumeration * createEnumeration()Returns an enumeration over all recognized time zone IDs.
    UCAL_HOUR_OF_DAY@ UCAL_HOUR_OF_DAYField number indicating the hour of the day.Definition ucal.h:351
    UCAL_ERA@ UCAL_ERAField number indicating the era, e.g., AD or BC in the Gregorian (Julian) calendar.Definition ucal.h:208
    UCAL_WEEK_OF_MONTH@ UCAL_WEEK_OF_MONTHField number indicating the week number within the current month.Definition ucal.h:263
    UCAL_YEAR@ UCAL_YEARField number indicating the year.Definition ucal.h:214
    UCAL_DAY_OF_YEAR@ UCAL_DAY_OF_YEARField number indicating the day number within the current year.Definition ucal.h:279
    UCAL_MINUTE@ UCAL_MINUTEField number indicating the minute within the hour.Definition ucal.h:359
    UCAL_DATE@ UCAL_DATEField number indicating the day of the month.Definition ucal.h:272
    UCAL_SECOND@ UCAL_SECONDField number indicating the second within the minute.Definition ucal.h:367
    UCAL_DAY_OF_WEEK_IN_MONTH@ UCAL_DAY_OF_WEEK_IN_MONTHField number indicating the ordinal number of the day of the week within the current month.Definition ucal.h:320
    UCAL_MONTH@ UCAL_MONTHField number indicating the month.Definition ucal.h:235
    UCAL_ZONE_OFFSET@ UCAL_ZONE_OFFSETField number indicating the raw offset from GMT in milliseconds.Definition ucal.h:382
    UCAL_WEEK_OF_YEAR@ UCAL_WEEK_OF_YEARField number indicating the week number within the current year.Definition ucal.h:248
    UCAL_MILLISECOND@ UCAL_MILLISECONDField number indicating the millisecond within the second.Definition ucal.h:375
    UCAL_HOUR@ UCAL_HOURField number indicating the hour of the morning or afternoon.Definition ucal.h:342
    UCAL_DAY_OF_MONTH@ UCAL_DAY_OF_MONTHField number indicating the day of the month.Definition ucal.h:496
    UCAL_DAY_OF_WEEK@ UCAL_DAY_OF_WEEKField number indicating the day of the week.Definition ucal.h:295
    UCAL_AM_PM@ UCAL_AM_PMField number indicating whether the HOUR is before or after noon.Definition ucal.h:331
    UCAL_DST_OFFSET@ UCAL_DST_OFFSETField number indicating the daylight savings offset in milliseconds.Definition ucal.h:389
    UCAL_SUNDAY@ UCAL_SUNDAYSunday.Definition ucal.h:511
    UCAL_NOVEMBER@ UCAL_NOVEMBERNovember.Definition ucal.h:554
    UCAL_MARCH@ UCAL_MARCHMarch.Definition ucal.h:538
    u_errorNameU_CAPI const char * u_errorName(UErrorCode code)Return a string for a UErrorCode value.
    UErrorCodeUErrorCodeStandard ICU4C error code type, a substitute for exceptions.Definition utypes.h:415
    U_ZERO_ERROR@ U_ZERO_ERRORNo error, no warning.Definition utypes.h:449
    U_FAILURE#define U_FAILURE(x)Does the error code indicate a failure?Definition utypes.h:717

Stable:
  ICU 2.0

Definition at line 153 of file gregocal.h.

## Member Enumeration Documentation

## ◆ EEras

enum icu::GregorianCalendar::EEras

Useful constants for GregorianCalendar and TimeZone.

Stable:
  ICU 2.0

Definition at line 160 of file gregocal.h.

## Constructor & Destructor Documentation

## ◆ GregorianCalendar() [1/10]

icu::GregorianCalendar::GregorianCalendar | ( | UErrorCode & | success | ) |

Constructs a default GregorianCalendar using the current time in the default time zone with the default locale.

Parameters

  success | Indicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.

Stable:
  ICU 2.0

## ◆ GregorianCalendar() [2/10]

icu::GregorianCalendar::GregorianCalendar | ( | TimeZone * | zoneToAdopt,
|  | UErrorCode & | success
| ) |  |

Constructs a GregorianCalendar based on the current time in the given time zone with the default locale.

Clients are no longer responsible for deleting the given time zone object after it's adopted.

Parameters

  zoneToAdopt | The given timezone.
  success | Indicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.

Stable:
  ICU 2.0

## ◆ GregorianCalendar() [3/10]

icu::GregorianCalendar::GregorianCalendar | ( | const TimeZone & | zone,
|  | UErrorCode & | success
| ) |  |

Constructs a GregorianCalendar based on the current time in the given time zone with the default locale.

Parameters

  zone | The given timezone.
  success | Indicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.

Stable:
  ICU 2.0

## ◆ GregorianCalendar() [4/10]

icu::GregorianCalendar::GregorianCalendar | ( | const Locale & | aLocale,
|  | UErrorCode & | success
| ) |  |

Constructs a GregorianCalendar based on the current time in the default time zone with the given locale.

Parameters

  aLocale | The given locale.
  success | Indicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.

Stable:
  ICU 2.0

## ◆ GregorianCalendar() [5/10]

icu::GregorianCalendar::GregorianCalendar | ( | TimeZone * | zoneToAdopt,
|  | const Locale & | aLocale,
|  | UErrorCode & | success
| ) |  |

Constructs a GregorianCalendar based on the current time in the given time zone with the given locale.

Clients are no longer responsible for deleting the given time zone object after it's adopted.

Parameters

  zoneToAdopt | The given timezone.
  aLocale | The given locale.
  success | Indicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.

Stable:
  ICU 2.0

## ◆ GregorianCalendar() [6/10]

icu::GregorianCalendar::GregorianCalendar | ( | const TimeZone & | zone,
|  | const Locale & | aLocale,
|  | UErrorCode & | success
| ) |  |

Constructs a GregorianCalendar based on the current time in the given time zone with the given locale.

Parameters

  zone | The given timezone.
  aLocale | The given locale.
  success | Indicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.

Stable:
  ICU 2.0

## ◆ GregorianCalendar() [7/10]

icu::GregorianCalendar::GregorianCalendar | ( | int32_t | year,
|  | int32_t | month,
|  | int32_t | date,
|  | UErrorCode & | success
| ) |  |

Constructs a GregorianCalendar with the given AD date set in the default time zone with the default locale.

Parameters

  year | The value used to set the YEAR time field in the calendar.
  month | The value used to set the MONTH time field in the calendar. Month value is 0-based. e.g., 0 for January.
  date | The value used to set the DATE time field in the calendar.
  success | Indicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.

Stable:
  ICU 2.0

## ◆ GregorianCalendar() [8/10]

icu::GregorianCalendar::GregorianCalendar | ( | int32_t | year,
|  | int32_t | month,
|  | int32_t | date,
|  | int32_t | hour,
|  | int32_t | minute,
|  | UErrorCode & | success
| ) |  |

Constructs a GregorianCalendar with the given AD date and time set for the default time zone with the default locale.

Parameters

  year | The value used to set the YEAR time field in the calendar.
  month | The value used to set the MONTH time field in the calendar. Month value is 0-based. e.g., 0 for January.
  date | The value used to set the DATE time field in the calendar.
  hour | The value used to set the HOUR_OF_DAY time field in the calendar.
  minute | The value used to set the MINUTE time field in the calendar.
  success | Indicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.

Stable:
  ICU 2.0

## ◆ GregorianCalendar() [9/10]

icu::GregorianCalendar::GregorianCalendar | ( | int32_t | year,
|  | int32_t | month,
|  | int32_t | date,
|  | int32_t | hour,
|  | int32_t | minute,
|  | int32_t | second,
|  | UErrorCode & | success
| ) |  |

Constructs a GregorianCalendar with the given AD date and time set for the default time zone with the default locale.

Parameters

  year | The value used to set the YEAR time field in the calendar.
  month | The value used to set the MONTH time field in the calendar. Month value is 0-based. e.g., 0 for January.
  date | The value used to set the DATE time field in the calendar.
  hour | The value used to set the HOUR_OF_DAY time field in the calendar.
  minute | The value used to set the MINUTE time field in the calendar.
  second | The value used to set the SECOND time field in the calendar.
  success | Indicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.

Stable:
  ICU 2.0

## ◆ ~GregorianCalendar()

virtual icu::GregorianCalendar::~GregorianCalendar | ( |  | ) |
| virtual

Destructor.

Stable:
  ICU 2.0

## ◆ GregorianCalendar() [10/10]

icu::GregorianCalendar::GregorianCalendar | ( | const GregorianCalendar & | source | ) |

Copy constructor.

Parameters

  source | the object to be copied.

Stable:
  ICU 2.0

## Member Function Documentation

## ◆ clone()

virtual GregorianCalendar * icu::GregorianCalendar::clone | ( |  | ) | const
| override virtual

Create and return a polymorphic copy of this calendar.

Returns
  return a polymorphic copy of this calendar.

Stable:
  ICU 2.0

Implements icu::Calendar.

## ◆ defaultCenturyStart()

virtual UDate icu::GregorianCalendar::defaultCenturyStart | ( |  | ) | const
| override virtual

Returns
  the start of the default century

Internal:
  Do not use. This API is for internal use only.

Implements icu::Calendar.

## ◆ defaultCenturyStartYear()

virtual int32_t icu::GregorianCalendar::defaultCenturyStartYear | ( |  | ) | const
| override virtual

Returns
  the beginning year of the default century

Internal:
  Do not use. This API is for internal use only.

Implements icu::Calendar.

## ◆ getActualMaximum()

virtual int32_t icu::GregorianCalendar::getActualMaximum | ( | UCalendarDateFields | field,
|  | UErrorCode & | status
| ) |  | const
| override virtual

Return the maximum value that this field could have, given the current date.

For example, with the date "Feb 3, 1997" and the DAY_OF_MONTH field, the actual maximum would be 28; for "Feb 3, 1996" it s 29. Similarly for a Hebrew calendar, for some years the actual maximum for MONTH is 12, and for others 13.

Parameters

  field | the time field.
  status | returns any errors that may result from this function call.

Returns
  the maximum value that this field could have, given the current date.

Stable:
  ICU 2.6

Reimplemented from icu::Calendar.

## ◆ getActualMinimum() [1/3]

int32_t icu::GregorianCalendar::getActualMinimum | ( | EDateFields | field | ) | const

Return the minimum value that this field could have, given the current date.

For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().

Parameters

  field | the time field.

Returns
  the minimum value that this field could have, given the current date.

Deprecated:
  ICU 2.6. Use getActualMinimum(UCalendarDateFields field) instead.

## ◆ getActualMinimum() [2/3]

int32_t icu::GregorianCalendar::getActualMinimum | ( | EDateFields | field,
|  | UErrorCode & | status
| ) |  | const

Return the minimum value that this field could have, given the current date.

For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().

Parameters

  field | the time field.
  status |

Returns
  the minimum value that this field could have, given the current date.

Deprecated:
  ICU 2.6. Use getActualMinimum(UCalendarDateFields field) instead. (Added to ICU 3.0 for signature consistency)

## ◆ getActualMinimum() [3/3]

int32_t icu::GregorianCalendar::getActualMinimum | ( | UCalendarDateFields | field,
|  | UErrorCode & | status
| ) |  | const
| override virtual

Return the minimum value that this field could have, given the current date.

For the Gregorian calendar, this is the same as getMinimum() and getGreatestMinimum().

Parameters

  field | the time field.
  status | error result.

Returns
  the minimum value that this field could have, given the current date.

Stable:
  ICU 3.0

Reimplemented from icu::Calendar.

## ◆ getDynamicClassID()

virtual UClassID icu::GregorianCalendar::getDynamicClassID | ( | void |  | ) | const
| override virtual

Override Calendar Returns a unique class ID POLYMORPHICALLY.

Pure virtual override. This method is to implement a simple version of RTTI, since not all C++ compilers support genuine RTTI. Polymorphic operator==() and clone() methods call this method.

Returns
  The class ID for this object. All objects of a given class have the same class ID. Objects of other classes have different class IDs.

Stable:
  ICU 2.0

Implements icu::Calendar.

## ◆ getEpochDay()

virtual UDate icu::GregorianCalendar::getEpochDay | ( | UErrorCode & | status | ) |
| protected virtual

Return the day number with respect to the epoch.

January 1, 1970 (Gregorian) is day zero.

Parameters

  status | Fill-in parameter which receives the status of this operation.

Returns
  the day number with respect to the epoch.

Internal:
  Do not use. This API is for internal use only.

## ◆ getGregorianChange()

UDate icu::GregorianCalendar::getGregorianChange | ( | void |  | ) | const

Gets the Gregorian Calendar change date.

This is the point when the switch from Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October 15, 1582. Previous to this time and date will be Julian dates.

Returns
  The Gregorian cutover time for this calendar.

Stable:
  ICU 2.0

## ◆ getStaticClassID()

static UClassID icu::GregorianCalendar::getStaticClassID | ( | void |  | ) |
| static

Return the class ID for this class.

This is useful only for comparing to a return value from getDynamicClassID(). For example:

     Base* polymorphic_pointer = createPolymorphicObject();
     if (polymorphic_pointer->getDynamicClassID() ==
         Derived::getStaticClassID()) ...

Returns
  The class ID for all objects of this class.

Stable:
  ICU 2.0

## ◆ getType()

virtual const char * icu::GregorianCalendar::getType | ( |  | ) | const
| override virtual

Returns the calendar type name string for this Calendar object.

The returned string is the legacy ICU calendar attribute value, for example, "gregorian" or "japanese".

For more details see the Calendar::getType() documentation.

Returns
  legacy calendar type name string

Stable:
  ICU 49

Implements icu::Calendar.

## ◆ handleComputeFields()

virtual void icu::GregorianCalendar::handleComputeFields | ( | int32_t | julianDay,
|  | UErrorCode & | status
| ) |  |
| override protected virtual

Subclasses may override this method to compute several fields specific to each calendar system.

These are:

- ERA
- YEAR
- MONTH
- DAY_OF_MONTH
- DAY_OF_YEAR
- EXTENDED_YEAR

The GregorianCalendar implementation implements a calendar with the specified Julian/Gregorian cutover date.

Internal:
  Do not use. This API is for internal use only.

Reimplemented from icu::Calendar.

## ◆ handleComputeJulianDay()

virtual int32_t icu::GregorianCalendar::handleComputeJulianDay | ( | UCalendarDateFields | bestField | ) |
| override protected virtual

Subclasses may override this.

This method calls handleGetMonthLength() to obtain the calendar-specific month length.

Parameters

  bestField | which field to use to calculate the date

Returns
  julian day specified by calendar fields.

Internal:
  Do not use. This API is for internal use only.

Reimplemented from icu::Calendar.

## ◆ handleComputeMonthStart()

virtual int32_t icu::GregorianCalendar::handleComputeMonthStart | ( | int32_t | eyear,
|  | int32_t | month,
|  | UBool | useMonth
| ) |  | const
| override protected virtual

Return the Julian day number of day before the first day of the given month in the given extended year.

Subclasses should override this method to implement their calendar system.

Parameters

  eyear | the extended year
  month | the zero-based month, or 0 if useMonth is false
  useMonth | if false, compute the day before the first day of the given year, otherwise, compute the day before the first day of the given month

Returns
  the Julian day number of the day before the first day of the given month and year

Internal:
  Do not use. This API is for internal use only.

Implements icu::Calendar.

## ◆ handleGetExtendedYear()

virtual int32_t icu::GregorianCalendar::handleGetExtendedYear | ( |  | ) |
| override protected virtual

Return the extended year defined by the current fields.

This will use the UCAL_EXTENDED_YEAR field or the UCAL_YEAR and supra-year fields (such as UCAL_ERA) specific to the calendar system, depending on which set of fields is newer.

Returns
  the extended year

Internal:
  Do not use. This API is for internal use only.

Implements icu::Calendar.

## ◆ handleGetExtendedYearFromWeekFields()

virtual int32_t icu::GregorianCalendar::handleGetExtendedYearFromWeekFields | ( | int32_t | yearWoy,
|  | int32_t | woy
| ) |  |
| override protected virtual

Subclasses may override this to convert from week fields (YEAR_WOY and WEEK_OF_YEAR) to an extended year in the case where YEAR, EXTENDED_YEAR are not set.

The Gregorian implementation assumes a yearWoy in gregorian format, according to the current era.

Returns
  the extended year, UCAL_EXTENDED_YEAR

Internal:
  Do not use. This API is for internal use only.

Reimplemented from icu::Calendar.

## ◆ handleGetLimit()

virtual int32_t icu::GregorianCalendar::handleGetLimit | ( | UCalendarDateFields | field,
|  | ELimitType | limitType
| ) |  | const
| override protected virtual

Subclass API for defining limits of different types.

Subclasses must implement this method to return limits for the following fields:

    UCAL_ERA
    UCAL_YEAR
    UCAL_MONTH
    UCAL_WEEK_OF_YEAR
    UCAL_WEEK_OF_MONTH
    UCAL_DATE (DAY_OF_MONTH on Java)
    UCAL_DAY_OF_YEAR
    UCAL_DAY_OF_WEEK_IN_MONTH
    UCAL_YEAR_WOY
    UCAL_EXTENDED_YEAR

Parameters

  field | one of the above field numbers
  limitType | one of `MINIMUM`, `GREATEST_MINIMUM`, `LEAST_MAXIMUM`, or `MAXIMUM`

Internal:
  Do not use. This API is for internal use only.

Implements icu::Calendar.

## ◆ handleGetMonthLength()

virtual int32_t icu::GregorianCalendar::handleGetMonthLength | ( | int32_t | extendedYear,
|  | int32_t | month
| ) |  | const
| override protected virtual

Return the number of days in the given month of the given extended year of this calendar system.

Subclasses should override this method if they can provide a more correct or more efficient implementation than the default implementation in Calendar.

Internal:
  Do not use. This API is for internal use only.

Reimplemented from icu::Calendar.

## ◆ handleGetYearLength()

virtual int32_t icu::GregorianCalendar::handleGetYearLength | ( | int32_t | eyear | ) | const
| override protected virtual

Return the number of days in the given extended year of this calendar system.

Subclasses should override this method if they can provide a more correct or more efficient implementation than the default implementation in Calendar.

Stable:
  ICU 2.0

Reimplemented from icu::Calendar.

## ◆ haveDefaultCentury()

virtual UBool icu::GregorianCalendar::haveDefaultCentury | ( |  | ) | const
| override virtual

Returns
  true if this calendar has the notion of a default century

Internal:
  Do not use. This API is for internal use only.

Implements icu::Calendar.

## ◆ internalGetEra()

virtual int32_t icu::GregorianCalendar::internalGetEra | ( |  | ) | const
| protected virtual

Return the ERA.

We need a special method for this because the default ERA is AD, but a zero (unset) ERA is BC.

Returns
  the ERA.

Internal:
  Do not use. This API is for internal use only.

## ◆ isEquivalentTo()

virtual UBool icu::GregorianCalendar::isEquivalentTo | ( | const Calendar & | other | ) | const
| override virtual

Returns true if the given Calendar object is equivalent to this one.

Calendar override.

Parameters

  other | the Calendar to be compared with this Calendar

Stable:
  ICU 2.4

Reimplemented from icu::Calendar.

## ◆ isLeapYear()

UBool icu::GregorianCalendar::isLeapYear | ( | int32_t | year | ) | const

Return true if the given year is a leap year.

Determination of whether a year is a leap year is actually very complicated. We do something crude and mostly correct here, but for a real determination you need a lot of contextual information. For example, in Sweden, the change from Julian to Gregorian happened in a complex way resulting in missed leap years and double leap years between 1700 and 1753. Another example is that after the start of the Julian calendar in 45 B.C., the leap years did not regularize until 8 A.D. This method ignores these quirks, and pays attention only to the Julian onset date and the Gregorian cutover (which can be changed).

Parameters

  year | The given year.

Returns
  True if the given year is a leap year; false otherwise.

Stable:
  ICU 2.0

## ◆ monthLength() [1/2]

virtual int32_t icu::GregorianCalendar::monthLength | ( | int32_t | month | ) | const
| protected virtual

return the length of the given month.

Parameters

  month | the given month.

Returns
  the length of the given month.

Internal:
  Do not use. This API is for internal use only.

## ◆ monthLength() [2/2]

virtual int32_t icu::GregorianCalendar::monthLength | ( | int32_t | month,
|  | int32_t | year
| ) |  | const
| protected virtual

return the length of the month according to the given year.

Parameters

  month | the given month.
  year | the given year.

Returns
  the length of the month

Internal:
  Do not use. This API is for internal use only.

## ◆ operator=()

GregorianCalendar & icu::GregorianCalendar::operator= | ( | const GregorianCalendar & | right | ) |

Default assignment operator.

Parameters

  right | the object to be copied.

Stable:
  ICU 2.0

## ◆ roll() [1/2]

virtual void icu::GregorianCalendar::roll | ( | EDateFields | field,
|  | int32_t | amount,
|  | UErrorCode & | status
| ) |  |
| override virtual

(Overrides Calendar) Rolls up or down by the given amount in the specified field.

For more information, see the documentation for Calendar::roll().

Parameters

  field | The time field.
  amount | Indicates amount to roll.
  status | Output param set to success/failure code on exit. If any value previously set in the time field is invalid, this will be set to an error status.

Deprecated:
  ICU 2.6. Use roll(UCalendarDateFields field, int32_t amount, UErrorCode& status) instead.

Reimplemented from icu::Calendar.

## ◆ roll() [2/2]

virtual void icu::GregorianCalendar::roll | ( | UCalendarDateFields | field,
|  | int32_t | amount,
|  | UErrorCode & | status
| ) |  |
| override virtual

(Overrides Calendar) Rolls up or down by the given amount in the specified field.

For more information, see the documentation for Calendar::roll().

Parameters

  field | The time field.
  amount | Indicates amount to roll.
  status | Output param set to success/failure code on exit. If any value previously set in the time field is invalid, this will be set to an error status.

Stable:
  ICU 2.6.

Reimplemented from icu::Calendar.

## ◆ setGregorianChange()

void icu::GregorianCalendar::setGregorianChange | ( | UDate | date,
|  | UErrorCode & | success
| ) |  |

Sets the GregorianCalendar change date.

This is the point when the switch from Julian dates to Gregorian dates occurred. Default is 00:00:00 local time, October 15, 1582. Previous to this time and date will be Julian dates.

Parameters

  date | The given Gregorian cutover date.
  success | Output param set to success/failure code on exit.

Stable:
  ICU 2.0

## ◆ yearLength()

int32_t icu::GregorianCalendar::yearLength | ( | void |  | ) | const
| protected

return the length of the year field.

Returns
  the length of the year field

Internal:
  Do not use. This API is for internal use only.

The documentation for this class was generated from the following file:

- i18n/unicode/gregocal.h