Trait icu_calendar::Calendar
source · pub trait Calendar {
type DateInner: PartialEq + Eq + Clone + Debug;
Show 14 methods
// Required methods
fn date_from_codes(
&self,
era: Era,
year: i32,
month_code: MonthCode,
day: u8,
) -> Result<Self::DateInner, CalendarError>;
fn date_from_iso(&self, iso: Date<Iso>) -> Self::DateInner;
fn date_to_iso(&self, date: &Self::DateInner) -> Date<Iso>;
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 debug_name(&self) -> &'static str;
fn year(&self, date: &Self::DateInner) -> FormattableYear;
fn is_in_leap_year(&self, date: &Self::DateInner) -> bool;
fn month(&self, date: &Self::DateInner) -> FormattableMonth;
fn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth;
fn day_of_year_info(&self, date: &Self::DateInner) -> DayOfYearInfo;
// Provided methods
fn day_of_week(&self, date: &Self::DateInner) -> IsoWeekday { ... }
fn any_calendar_kind(&self) -> Option<AnyCalendarKind> { ... }
}
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.
For ICU4X 1.0, implementing this trait or calling methods directly is considered
unstable and prone to change, especially for offset_date()
and until()
.
Required Associated Types§
Required Methods§
sourcefn date_from_codes(
&self,
era: Era,
year: i32,
month_code: MonthCode,
day: u8,
) -> Result<Self::DateInner, CalendarError>
fn date_from_codes( &self, era: Era, year: i32, month_code: MonthCode, day: u8, ) -> Result<Self::DateInner, CalendarError>
Construct a date from era/month codes and fields
sourcefn date_from_iso(&self, iso: Date<Iso>) -> Self::DateInner
fn date_from_iso(&self, iso: Date<Iso>) -> Self::DateInner
Construct the date from an ISO date
sourcefn date_to_iso(&self, date: &Self::DateInner) -> Date<Iso>
fn date_to_iso(&self, date: &Self::DateInner) -> Date<Iso>
Obtain an ISO date from this date
sourcefn months_in_year(&self, date: &Self::DateInner) -> u8
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
sourcefn days_in_year(&self, date: &Self::DateInner) -> u16
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
sourcefn days_in_month(&self, date: &Self::DateInner) -> u8
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
sourcefn debug_name(&self) -> &'static str
fn debug_name(&self) -> &'static str
Obtain a name for the calendar for debug printing
sourcefn year(&self, date: &Self::DateInner) -> FormattableYear
fn year(&self, date: &Self::DateInner) -> FormattableYear
The calendar-specific year represented by date
sourcefn is_in_leap_year(&self, date: &Self::DateInner) -> bool
fn is_in_leap_year(&self, date: &Self::DateInner) -> bool
Calculate if a date is in a leap year
sourcefn month(&self, date: &Self::DateInner) -> FormattableMonth
fn month(&self, date: &Self::DateInner) -> FormattableMonth
The calendar-specific month represented by date
sourcefn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth
fn day_of_month(&self, date: &Self::DateInner) -> DayOfMonth
The calendar-specific day-of-month represented by date
sourcefn day_of_year_info(&self, date: &Self::DateInner) -> DayOfYearInfo
fn day_of_year_info(&self, date: &Self::DateInner) -> DayOfYearInfo
Information of the day of the year
Provided Methods§
sourcefn day_of_week(&self, date: &Self::DateInner) -> IsoWeekday
fn day_of_week(&self, date: &Self::DateInner) -> IsoWeekday
Calculate the day of the week and return it
sourcefn any_calendar_kind(&self) -> Option<AnyCalendarKind>
fn any_calendar_kind(&self) -> Option<AnyCalendarKind>
The AnyCalendarKind
corresponding to this calendar,
if one exists. Implementors outside of icu::calendar
should return None