Trait temporal_rs::components::calendar::CalendarProtocol
source · pub trait CalendarProtocol: Clone {
type Date: IsoDateSlots + GetCalendarSlot<Self> + Clone + Debug;
type DateTime: IsoDateSlots + GetCalendarSlot<Self> + Clone + Debug;
type YearMonth: IsoDateSlots + GetCalendarSlot<Self> + Clone + Debug;
type MonthDay: IsoDateSlots + GetCalendarSlot<Self> + Clone + Debug;
type Context;
Show 23 methods
// Required methods
fn date_from_fields(
&self,
fields: &mut TemporalFields,
overflow: ArithmeticOverflow,
context: &mut Self::Context
) -> TemporalResult<Date<Self>>;
fn year_month_from_fields(
&self,
fields: &mut TemporalFields,
overflow: ArithmeticOverflow,
context: &mut Self::Context
) -> TemporalResult<YearMonth<Self>>;
fn month_day_from_fields(
&self,
fields: &mut TemporalFields,
overflow: ArithmeticOverflow,
context: &mut Self::Context
) -> TemporalResult<MonthDay<Self>>;
fn date_add(
&self,
date: &Date<Self>,
duration: &Duration,
overflow: ArithmeticOverflow,
context: &mut Self::Context
) -> TemporalResult<Date<Self>>;
fn date_until(
&self,
one: &Date<Self>,
two: &Date<Self>,
largest_unit: TemporalUnit,
context: &mut Self::Context
) -> TemporalResult<Duration>;
fn era(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<Option<TinyAsciiStr<16>>>;
fn era_year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<Option<i32>>;
fn year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<i32>;
fn month(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u8>;
fn month_code(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<TinyAsciiStr<4>>;
fn day(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u8>;
fn day_of_week(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>;
fn day_of_year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>;
fn week_of_year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>;
fn year_of_week(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<i32>;
fn days_in_week(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>;
fn days_in_month(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>;
fn days_in_year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>;
fn months_in_year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>;
fn in_leap_year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<bool>;
fn fields(
&self,
fields: Vec<String>,
context: &mut Self::Context
) -> TemporalResult<Vec<String>>;
fn merge_fields(
&self,
fields: &TemporalFields,
additional_fields: &TemporalFields,
context: &mut Self::Context
) -> TemporalResult<TemporalFields>;
fn identifier(&self, context: &mut Self::Context) -> TemporalResult<String>;
}
Expand description
A trait for implementing a Builtin Calendar’s Calendar Protocol in Rust.
Required Associated Types§
sourcetype Date: IsoDateSlots + GetCalendarSlot<Self> + Clone + Debug
type Date: IsoDateSlots + GetCalendarSlot<Self> + Clone + Debug
A Custom Date
Type for an associated CalendarProtocol
. Default Date<C>
sourcetype DateTime: IsoDateSlots + GetCalendarSlot<Self> + Clone + Debug
type DateTime: IsoDateSlots + GetCalendarSlot<Self> + Clone + Debug
A Custom DateTime
Type for an associated CalendarProtocol
. Default DateTime<C>
sourcetype YearMonth: IsoDateSlots + GetCalendarSlot<Self> + Clone + Debug
type YearMonth: IsoDateSlots + GetCalendarSlot<Self> + Clone + Debug
A Custom YearMonth
Type for an associated CalendarProtocol
. Default YearMonth<C>
sourcetype MonthDay: IsoDateSlots + GetCalendarSlot<Self> + Clone + Debug
type MonthDay: IsoDateSlots + GetCalendarSlot<Self> + Clone + Debug
A Custom MonthDay
Type for an associated CalendarProtocol
. Default MonthDay<C>
Required Methods§
sourcefn date_from_fields(
&self,
fields: &mut TemporalFields,
overflow: ArithmeticOverflow,
context: &mut Self::Context
) -> TemporalResult<Date<Self>>
fn date_from_fields( &self, fields: &mut TemporalFields, overflow: ArithmeticOverflow, context: &mut Self::Context ) -> TemporalResult<Date<Self>>
Creates a Temporal.PlainDate
object from provided fields.
sourcefn year_month_from_fields(
&self,
fields: &mut TemporalFields,
overflow: ArithmeticOverflow,
context: &mut Self::Context
) -> TemporalResult<YearMonth<Self>>
fn year_month_from_fields( &self, fields: &mut TemporalFields, overflow: ArithmeticOverflow, context: &mut Self::Context ) -> TemporalResult<YearMonth<Self>>
Creates a Temporal.PlainYearMonth
object from the provided fields.
sourcefn month_day_from_fields(
&self,
fields: &mut TemporalFields,
overflow: ArithmeticOverflow,
context: &mut Self::Context
) -> TemporalResult<MonthDay<Self>>
fn month_day_from_fields( &self, fields: &mut TemporalFields, overflow: ArithmeticOverflow, context: &mut Self::Context ) -> TemporalResult<MonthDay<Self>>
Creates a Temporal.PlainMonthDay
object from the provided fields.
sourcefn date_add(
&self,
date: &Date<Self>,
duration: &Duration,
overflow: ArithmeticOverflow,
context: &mut Self::Context
) -> TemporalResult<Date<Self>>
fn date_add( &self, date: &Date<Self>, duration: &Duration, overflow: ArithmeticOverflow, context: &mut Self::Context ) -> TemporalResult<Date<Self>>
Returns a Temporal.PlainDate
based off an added date.
sourcefn date_until(
&self,
one: &Date<Self>,
two: &Date<Self>,
largest_unit: TemporalUnit,
context: &mut Self::Context
) -> TemporalResult<Duration>
fn date_until( &self, one: &Date<Self>, two: &Date<Self>, largest_unit: TemporalUnit, context: &mut Self::Context ) -> TemporalResult<Duration>
Returns a Temporal.Duration
representing the duration between two dates.
sourcefn era(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<Option<TinyAsciiStr<16>>>
fn era( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<Option<TinyAsciiStr<16>>>
Returns the era for a given temporaldatelike
.
sourcefn era_year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<Option<i32>>
fn era_year( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<Option<i32>>
Returns the era year for a given temporaldatelike
sourcefn year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<i32>
fn year( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<i32>
Returns the year
for a given temporaldatelike
sourcefn month(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u8>
fn month( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<u8>
Returns the month
for a given temporaldatelike
sourcefn month_code(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<TinyAsciiStr<4>>
fn month_code( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<TinyAsciiStr<4>>
Returns the monthCode
for a given temporaldatelike
sourcefn day(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u8>
fn day( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<u8>
Returns the day
for a given temporaldatelike
sourcefn day_of_week(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>
fn day_of_week( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<u16>
Returns a value representing the day of the week for a date.
sourcefn day_of_year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>
fn day_of_year( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<u16>
Returns a value representing the day of the year for a given calendar.
sourcefn week_of_year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>
fn week_of_year( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<u16>
Returns a value representing the week of the year for a given calendar.
sourcefn year_of_week(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<i32>
fn year_of_week( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<i32>
Returns the year of a given week.
sourcefn days_in_week(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>
fn days_in_week( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<u16>
Returns the days in a week for a given calendar.
sourcefn days_in_month(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>
fn days_in_month( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<u16>
Returns the days in a month for a given calendar.
sourcefn days_in_year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>
fn days_in_year( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<u16>
Returns the days in a year for a given calendar.
sourcefn months_in_year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<u16>
fn months_in_year( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<u16>
Returns the months in a year for a given calendar.
sourcefn in_leap_year(
&self,
date_like: &CalendarDateLike<Self>,
context: &mut Self::Context
) -> TemporalResult<bool>
fn in_leap_year( &self, date_like: &CalendarDateLike<Self>, context: &mut Self::Context ) -> TemporalResult<bool>
Returns whether a value is within a leap year according to the designated calendar.
sourcefn fields(
&self,
fields: Vec<String>,
context: &mut Self::Context
) -> TemporalResult<Vec<String>>
fn fields( &self, fields: Vec<String>, context: &mut Self::Context ) -> TemporalResult<Vec<String>>
Return the fields for a value.
sourcefn merge_fields(
&self,
fields: &TemporalFields,
additional_fields: &TemporalFields,
context: &mut Self::Context
) -> TemporalResult<TemporalFields>
fn merge_fields( &self, fields: &TemporalFields, additional_fields: &TemporalFields, context: &mut Self::Context ) -> TemporalResult<TemporalFields>
Merge fields based on the calendar and provided values.
sourcefn identifier(&self, context: &mut Self::Context) -> TemporalResult<String>
fn identifier(&self, context: &mut Self::Context) -> TemporalResult<String>
Debug name
Object Safety§
Implementations on Foreign Types§
source§impl CalendarProtocol for ()
impl CalendarProtocol for ()
An empty CalendarProtocol
implementation on ()
.
§Panics
Attempting to use this empty calendar implementation as a valid calendar is an error and will cause a panic.