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 net35-Client, PCL
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
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 net35-Client, PCL
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
Returns a read-only list of eras used in this calendar system.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public IList<Era> Eras { get; }
Property Value
| Type |
Description |
| IList<Era> |
|
Gregorian
Returns a Gregorian calendar system with at least 4 days in the first week of a week-year.
Since 1.4.x
Availability net35-Client, PCL
Declaration
public static CalendarSystem Gregorian { get; }
Property Value
| Type |
Description |
| CalendarSystem |
A Gregorian calendar system with at least 4 days in the first week of a week-year. (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 net35-Client, PCL
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 net35-Client, PCL
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 net35-Client, PCL
Declaration
public string Id { get; }
Property Value
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 net35-Client, PCL
Declaration
public static IEnumerable<string> Ids { get; }
Property Value
| Type |
Description |
| IEnumerable<String> |
|
IslamicBcl
Returns an Islamic calendar system equivalent to the one used by the BCL HijriCalendar.
Since 1.4.x
Availability net35-Client, PCL
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 net35-Client, PCL
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 net35-Client, PCL
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
The maximum valid year (inclusive) within this calendar.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public int MaxYear { get; }
Property Value
MinYear
The minimum valid year (inclusive) within this calendar.
Since 1.0.x
Availability net35-Client, PCL
Declaration
public int MinYear { get; }
Property Value
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, and other calendars
specify the minimum number of days in the first week of a year.)
Since 1.0.x
Availability net35-Client, PCL
Declaration
public string Name { get; }
Property Value
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 net35-Client, PCL
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.) |
UsesIsoDayOfWeek
Returns whether the day-of-week field refers to ISO days. If true, types such as
LocalDateTime
can use the
IsoDayOfWeek property to avoid using magic numbers.
This defaults to true, but can be overridden by specific calendars.
Since 1.0.x
Availability net35-Client, PCL
Declaration
[Obsolete("Removed in 2.0 as all calendar systems are deemed to use ISO days.")]
public bool UsesIsoDayOfWeek { get; }
Property Value
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 net35-Client, PCL
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. |
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 net35-Client, PCL
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. |
GetCopticCalendar(Int32)
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.0.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use the Coptic property, then WeekYearRules for specific week-year rules for compatibility with 2.0.")]
public static CalendarSystem GetCopticCalendar(int minDaysInFirstWeek)
Parameters
| Type |
Name |
Description |
| Int32 |
minDaysInFirstWeek |
The minimum number of days in the first week of the year.
When computing the WeekOfWeekYear and WeekYear properties of a particular date, this is
used to decide at what point the week year changes. |
Returns
| 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. |
GetDaysInMonth(Int32, Int32)
Returns the number of days in the given month within the given year.
Since 1.0.x
Availability net35-Client, PCL
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. |
GetGregorianCalendar(Int32)
Returns a pure proleptic Gregorian calendar system, which defines every
fourth year as leap, unless the year is divisible by 100 and not by 400.
This improves upon the Julian calendar leap year rule.
Since 1.0.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use the Gregorian property, then WeekYearRules for specific week-year rules for compatibility with 2.0.")]
public static CalendarSystem GetGregorianCalendar(int minDaysInFirstWeek)
Parameters
| Type |
Name |
Description |
| Int32 |
minDaysInFirstWeek |
The minimum number of days in the first week of the year.
When computing the WeekOfWeekYear and WeekYear properties of a particular date, this is
used to decide at what point the week year changes. |
Returns
| Type |
Description |
| CalendarSystem |
A suitable Gregorian calendar reference; the same reference may be returned by several
calls as the object is immutable and thread-safe. |
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 net35-Client, PCL
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 net35-Client, PCL
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. |
GetJulianCalendar(Int32)
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.0.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use the Julian property, then WeekYearRules for specific week-year rules for compatibility with 2.0.")]
public static CalendarSystem GetJulianCalendar(int minDaysInFirstWeek)
Parameters
| Type |
Name |
Description |
| Int32 |
minDaysInFirstWeek |
The minimum number of days in the first week of the year.
When computing the WeekOfWeekYear and WeekYear properties of a particular date, this is
used to decide at what point the week year changes. |
Returns
| 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. |
GetMaxMonth(Int32)
The maximum valid month (inclusive) within this calendar in the given year. It is assumed that
all calendars start with month 1 and go up to this month number in any valid year.
Since 1.0.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use GetMonthsInYear for compatibility with 2.0")]
public int GetMaxMonth(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. |
GetMaxYearOfEra(Era)
Returns the maximum valid year-of-era in the given era.
Since 1.0.x
Availability net35-Client, PCL
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 net35-Client, PCL
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)
The number of months within this calendar in the given year. It is assumed that
all calendars start with month 1 and go up to this month number in any valid year.
Since 1.4.x
Availability net35-Client, PCL
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. |
GetPersianCalendar()
Returns a Persian (also known as Solar Hijri) calendar system. This is the main calendar in Iran
and Afghanistan, and is also used in some other countries where Persian is spoken.
Since 1.3.x
Availability net35-Client, PCL
Declaration
[Obsolete("Use the PersianSimple property for compatibility with 2.0.")]
public static CalendarSystem GetPersianCalendar()
Returns
IsLeapYear(Int32)
Returns whether or not the given year is a leap year in this calendar.
Since 1.0.x
Availability net35-Client, PCL
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 net35-Client, PCL
Declaration
public override string ToString()
Returns
| Type |
Description |
| String |
The ID of this calendar system. |
Overrides
System.Object.ToString()