ICU 73.2  73.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:
icu::Calendar icu::UObject icu::UMemory

Public Types

enum  EEras { BC, AD }
 Useful constants for GregorianCalendar and TimeZone. 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.
GregorianCalendaroperator= (const GregorianCalendar &right)
 Default assignment operator.
virtual GregorianCalendarclone () 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

Static Public Member Functions

static UClassID getStaticClassID (void)
 Return the class ID for this class.

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 (int32_t year) const
 return the length of the given year.
int32_t yearLength (void) const
 return the length of the year field.
void pinDayOfMonth (void)
 After adjustments such as add(MONTH), add(YEAR), we don't want the month to jump around.
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.

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 53. 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
Stable:
ICU 2.0

Definition at line 153 of file gregocal.h.


Member Enumeration Documentation

Useful constants for GregorianCalendar and TimeZone.

Stable:
ICU 2.0

Definition at line 160 of file gregocal.h.


Constructor & Destructor Documentation

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

Parameters:
successIndicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.
Stable:
ICU 2.0

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:
zoneToAdoptThe given timezone.
successIndicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.
Stable:
ICU 2.0

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

Parameters:
zoneThe given timezone.
successIndicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.
Stable:
ICU 2.0
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:
aLocaleThe given locale.
successIndicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.
Stable:
ICU 2.0
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:
zoneToAdoptThe given timezone.
aLocaleThe given locale.
successIndicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.
Stable:
ICU 2.0
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:
zoneThe given timezone.
aLocaleThe given locale.
successIndicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.
Stable:
ICU 2.0
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:
yearThe value used to set the YEAR time field in the calendar.
monthThe value used to set the MONTH time field in the calendar. Month value is 0-based. e.g., 0 for January.
dateThe value used to set the DATE time field in the calendar.
successIndicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.
Stable:
ICU 2.0
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:
yearThe value used to set the YEAR time field in the calendar.
monthThe value used to set the MONTH time field in the calendar. Month value is 0-based. e.g., 0 for January.
dateThe value used to set the DATE time field in the calendar.
hourThe value used to set the HOUR_OF_DAY time field in the calendar.
minuteThe value used to set the MINUTE time field in the calendar.
successIndicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.
Stable:
ICU 2.0
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:
yearThe value used to set the YEAR time field in the calendar.
monthThe value used to set the MONTH time field in the calendar. Month value is 0-based. e.g., 0 for January.
dateThe value used to set the DATE time field in the calendar.
hourThe value used to set the HOUR_OF_DAY time field in the calendar.
minuteThe value used to set the MINUTE time field in the calendar.
secondThe value used to set the SECOND time field in the calendar.
successIndicates the status of GregorianCalendar object construction. Returns U_ZERO_ERROR if constructed successfully.
Stable:
ICU 2.0

Destructor.

Stable:
ICU 2.0

Copy constructor.

Parameters:
sourcethe object to be copied.
Stable:
ICU 2.0

Member Function Documentation

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.

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.

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.

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:
fieldthe time field.
statusreturns 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.

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:
fieldthe time field.
Returns:
the minimum value that this field could have, given the current date.
Deprecated:
ICU 2.6. Use getActualMinimum(UCalendarDateFields field) instead.
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:
fieldthe 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)

Reimplemented from icu::Calendar.

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:
fieldthe time field.
statuserror result.
Returns:
the minimum value that this field could have, given the current date.
Stable:
ICU 3.0

Reimplemented from icu::Calendar.

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.

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:
statusFill-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.

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

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
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.

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.

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:
bestFieldwhich 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.

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:
eyearthe extended year
monththe zero-based month, or 0 if useMonth is false
useMonthif 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.

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.

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.

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:
fieldone of the above field numbers
limitTypeone of MINIMUM, GREATEST_MINIMUM, LEAST_MAXIMUM, or MAXIMUM
Internal:
Do not use. This API is for internal use only.

Implements icu::Calendar.

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.

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.

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.

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.
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:
otherthe Calendar to be compared with this Calendar
Stable:
ICU 2.4

Reimplemented from icu::Calendar.

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:
yearThe given year.
Returns:
True if the given year is a leap year; false otherwise.
Stable:
ICU 2.0
virtual int32_t icu::GregorianCalendar::monthLength ( int32_t  month) const [protected, virtual]

return the length of the given month.

Parameters:
monththe given month.
Returns:
the length of the given month.
Internal:
Do not use. This API is for internal use only.
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:
monththe given month.
yearthe given year.
Returns:
the length of the month
Internal:
Do not use. This API is for internal use only.
GregorianCalendar& icu::GregorianCalendar::operator= ( const GregorianCalendar right)

Default assignment operator.

Parameters:
rightthe object to be copied.
Stable:
ICU 2.0
void icu::GregorianCalendar::pinDayOfMonth ( void  ) [protected]

After adjustments such as add(MONTH), add(YEAR), we don't want the month to jump around.

E.g., we don't want Jan 31 + 1 month to go to Mar 3, we want it to go to Feb 28. Adjustments which might run into this problem call this method to retain the proper month.

Internal:
Do not use. This API is for internal use only.
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:
fieldThe time field.
amountIndicates amount to roll.
statusOutput 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.

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:
fieldThe time field.
amountIndicates amount to roll.
statusOutput 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.

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:
dateThe given Gregorian cutover date.
successOutput param set to success/failure code on exit.
Stable:
ICU 2.0
int32_t icu::GregorianCalendar::yearLength ( int32_t  year) const [protected]

return the length of the given year.

Parameters:
yearthe given year.
Returns:
the length of the given year.
Internal:
Do not use. This API is for internal use only.
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: