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
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 abstract class CalendarSystem
Properties
Eras
Returns a read-only list of eras supported by this calendar system.
Since 1.0.x
Availability net35-Client
Declaration
public IList<Era> Eras { get; }
Property Value
Type |
Description |
IList<Era> |
|
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
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
Declaration
public static IEnumerable<string> Ids { get; }
Property Value
Type |
Description |
IEnumerable<String> |
|
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
Declaration
public static CalendarSystem Iso { get; }
Property Value
MaxYear
The maximum valid year (inclusive) within this calendar.
Since 1.0.x
Availability net35-Client
Declaration
public int MaxYear { get; }
Property Value
MinYear
The minimum valid year (inclusive) within this calendar.
Since 1.0.x
Availability net35-Client
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
Declaration
public string Name { get; }
Property Value
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
Declaration
public virtual 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
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
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 |
System.ArgumentNullException |
era is null |
ArgumentOutOfRangeException |
yearOfEra is out of the range of years for the given era |
ArgumentException |
era is not an era of this calendar |
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
Declaration
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
Declaration
public abstract 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
Declaration
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. |
GetIslamicCalendar(IslamicLeapYearPattern, IslamicEpoch)
Returns an Islamic, or Hijri, calendar system.
Since 1.0.x
Availability net35-Client
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
Declaration
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
Declaration
public abstract 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
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 |
System.ArgumentNullException |
era is null |
ArgumentException |
era is not an era of this calendar |
GetMinYearOfEra(Era)
Returns the minimum valid year-of-era in the given era.
Since 1.0.x
Availability net35-Client
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 |
System.ArgumentNullException |
era is null |
ArgumentException |
era is not an era of this calendar |
IsLeapYear(Int32)
Returns whether or not the given year is a leap year in this calendar.
Since 1.0.x
Availability net35-Client
Declaration
public abstract 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
Declaration
public override string ToString()
Returns
Type |
Description |
String |
The ID of this calendar system. |
Overrides
System.Object.ToString()