Class CalendarSystem
A calendar system maps the non-calendar-specific "local time line" to human concepts
such as years, months and days.
Since 1.0.x
Availability netstandard2.0
Inheritance
Object
CalendarSystem
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Assembly: NodaTime.dll
Syntax
public sealed class CalendarSystem
Properties
Badi
Returns the Badíʿ (meaning "wondrous" or "unique") calendar, as described at https://en.wikipedia.org/wiki/Badi_calendar.
This is a purely solar calendar with years starting at the vernal equinox.
Since 2.3.x
Availability netstandard2.0
Declaration
public static CalendarSystem Badi { get; }
Property Value
Coptic
Returns a Coptic calendar system, which defines every fourth year as
leap, much like the Julian calendar. The year is broken down into 12 months,
each 30 days in length. An extra period at the end of the year is either 5
or 6 days in length. In this implementation, it is considered a 13th month.
Since 1.4.x
Availability netstandard2.0
Declaration
public static CalendarSystem Coptic { get; }
Property Value
Type |
Description |
CalendarSystem |
A suitable Coptic calendar reference; the same reference may be returned by several
calls as the object is immutable and thread-safe. |
Eras
Gets a read-only list of eras used in this calendar system.
Since 1.0.x
Availability netstandard2.0
Declaration
public IList<Era> Eras { get; }
Property Value
Type |
Description |
IList<Era> |
A read-only list of eras used in this calendar system. |
Gregorian
Returns a Gregorian calendar system.
Since 1.4.x
Availability netstandard2.0
Declaration
public static CalendarSystem Gregorian { get; }
Property Value
HebrewCivil
Returns a Hebrew calendar system using the civil month numbering,
equivalent to the one used by the BCL HebrewCalendar.
Since 1.4.x
Availability netstandard2.0
Declaration
public static CalendarSystem HebrewCivil { get; }
Property Value
Type |
Description |
CalendarSystem |
A Hebrew calendar system using the civil month numbering, equivalent to the one used by the
BCL. |
See Also
HebrewScriptural
Returns a Hebrew calendar system using the scriptural month numbering.
Since 1.4.x
Availability netstandard2.0
Declaration
public static CalendarSystem HebrewScriptural { get; }
Property Value
Type |
Description |
CalendarSystem |
A Hebrew calendar system using the scriptural month numbering. |
See Also
Id
Returns the unique identifier for this calendar system. This is provides full round-trip capability
using
ForId(String) to retrieve the calendar system from the identifier.
Since 1.0.x
Availability netstandard2.0
Declaration
public string Id { get; }
Property Value
Type |
Description |
String |
The unique identifier for this calendar system. |
Ids
Returns the IDs of all calendar systems available within Noda Time. The order of the keys is not guaranteed.
Since 1.0.x
Availability netstandard2.0
Declaration
public static IEnumerable<string> Ids { get; }
Property Value
Type |
Description |
IEnumerable<String> |
The IDs of all calendar systems available within Noda Time. |
IslamicBcl
Returns an Islamic calendar system equivalent to the one used by the BCL HijriCalendar.
Since 1.4.x
Availability netstandard2.0
Declaration
public static CalendarSystem IslamicBcl { get; }
Property Value
Type |
Description |
CalendarSystem |
An Islamic calendar system equivalent to the one used by the BCL. |
See Also
Iso
Returns a calendar system that follows the rules of the ISO-8601 standard,
which is compatible with Gregorian for all modern dates.
Since 1.0.x
Availability netstandard2.0
Declaration
public static CalendarSystem Iso { get; }
Property Value
Julian
Returns a pure proleptic Julian calendar system, which defines every
fourth year as a leap year. This implementation follows the leap year rule
strictly, even for dates before 8 CE, where leap years were actually
irregular.
Since 1.4.x
Availability netstandard2.0
Declaration
public static CalendarSystem Julian { get; }
Property Value
Type |
Description |
CalendarSystem |
A suitable Julian calendar reference; the same reference may be returned by several
calls as the object is immutable and thread-safe. |
MaxYear
Gets the maximum valid year (inclusive) within this calendar.
Since 1.0.x
Availability netstandard2.0
Declaration
public int MaxYear { get; }
Property Value
Type |
Description |
Int32 |
The maximum valid year (inclusive) within this calendar. |
MinYear
Gets the minimum valid year (inclusive) within this calendar.
Since 1.0.x
Availability netstandard2.0
Declaration
public int MinYear { get; }
Property Value
Type |
Description |
Int32 |
The minimum valid year (inclusive) within this calendar. |
Name
Returns the name of this calendar system. Each kind of calendar system has a unique name, but this
does not usually provide enough information for round-tripping. (For example, the name of an
Islamic calendar system does not indicate which kind of leap cycle it uses.)
Since 1.0.x
Availability netstandard2.0
Declaration
public string Name { get; }
Property Value
Type |
Description |
String |
The name of this calendar system. |
PersianArithmetic
Returns a Persian (also known as Solar Hijri) calendar system implementing the behaviour of the
BCL PersianCalendar
from .NET 4.6 onwards (and Windows 10), and the astronomical
system described in Wikipedia and Calendrical Calculations.
Since 2.0.x
Availability netstandard2.0
Declaration
public static CalendarSystem PersianArithmetic { get; }
Property Value
Type |
Description |
CalendarSystem |
A Persian calendar system using astronomical calculations to determine leap years. |
PersianAstronomical
Returns a Persian (also known as Solar Hijri) calendar system implementing the behaviour
proposed by Ahmad Birashk with nested cycles of years determining which years are leap years.
Since 2.0.x
Availability netstandard2.0
Declaration
public static CalendarSystem PersianAstronomical { get; }
Property Value
Type |
Description |
CalendarSystem |
A Persian calendar system using cycles-within-cycles of years to determine leap years. |
PersianSimple
Returns a Persian (also known as Solar Hijri) calendar system implementing the behaviour of the
BCL PersianCalendar
before .NET 4.6, and the sole Persian calendar in Noda Time 1.3.
Since 1.4.x
Availability netstandard2.0
Declaration
public static CalendarSystem PersianSimple { get; }
Property Value
Type |
Description |
CalendarSystem |
A Persian calendar system using a simple 33-year leap cycle. |
UmAlQura
Returns an Um Al Qura calendar system - an Islamic calendar system primarily used by
Saudi Arabia.
Since 2.0.x
Availability netstandard2.0
Declaration
public static CalendarSystem UmAlQura { get; }
Property Value
Type |
Description |
CalendarSystem |
A calendar system for the Um Al Qura calendar. |
Methods
ForId(String)
Fetches a calendar system by its unique identifier. This provides full round-tripping of a calendar
system. This method will always return the same reference for the same ID.
Since 1.0.x
Availability netstandard2.0
Declaration
public static CalendarSystem ForId(string id)
Parameters
Type |
Name |
Description |
String |
id |
The ID of the calendar system. This is case-sensitive. |
Returns
Type |
Description |
CalendarSystem |
The calendar system with the given ID. |
Exceptions
Type |
Condition |
System.Collections.Generic.KeyNotFoundException |
No calendar system for the specified ID can be found. |
System.NotSupportedException |
The calendar system with the specified ID is known, but not supported on this platform. |
See Also
GetAbsoluteYear(Int32, Era)
Returns the "absolute year" (the one used throughout most of the API, without respect to eras)
from a year-of-era and an era.
Since 1.0.x
Availability netstandard2.0
Declaration
public int GetAbsoluteYear(int yearOfEra, Era era)
Parameters
Type |
Name |
Description |
Int32 |
yearOfEra |
The year within the era. |
Era |
era |
The era in which to consider the year |
Returns
Type |
Description |
Int32 |
The absolute year represented by the specified year of era. |
Exceptions
Type |
Condition |
ArgumentOutOfRangeException |
yearOfEra is out of the range of years for the given era. |
ArgumentException |
era is not an era used in this calendar. |
GetDaysInMonth(Int32, Int32)
Returns the number of days in the given month within the given year.
Since 1.0.x
Availability netstandard2.0
Declaration
public int GetDaysInMonth(int year, int month)
Parameters
Type |
Name |
Description |
Int32 |
year |
The year in which to consider the month |
Int32 |
month |
The month to determine the number of days in |
Returns
Type |
Description |
Int32 |
The number of days in the given month and year. |
Exceptions
Type |
Condition |
ArgumentOutOfRangeException |
The given year / month combination
is invalid for this calendar. |
GetDaysInYear(Int32)
Returns the number of days in the given year.
Since 2.0.x
Availability netstandard2.0
Declaration
public int GetDaysInYear(int year)
Parameters
Type |
Name |
Description |
Int32 |
year |
The year to determine the number of days in |
Returns
Type |
Description |
Int32 |
The number of days in the given year. |
Exceptions
Type |
Condition |
ArgumentOutOfRangeException |
The given year is invalid for this calendar. |
GetHebrewCalendar(HebrewMonthNumbering)
Returns a Hebrew calendar, as described at https://en.wikipedia.org/wiki/Hebrew_calendar. This is a
purely mathematical calculator, applied proleptically to the period where the real calendar was observational.
Since 1.3.x
Availability netstandard2.0
Declaration
public static CalendarSystem GetHebrewCalendar(HebrewMonthNumbering monthNumbering)
Parameters
Returns
Type |
Description |
CalendarSystem |
A Hebrew calendar system for the given month numbering. |
GetIslamicCalendar(IslamicLeapYearPattern, IslamicEpoch)
Returns an Islamic, or Hijri, calendar system.
Since 1.0.x
Availability netstandard2.0
Declaration
public static CalendarSystem GetIslamicCalendar(IslamicLeapYearPattern leapYearPattern, IslamicEpoch epoch)
Parameters
Type |
Name |
Description |
IslamicLeapYearPattern |
leapYearPattern |
The pattern of years in the 30-year cycle to consider as leap years |
IslamicEpoch |
epoch |
The kind of epoch to use (astronomical or civil) |
Returns
Type |
Description |
CalendarSystem |
A suitable Islamic calendar reference; the same reference may be returned by several
calls as the object is immutable and thread-safe. |
GetMaxYearOfEra(Era)
Returns the maximum valid year-of-era in the given era.
Since 1.0.x
Availability netstandard2.0
Declaration
public int GetMaxYearOfEra(Era era)
Parameters
Type |
Name |
Description |
Era |
era |
The era in which to find the greatest year |
Returns
Type |
Description |
Int32 |
The maximum valid year in the given era. |
Exceptions
Type |
Condition |
ArgumentException |
era is not an era used in this calendar. |
GetMinYearOfEra(Era)
Returns the minimum valid year-of-era in the given era.
Since 1.0.x
Availability netstandard2.0
Declaration
public int GetMinYearOfEra(Era era)
Parameters
Type |
Name |
Description |
Era |
era |
The era in which to find the greatest year |
Returns
Type |
Description |
Int32 |
The minimum valid year in the given era. |
Exceptions
Type |
Condition |
ArgumentException |
era is not an era used in this calendar. |
GetMonthsInYear(Int32)
Returns the maximum valid month (inclusive) within this calendar in the given year.
Since 1.4.x
Availability netstandard2.0
Declaration
public int GetMonthsInYear(int year)
Parameters
Type |
Name |
Description |
Int32 |
year |
The year to consider. |
Returns
Type |
Description |
Int32 |
The maximum month number within the given year. |
Exceptions
Type |
Condition |
ArgumentOutOfRangeException |
The given year is invalid for this calendar.
Note that some implementations may return a month rather than throw this exception (for example, if all
years have the same number of months in this calendar system). Failure to throw an exception should not be
treated as an indication that the year is valid. |
IsLeapYear(Int32)
Returns whether or not the given year is a leap year in this calendar.
Since 1.0.x
Availability netstandard2.0
Declaration
public bool IsLeapYear(int year)
Parameters
Type |
Name |
Description |
Int32 |
year |
The year to consider. |
Returns
Type |
Description |
Boolean |
True if the given year is a leap year; false otherwise. |
Exceptions
Type |
Condition |
ArgumentOutOfRangeException |
The given year is invalid for this calendar.
Note that some implementations may return a value rather than throw this exception. Failure to throw an
exception should not be treated as an indication that the year is valid. |
ToString()
Converts this calendar system to text by simply returning its unique ID.
Since 1.0.x
Availability netstandard2.0
Declaration
public override string ToString()
Returns
Type |
Description |
String |
The ID of this calendar system. |
Overrides
System.Object.ToString()