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 net6.0, net8.0, netstandard2.0
Inheritance
CalendarSystem
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 net6.0, net8.0, 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 net6.0, net8.0, 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 net6.0, net8.0, 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 net6.0, net8.0, 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 net6.0, net8.0, 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 net6.0, net8.0, 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 net6.0, net8.0, 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 net6.0, net8.0, 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 net6.0, net8.0, 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 net6.0, net8.0, 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 net6.0, net8.0, 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 net6.0, net8.0, netstandard2.0
Declaration
public int MaxYear { get; }
Property Value
Type |
Description |
int |
The maximum valid year (inclusive) within this calendar. |
MinYear
Gets the minimum valid year (inclusive) within this calendar.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public int MinYear { get; }
Property Value
Type |
Description |
int |
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 net6.0, net8.0, 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
proposed by Ahmad Birashk with nested cycles of years determining which years are leap years.
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static CalendarSystem PersianArithmetic { get; }
Property Value
Type |
Description |
CalendarSystem |
A Persian calendar system using cycles-within-cycles of years to determine leap years. |
PersianAstronomical
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 net6.0, net8.0, netstandard2.0
Declaration
public static CalendarSystem PersianAstronomical { get; }
Property Value
Type |
Description |
CalendarSystem |
A Persian calendar system using astronomical calculations 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 net6.0, net8.0, 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 net6.0, net8.0, 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 net6.0, net8.0, 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
See Also
GetAbsoluteYear(int, 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 net6.0, net8.0, netstandard2.0
Declaration
public int GetAbsoluteYear(int yearOfEra, Era era)
Parameters
Type |
Name |
Description |
int |
yearOfEra |
The year within the era. |
Era |
era |
The era in which to consider the year |
Returns
Type |
Description |
int |
The absolute year represented by the specified year of era. |
Exceptions
GetDaysInMonth(int, int)
Returns the number of days in the given month within the given year.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public int GetDaysInMonth(int year, int month)
Parameters
Type |
Name |
Description |
int |
year |
The year in which to consider the month |
int |
month |
The month to determine the number of days in |
Returns
Type |
Description |
int |
The number of days in the given month and year. |
Exceptions
GetDaysInYear(int)
Returns the number of days in the given year.
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public int GetDaysInYear(int year)
Parameters
Type |
Name |
Description |
int |
year |
The year to determine the number of days in |
Returns
Type |
Description |
int |
The number of days in the given year. |
Exceptions
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 net6.0, net8.0, 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 net6.0, net8.0, 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 net6.0, net8.0, 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 |
int |
The maximum valid year in the given era. |
Exceptions
GetMinYearOfEra(Era)
Returns the minimum valid year-of-era in the given era.
Since 1.0.x
Availability net6.0, net8.0, 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 |
int |
The minimum valid year in the given era. |
Exceptions
GetMonthsInYear(int)
Returns the maximum valid month (inclusive) within this calendar in the given year.
Since 1.4.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public int GetMonthsInYear(int year)
Parameters
Type |
Name |
Description |
int |
year |
The year to consider. |
Returns
Type |
Description |
int |
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(int)
Returns whether or not the given year is a leap year in this calendar.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public bool IsLeapYear(int year)
Parameters
Type |
Name |
Description |
int |
year |
The year to consider. |
Returns
Type |
Description |
bool |
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 net6.0, net8.0, netstandard2.0
Declaration
public override string ToString()
Returns
Type |
Description |
string |
The ID of this calendar system. |
Overrides