pub trait CalendarSystem {
type Date: Clone + Debug;
// Required methods
fn to_gregorian(&self, date: &Self::Date) -> Option<NaiveDate>;
fn from_gregorian(&self, date: &NaiveDate) -> Option<Self::Date>;
fn name(&self) -> &str;
// Provided method
fn calendar_type(&self) -> CalendarType { ... }
}Expand description
A calendar system for date representation.
Different from TemporalOntology in that calendars are specifically
about date representation, while ontologies are about temporal concepts.
§Built-in Implementations
GregorianCalendar: Standard Western calendar
§Example: Islamic Calendar
ⓘ
struct HijriCalendar;
impl CalendarSystem for HijriCalendar {
type Date = HijriDate;
fn to_gregorian(&self, date: &Self::Date) -> Option<NaiveDate> {
// Islamic calendar is purely lunar (354 or 355 days/year)
// Conversion requires astronomical calculation or lookup tables
todo!()
}
fn from_gregorian(&self, date: &NaiveDate) -> Option<Self::Date> {
todo!()
}
}Required Associated Types§
Required Methods§
Sourcefn to_gregorian(&self, date: &Self::Date) -> Option<NaiveDate>
fn to_gregorian(&self, date: &Self::Date) -> Option<NaiveDate>
Convert to Gregorian date.
Sourcefn from_gregorian(&self, date: &NaiveDate) -> Option<Self::Date>
fn from_gregorian(&self, date: &NaiveDate) -> Option<Self::Date>
Convert from Gregorian date.
Provided Methods§
Sourcefn calendar_type(&self) -> CalendarType
fn calendar_type(&self) -> CalendarType
Is this calendar lunar, solar, or lunisolar?