[Serializable] |
A leap year in the Gregorian calendar is defined as a year that is evenly divisible by four, except if it is divisible by 100; however, years that are divisible by 400 are leap years. For example, the year 1900 was not a leap year, but the year 2000 was. A common year has 365 days and a leap year has 366 days.
The Gregorian calendar has 12 months with 28 to 31 days each: January (31 days), February (28 or 29 days), March (31 days), April (30 days), May (31 days), June (30 days), July (31 days), August (31 days), September (30 days), October (31 days), November (30 days), and December (31 days). February has 29 days during leap years and 28 during common years.
If the GregorianCalendar is selected in DateTimeFormatInfo.Calendar, DateTimeFormatInfo ignores punctuation in abbreviated era names; that is, "A.D." is equivalent to "AD".
ctor #1 | Overloaded:.ctor() Default constructor. This constructor is called by derived class constructors to initialize state in this type.Initializes a new instance of the GregorianCalendar class using the default GregorianCalendarTypes value. |
ctor #2 | Overloaded:.ctor(GregorianCalendarTypes type) Initializes a new instance of the GregorianCalendar class using the specified GregorianCalendarTypes value. |
ADEra | Represents the current era. This field is constant. |
CalendarType | Read-write Gets or sets the GregorianCalendarTypes value that denotes the version of the current GregorianCalendar. |
Eras | Read-only Overridden: Gets the list of eras in the GregorianCalendar. |
TwoDigitYearMax | Read-write Overridden: Gets or sets the last year of a 100-year range that can be represented by a 2-digit year. |
AddDays (inherited from System.Globalization.Calendar) |
See base class member description: System.Globalization.Calendar.AddDays Returns a DateTime that is the specified number of days away from the specified DateTime. |
AddHours (inherited from System.Globalization.Calendar) |
See base class member description: System.Globalization.Calendar.AddHours Returns a DateTime that is the specified number of hours away from the specified DateTime. |
AddMilliseconds (inherited from System.Globalization.Calendar) |
See base class member description: System.Globalization.Calendar.AddMilliseconds Returns a DateTime that is the specified number of milliseconds away from the specified DateTime. |
AddMinutes (inherited from System.Globalization.Calendar) |
See base class member description: System.Globalization.Calendar.AddMinutes Returns a DateTime that is the specified number of minutes away from the specified DateTime. |
AddMonths | Overridden: Returns a DateTime that is the specified number of months away from the specified DateTime. |
AddSeconds (inherited from System.Globalization.Calendar) |
See base class member description: System.Globalization.Calendar.AddSeconds Returns a DateTime that is the specified number of seconds away from the specified DateTime. |
AddWeeks | Overridden: Returns a DateTime that is the specified number of weeks away from the specified DateTime. |
AddYears | Overridden: Returns a DateTime that is the specified number of years away from the specified DateTime. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetDayOfMonth | Overridden: Returns the day of the month in the specified DateTime. |
GetDayOfWeek | Overridden: Returns the day of the week in the specified DateTime. |
GetDayOfYear | Overridden: Returns the day of the year in the specified DateTime. |
GetDaysInMonth (inherited from System.Globalization.Calendar) |
Overloaded:GetDaysInMonth(int year, int month) See base class member description: System.Globalization.Calendar.GetDaysInMonthReturns the number of days in the specified month in the specified year in the current era. |
GetDaysInMonth | Overloaded:GetDaysInMonth(int year, int month, int era) Overridden: Returns the number of days in the specified month in the specified year in the specified era. |
GetDaysInYear (inherited from System.Globalization.Calendar) |
Overloaded:GetDaysInYear(int year) See base class member description: System.Globalization.Calendar.GetDaysInYearReturns the number of days in the specified year in the current era. |
GetDaysInYear | Overloaded:GetDaysInYear(int year, int era) Overridden: Returns the number of days in the specified year in the specified era. |
GetEra | Overridden: Returns the era in the specified DateTime. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetHour (inherited from System.Globalization.Calendar) |
See base class member description: System.Globalization.Calendar.GetHour Returns the hours value in the specified DateTime. |
GetMilliseconds (inherited from System.Globalization.Calendar) |
See base class member description: System.Globalization.Calendar.GetMilliseconds Returns the milliseconds value in the specified DateTime. |
GetMinute (inherited from System.Globalization.Calendar) |
See base class member description: System.Globalization.Calendar.GetMinute Returns the minutes value in the specified DateTime. |
GetMonth | Overridden: Returns the month in the specified DateTime. |
GetMonthsInYear (inherited from System.Globalization.Calendar) |
Overloaded:GetMonthsInYear(int year) See base class member description: System.Globalization.Calendar.GetMonthsInYearReturns the number of months in the specified year in the current era. |
GetMonthsInYear | Overloaded:GetMonthsInYear(int year, int era) Overridden: Returns the number of months in the specified year in the specified era. |
GetSecond (inherited from System.Globalization.Calendar) |
See base class member description: System.Globalization.Calendar.GetSecond Returns the seconds value in the specified DateTime. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
GetWeekOfYear (inherited from System.Globalization.Calendar) |
See base class member description: System.Globalization.Calendar.GetWeekOfYear Returns the week of the year that includes the date in the specified DateTime. |
GetYear | Overridden: Returns the year in the specified DateTime. |
IsLeapDay (inherited from System.Globalization.Calendar) |
Overloaded:IsLeapDay(int year, int month, int day) See base class member description: System.Globalization.Calendar.IsLeapDayDetermines whether the specified date in the current era is a leap day. |
IsLeapDay | Overloaded:IsLeapDay(int year, int month, int day, int era) Overridden: Determines whether the specified date in the specified era is a leap day. |
IsLeapMonth (inherited from System.Globalization.Calendar) |
Overloaded:IsLeapMonth(int year, int month) See base class member description: System.Globalization.Calendar.IsLeapMonthDetermines whether the specified month in the specified year in the current era is a leap month. |
IsLeapMonth | Overloaded:IsLeapMonth(int year, int month, int era) Overridden: Determines whether the specified month in the specified year in the specified era is a leap month. |
IsLeapYear (inherited from System.Globalization.Calendar) |
Overloaded:IsLeapYear(int year) See base class member description: System.Globalization.Calendar.IsLeapYearDetermines whether the specified year in the current era is a leap year. |
IsLeapYear | Overloaded:IsLeapYear(int year, int era) Overridden: Determines whether the specified year in the specified era is a leap year. |
ToDateTime (inherited from System.Globalization.Calendar) |
Overloaded:ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond) See base class member description: System.Globalization.Calendar.ToDateTimeReturns a DateTime that is set to the specified date and time in the current era. |
ToDateTime | Overloaded:ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era) Overridden: Returns a DateTime that is set to the specified date and time in the specified era. |
ToFourDigitYear | Overridden: Converts the specified two-digit year to a four-digit year by using the GregorianCalendar.TwoDigitYearMax property to determine the appropriate century. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public GregorianCalendar(); |
public GregorianCalendar(GregorianCalendar( |
type
public const int ADEra;
|
public virtual GregorianCalendarTypes CalendarType {get; set;}
|
public override int[] Eras {get;}
|
public override int TwoDigitYearMax {get; set;}
|
The initial value of this property is derived from the settings in Regional and Language Options (or Regional Options or Regional Settings) in Control Panel in Windows. However, that information can change during the life of the AppDomain. The GregorianCalendar class does not detect changes in the system settings automatically.
time
days
Exception Type | Condition |
---|---|
ArgumentException | The resulting DateTime is outside the supported range. |
time
hours
Exception Type | Condition |
---|---|
ArgumentException | The resulting DateTime is outside the supported range. |
time
milliseconds
Exception Type | Condition |
---|---|
ArgumentException | The resulting DateTime is outside the supported range. |
time
minutes
Exception Type | Condition |
---|---|
ArgumentException | The resulting DateTime is outside the supported range. |
time
months
Exception Type | Condition |
---|---|
ArgumentException | The resulting DateTime is outside the supported range. |
ArgumentOutOfRangeException | months is less than -120000. -or- months is greater than 120000. |
For example, if the specified month is October, which has 31 days, the specified day is the 31st day of that month, and the value of the months parameter is 6, the resulting year is one more than the specified year, the resulting month is April, and the resulting day is the 30th day, which is the last day in April.
If the value of the months parameter is negative, the resulting DateTime is earlier than the specified DateTime.
time
seconds
Exception Type | Condition |
---|---|
ArgumentException | The resulting DateTime is outside the supported range. |
time
weeks
Exception Type | Condition |
---|---|
ArgumentException | The resulting DateTime is outside the supported range. |
In all .NET Framework classes derived from the Calendar class, a week is defined as seven days, except the first and last weeks of the year which might have less than seven days.
time
years
Exception Type | Condition |
---|---|
ArgumentException | The resulting DateTime is outside the supported range. |
For example, February has 28 days, except during leap years when it has 29 days. If the specified date is the 29th day of February in a leap year and the value of years is 1, the resulting date will be the 28th day of February in the following year.
If years is negative, the resulting DateTime is earlier than the specified DateTime.
~GregorianCalendar(); |
time
time
time
year
month
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. -or- month is outside the range supported by the calendar. |
year
month
era
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | year is outside the range supported by the calendar. -or- month is outside the range supported by the calendar. |
ArgumentException | era is outside the range supported by the calendar. |
year
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. |
year
era
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | year is outside the range supported by the calendar. |
ArgumentException | era is outside the range supported by the calendar. |
time
public virtual int GetHashCode(); |
time
time
time
time
year
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. |
year
era
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. -or- era is outside the range supported by the calendar. |
time
public Type GetType(); |
public virtual int GetWeekOfYear( |
time
rule
firstDayOfWeek
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | firstDayOfWeek is outside the range supported by the calendar. -or- rule is not a valid CalendarWeekRule value. |
DateTimeFormatInfo.CalendarWeekRule of CultureInfo.DateTimeFormat contains the default CalendarWeekRule value that defines a calendar week for a specific culture.
This method can also be used to determine the number of weeks in the year by setting time to the last day of the year.
time
year
month
day
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. -or- month is outside the range supported by the calendar. -or- day is outside the range supported by the calendar. |
A leap day is a day that occurs only in a leap year. For example, in the Gregorian calendar, the 29th day of February is the only leap day.
year
month
day
era
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. -or- month is outside the range supported by the calendar. -or- day is outside the range supported by the calendar. -or- era is outside the range supported by the calendar. |
A leap day is a day that occurs only in a leap year. In the Gregorian calendar, the 29th day of February is the only leap day.
year
month
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. -or- month is outside the range supported by the calendar. |
A leap month is an entire month that occurs only in a leap year. For example, in the Hebrew calendar, Veadar is the only leap month.
year
month
era
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. -or- month is outside the range supported by the calendar. -or- era is outside the range supported by the calendar. |
A leap month is an entire month that occurs only in a leap year. The Gregorian calendar does not have any leap months.
year
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. |
year
era
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. -or- era is outside the range supported by the calendar. |
protected object MemberwiseClone(); |
public virtual DateTime ToDateTime( |
year
month
day
hour
minute
second
millisecond
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. -or- month is outside the range supported by the calendar. -or- day is outside the range supported by the calendar. -or- hour is less than zero or greater than 23. -or- minute is less than zero or greater than 59. -or- second is less than zero or greater than 59. -or- millisecond is less than zero or greater than 999. |
public override DateTime ToDateTime( |
year
month
day
hour
minute
second
millisecond
era
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. -or- month is outside the range supported by the calendar. -or- day is outside the range supported by the calendar. -or- hour is less than zero or greater than 23. -or- minute is less than zero or greater than 59. -or- second is less than zero or greater than 59. -or- millisecond is less than zero or greater than 999. -or- era is outside the range supported by the calendar. |
year
Exception Type | Condition |
---|---|
ArgumentException | year is outside the range supported by the calendar. |
public virtual string ToString(); |