Trait Calendar

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

Show 16 methods // Required methods fn from_codes( &self, era: Option<&str>, year: i32, month_code: MonthCode, day: u8, ) -> Result<Self::DateInner, DateError>; fn from_iso(&self, iso: IsoDateInner) -> Self::DateInner; fn to_iso(&self, date: &Self::DateInner) -> IsoDateInner; 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 extended_year(&self, date: &Self::DateInner) -> i32; 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;
}
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 + Debug

The internal type used to represent dates

Source

type Year: Debug + Into<YearInfo>

The type of YearInfo returned by the date

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 extended_year if no era is provided

Source

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

Construct the date from an ISO date

Source

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

Obtain an ISO date from this date

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 extended_year(&self, date: &Self::DateInner) -> i32

The extended year value

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

Dyn Compatibilityยง

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementorsยง

Sourceยง

impl Calendar for AnyCalendar

Sourceยง

impl Calendar for Buddhist

Sourceยง

impl Calendar for Chinese

Sourceยง

type DateInner = ChineseDateInner

Sourceยง

type Year = CyclicYear

Sourceยง

impl Calendar for Coptic

Sourceยง

type DateInner = CopticDateInner

Sourceยง

type Year = EraYear

Sourceยง

impl Calendar for Dangi

Sourceยง

impl Calendar for Ethiopian

Sourceยง

type DateInner = EthiopianDateInner

Sourceยง

type Year = EraYear

Sourceยง

impl Calendar for Hebrew

Sourceยง

type DateInner = HebrewDateInner

Sourceยง

type Year = EraYear

Sourceยง

impl Calendar for HijriSimulated

Sourceยง

type DateInner = HijriSimulatedDateInner

Sourceยง

type Year = EraYear

Sourceยง

impl Calendar for HijriTabular

Sourceยง

type DateInner = HijriTabularDateInner

Sourceยง

type Year = EraYear

Sourceยง

impl Calendar for HijriUmmAlQura

Sourceยง

type DateInner = HijriUmmAlQuraDateInner

Sourceยง

type Year = EraYear

Sourceยง

impl Calendar for Indian

Sourceยง

type DateInner = IndianDateInner

Sourceยง

type Year = EraYear

Sourceยง

impl Calendar for Japanese

Sourceยง

type DateInner = JapaneseDateInner

Sourceยง

type Year = EraYear

Sourceยง

impl Calendar for JapaneseExtended

Sourceยง

type DateInner = JapaneseDateInner

Sourceยง

type Year = EraYear

Sourceยง

impl Calendar for Julian

Sourceยง

type DateInner = JulianDateInner

Sourceยง

type Year = EraYear

Sourceยง

impl Calendar for Persian

Sourceยง

type DateInner = PersianDateInner

Sourceยง

type Year = EraYear

Sourceยง

impl Calendar for Roc

Sourceยง

impl Calendar for Gregorian

Sourceยง

type DateInner = GregorianDateInner

Sourceยง

type Year = EraYear

Sourceยง

impl Calendar for Iso