pub(crate) trait CalendarArithmetic: Calendar {
    type YearInfo: Copy + Debug;

    // Required methods
    fn month_days(year: i32, month: u8, year_info: Self::YearInfo) -> u8;
    fn months_for_every_year(year: i32, year_info: Self::YearInfo) -> u8;
    fn is_leap_year(year: i32, year_info: Self::YearInfo) -> bool;
    fn last_month_day_in_year(year: i32, year_info: Self::YearInfo) -> (u8, u8);

    // Provided method
    fn days_in_provided_year(year: i32, year_info: Self::YearInfo) -> u16 { ... }
}

Required Associated Types§

source

type YearInfo: Copy + Debug

In case we plan to cache per-year data, this stores useful computational information for the current year as a field on ArithmeticDate

Required Methods§

source

fn month_days(year: i32, month: u8, year_info: Self::YearInfo) -> u8

source

fn months_for_every_year(year: i32, year_info: Self::YearInfo) -> u8

source

fn is_leap_year(year: i32, year_info: Self::YearInfo) -> bool

source

fn last_month_day_in_year(year: i32, year_info: Self::YearInfo) -> (u8, u8)

Provided Methods§

source

fn days_in_provided_year(year: i32, year_info: Self::YearInfo) -> u16

Calculate the days in a given year Can be overridden with simpler implementations for solar calendars (typically, 366 in leap, 365 otherwise) Leave this as the default for lunar calendars

The name has provided in it to avoid clashes with Calendar

Object Safety§

This trait is not object safe.

Implementors§