Calendar

Trait Calendar 

Source
pub trait Calendar: UnstableSealed {
    type DateInner: Eq + Copy + PartialOrd + Debug;
    type Year: Debug + Into<YearInfo>;
    type DifferenceError;

Show 17 methods // Required methods fn from_codes( &self, era: Option<&str>, year: i32, month_code: MonthCode, day: u8, ) -> Result<Self::DateInner, DateError>; fn has_cheap_iso_conversion(&self) -> bool; fn from_rata_die(&self, rd: RataDie) -> Self::DateInner; fn to_rata_die(&self, date: &Self::DateInner) -> RataDie; fn months_in_year(&self, date: &Self::DateInner) -> u8; fn days_in_year(&self, date: &Self::DateInner) -> u16; fn days_in_month(&self, date: &Self::DateInner) -> u8; fn is_in_leap_year(&self, date: &Self::DateInner) -> bool; fn year_info(&self, date: &Self::DateInner) -> Self::Year; fn month(&self, date: &Self::DateInner) -> MonthInfo; fn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth; fn day_of_year(&self, date: &Self::DateInner) -> DayOfYear; fn calendar_algorithm(&self) -> Option<CalendarAlgorithm>; fn debug_name(&self) -> &'static str; // Provided methods fn from_iso(&self, iso: IsoDateInner) -> Self::DateInner { ... } fn to_iso(&self, date: &Self::DateInner) -> IsoDateInner { ... } fn extended_year(&self, date: &Self::DateInner) -> i32 { ... }
}
Expand description

A calendar implementation

Only implementors of Calendar should care about these methods, in general users of these calendars should use the methods on Date instead.

Individual Calendar implementations may have inherent utility methods allowing for direct construction, etc.

๐Ÿšซ This trait is sealed; it should not be implemented by user code. If an API requests an item that implements this trait, please consider using a type from the implementors listed below.

It is still possible to implement this trait in userland (since UnstableSealed is public), do not do so unless you are prepared for things to occasionally break.

Required Associated Typesยง

Source

type DateInner: Eq + Copy + PartialOrd + Debug

The internal type used to represent dates

Equality and ordering should observe normal calendar semantics.

Source

type Year: Debug + Into<YearInfo>

The type of YearInfo returned by the date

Source

type DifferenceError

The type of error returned by until

Required Methodsยง

Source

fn from_codes( &self, era: Option<&str>, year: i32, month_code: MonthCode, day: u8, ) -> Result<Self::DateInner, DateError>

Construct a date from era/month codes and fields

The year is the extended year if no era is provided

Source

fn has_cheap_iso_conversion(&self) -> bool

Whether from_iso/to_iso is more efficient than from_rata_die/to_rata_die.

Source

fn from_rata_die(&self, rd: RataDie) -> Self::DateInner

Construct the date from a RataDie

Source

fn to_rata_die(&self, date: &Self::DateInner) -> RataDie

Obtain a RataDie from this date

Source

fn months_in_year(&self, date: &Self::DateInner) -> u8

Count the number of months in a given year, specified by providing a date from that year

Source

fn days_in_year(&self, date: &Self::DateInner) -> u16

Count the number of days in a given year, specified by providing a date from that year

Source

fn days_in_month(&self, date: &Self::DateInner) -> u8

Count the number of days in a given month, specified by providing a date from that year/month

Source

fn is_in_leap_year(&self, date: &Self::DateInner) -> bool

Calculate if a date is in a leap year

Source

fn year_info(&self, date: &Self::DateInner) -> Self::Year

Information about the year

Source

fn month(&self, date: &Self::DateInner) -> MonthInfo

The calendar-specific month represented by date

Source

fn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth

The calendar-specific day-of-month represented by date

Source

fn day_of_year(&self, date: &Self::DateInner) -> DayOfYear

Information of the day of the year

Source

fn calendar_algorithm(&self) -> Option<CalendarAlgorithm>

Returns the CalendarAlgorithm that is required to match when parsing into this calendar.

If left empty, any algorithm will parse successfully.

Source

fn debug_name(&self) -> &'static str

Obtain a name for the calendar for debug printing

Provided Methodsยง

Source

fn from_iso(&self, iso: IsoDateInner) -> Self::DateInner

Construct the date from an ISO date.

Only called if HAS_CHEAP_ISO_CONVERSION is set.

Source

fn to_iso(&self, date: &Self::DateInner) -> IsoDateInner

Obtain an ISO date from this date.

Only called if HAS_CHEAP_ISO_CONVERSION is set.

Source

fn extended_year(&self, date: &Self::DateInner) -> i32

Implementorsยง

Sourceยง

impl Calendar for AnyCalendar

Sourceยง

type DateInner = AnyDateInner

Sourceยง

type Year = YearInfo

Sourceยง

type DifferenceError = AnyCalendarDifferenceError

Sourceยง

impl Calendar for Buddhist

Sourceยง

impl Calendar for Coptic

Sourceยง

impl Calendar for Ethiopian

Sourceยง

impl Calendar for Hebrew

Sourceยง

impl Calendar for Indian

Sourceยง

impl Calendar for Japanese

Sourceยง

impl Calendar for JapaneseExtended

Sourceยง

impl Calendar for Julian

Sourceยง

impl Calendar for Persian

Sourceยง

impl Calendar for Roc

Sourceยง

impl Calendar for Gregorian

Sourceยง

impl Calendar for Iso

Sourceยง

impl<R> Calendar for EastAsianTraditional<R>
where R: Rules,

Sourceยง

impl<R> Calendar for Hijri<R>
where R: Rules,