pub(crate) trait DateFieldsResolver: Calendar {
type YearInfo: Copy + Debug + PartialEq + ToExtendedYear;
// Required methods
fn days_in_provided_month(year: Self::YearInfo, month: u8) -> u8;
fn months_in_provided_year(year: Self::YearInfo) -> u8;
fn year_info_from_era(
&self,
era: &[u8],
era_year: i32,
) -> Result<Self::YearInfo, UnknownEraError>;
fn year_info_from_extended(&self, extended_year: i32) -> Self::YearInfo;
fn reference_year_from_month_day(
&self,
month_code: ValidMonthCode,
day: u8,
) -> Result<Self::YearInfo, EcmaReferenceYearError>;
// Provided methods
fn ordinal_month_from_code(
&self,
_year: &Self::YearInfo,
month_code: ValidMonthCode,
_options: DateFromFieldsOptions,
) -> Result<u8, MonthCodeError> { ... }
fn month_code_from_ordinal(
&self,
_year: &Self::YearInfo,
ordinal_month: u8,
) -> ValidMonthCode { ... }
}Expand description
Trait for converting from era codes, month codes, and other fields to year/month/day ordinals.
Required Associated Types§
Required Methods§
fn days_in_provided_month(year: Self::YearInfo, month: u8) -> u8
fn months_in_provided_year(year: Self::YearInfo) -> u8
Sourcefn year_info_from_era(
&self,
era: &[u8],
era_year: i32,
) -> Result<Self::YearInfo, UnknownEraError>
fn year_info_from_era( &self, era: &[u8], era_year: i32, ) -> Result<Self::YearInfo, UnknownEraError>
Converts the era and era year to a YearInfo. If the calendar does not have eras, this should always return an Err result.
Sourcefn year_info_from_extended(&self, extended_year: i32) -> Self::YearInfo
fn year_info_from_extended(&self, extended_year: i32) -> Self::YearInfo
Converts an extended year to a YearInfo.
Sourcefn reference_year_from_month_day(
&self,
month_code: ValidMonthCode,
day: u8,
) -> Result<Self::YearInfo, EcmaReferenceYearError>
fn reference_year_from_month_day( &self, month_code: ValidMonthCode, day: u8, ) -> Result<Self::YearInfo, EcmaReferenceYearError>
Calculates the ECMA reference year for the month code and day, or an error if the month code and day are invalid.
Note that this is called before any potential Overflow::Constrain application, so this should accept out-of-range day values as if they are the highest possible day for the given month.
Provided Methods§
Sourcefn ordinal_month_from_code(
&self,
_year: &Self::YearInfo,
month_code: ValidMonthCode,
_options: DateFromFieldsOptions,
) -> Result<u8, MonthCodeError>
fn ordinal_month_from_code( &self, _year: &Self::YearInfo, month_code: ValidMonthCode, _options: DateFromFieldsOptions, ) -> Result<u8, MonthCodeError>
Calculates the ordinal month for the given year and month code.
The default impl is for non-lunisolar calendars with 12 months!
Sourcefn month_code_from_ordinal(
&self,
_year: &Self::YearInfo,
ordinal_month: u8,
) -> ValidMonthCode
fn month_code_from_ordinal( &self, _year: &Self::YearInfo, ordinal_month: u8, ) -> ValidMonthCode
Calculates the month code from the given ordinal month and year.
The caller must ensure that the ordinal is in range.
The default impl is for non-lunisolar calendars!
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.