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 net45, netstandard1.3
Inheritance
Object
CalendarSystem
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
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 net45, netstandard1.3
Declaration
public static CalendarSystem Badi { get; }
Property Value
Type |
Description |
CalendarSystem |
The Badíʿ calendar system. (The value returned is never null.) |
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 net45, netstandard1.3
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. (The value returned is never null.) |
Eras
Gets a read-only list of eras used in this calendar system.
Since 1.0.x
Availability net45, netstandard1.3
Declaration
public IList<Era> Eras { get; }
Property Value
Type |
Description |
IList<Era> |
A read-only list of eras used in this calendar system. (The value returned is never null.) |
Gregorian
Returns a Gregorian calendar system.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public static CalendarSystem Gregorian { get; }
Property Value
Type |
Description |
CalendarSystem |
A Gregorian calendar system. (The value returned is never null.) |
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 net45, netstandard1.3
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. (The value returned is never null.) |
See Also
HebrewScriptural
Returns a Hebrew calendar system using the scriptural month numbering.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public static CalendarSystem HebrewScriptural { get; }
Property Value
Type |
Description |
CalendarSystem |
A Hebrew calendar system using the scriptural month numbering. (The value returned is never null.) |
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 net45, netstandard1.3
Declaration
public string Id { get; }
Property Value
Type |
Description |
String |
The unique identifier for this calendar system. (The value returned is never null.) |
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 net45, netstandard1.3
Declaration
public static IEnumerable<string> Ids { get; }
Property Value
Type |
Description |
IEnumerable<String> |
The IDs of all calendar systems available within Noda Time. (The value returned is never null.) |
IslamicBcl
Returns an Islamic calendar system equivalent to the one used by the BCL HijriCalendar.
Since 1.4.x
Availability net45, netstandard1.3
Declaration
public static CalendarSystem IslamicBcl { get; }
Property Value
Type |
Description |
CalendarSystem |
An Islamic calendar system equivalent to the one used by the BCL. (The value returned is never null.) |
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 net45, netstandard1.3
Declaration
public static CalendarSystem Iso { get; }
Property Value
Type |
Description |
CalendarSystem |
The ISO calendar system. (The value returned is never null.) |
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 net45, netstandard1.3
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. (The value returned is never null.) |
MaxYear
Gets the maximum valid year (inclusive) within this calendar.
Since 1.0.x
Availability net45, netstandard1.3
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 net45, netstandard1.3
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 net45, netstandard1.3
Declaration
public string Name { get; }
Property Value
Type |
Description |
String |
The name of this calendar system. (The value returned is never null.) |
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 net45, netstandard1.3
Declaration
public static CalendarSystem PersianArithmetic { get; }
Property Value
Type |
Description |
CalendarSystem |
A Persian calendar system using astronomical calculations to determine leap years. (The value returned is never null.) |
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 net45, netstandard1.3
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. (The value returned is never null.) |
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 net45, netstandard1.3
Declaration
public static CalendarSystem PersianSimple { get; }
Property Value
Type |
Description |
CalendarSystem |
A Persian calendar system using a simple 33-year leap cycle. (The value returned is never null.) |
UmAlQura
Returns an Um Al Qura calendar system - an Islamic calendar system primarily used by
Saudi Arabia.
Since 2.0.x
Availability net45, netstandard1.3
Declaration
public static CalendarSystem UmAlQura { get; }
Property Value
Type |
Description |
CalendarSystem |
A calendar system for the Um Al Qura calendar. (The value returned is never null.) |
Methods
ForId(String)
Fetches a calendar system by its unique identifier. This provides full round-tripping of a calendar
system. It is not guaranteed that calling this method twice with the same identifier will return
identical references, but the references objects will be equal.
Since 1.0.x
Availability net45, netstandard1.3
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. (The value returned is never null.) |
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. |
ArgumentNullException |
id is null. |
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 net45, netstandard1.3
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. |
ArgumentNullException |
era is null. |
GetDaysInMonth(Int32, Int32)
Returns the number of days in the given month within the given year.
Since 1.0.x
Availability net45, netstandard1.3
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 net45, netstandard1.3
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 http://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 net45, netstandard1.3
Declaration
public static CalendarSystem GetHebrewCalendar(HebrewMonthNumbering monthNumbering)
Parameters
Returns
Type |
Description |
CalendarSystem |
A Hebrew calendar system for the given month numbering. (The value returned is never null.) |
GetIslamicCalendar(IslamicLeapYearPattern, IslamicEpoch)
Returns an Islamic, or Hijri, calendar system.
Since 1.0.x
Availability net45, netstandard1.3
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. (The value returned is never null.) |
GetMaxYearOfEra(Era)
Returns the maximum valid year-of-era in the given era.
Since 1.0.x
Availability net45, netstandard1.3
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. |
ArgumentNullException |
era is null. |
GetMinYearOfEra(Era)
Returns the minimum valid year-of-era in the given era.
Since 1.0.x
Availability net45, netstandard1.3
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 eraera. |
Exceptions
Type |
Condition |
ArgumentException |
era is not an era used in this calendar. |
ArgumentNullException |
era is null. |
GetMonthsInYear(Int32)
Returns the maximum valid month (inclusive) within this calendar in the given year.
Since 1.4.x
Availability net45, netstandard1.3
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 net45, netstandard1.3
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 net45, netstandard1.3
Declaration
public override string ToString()
Returns
Type |
Description |
String |
The ID of this calendar system. |
Overrides
System.Object.ToString()