Skip to main content

DateAdapter

Trait DateAdapter 

Source
pub trait DateAdapter {
Show 13 methods // Required methods fn today(&self) -> Option<Day>; fn month_of(&self, day: Day) -> MonthKey; fn month_grid(&self, month: MonthKey) -> MonthGrid; fn month_label(&self, month: MonthKey) -> SharedString; fn weekday_labels(&self) -> Vec<SharedString>; fn format_day(&self, day: Day) -> SharedString; fn day_label(&self, day: Day) -> SharedString; fn parse_day(&self, text: &str) -> Result<Day, SharedString>; fn shift_month(&self, month: MonthKey, delta: i32) -> Option<MonthKey>; fn is_selectable(&self, day: Day) -> Selectability; fn days_in(&self, start: Day, end: Day) -> Option<Vec<Day>>; fn clock(&self) -> Clock; fn format_time(&self, time: TimeOfDay) -> SharedString;
}
Expand description

Everything the date components are not allowed to know.

One implementation of this is the whole seam. The components read facts from it, hand Day values back to it, and never derive a date fact themselves — including which month a keystroke moved to, which is shift_month rather than an addition.

Required Methods§

Source

fn today(&self) -> Option<Day>

What day it is, or None when the host has not established one.

None is a real answer and is rendered as one: no today ring is drawn and no month is guessed from it.

Source

fn month_of(&self, day: Day) -> MonthKey

Source

fn month_grid(&self, month: MonthKey) -> MonthGrid

Source

fn month_label(&self, month: MonthKey) -> SharedString

What the month is called, already in the host’s language.

Source

fn weekday_labels(&self) -> Vec<SharedString>

The weekday headings, already in the host’s first-day-of-week order.

Source

fn format_day(&self, day: Day) -> SharedString

The whole day, as a field would show it.

Source

fn day_label(&self, day: Day) -> SharedString

What the grid draws in the day’s own cell, usually its number.

Source

fn parse_day(&self, text: &str) -> Result<Day, SharedString>

Reads a typed date. The error is the message shown to the typist, word for word; the components never write one of their own.

Source

fn shift_month(&self, month: MonthKey, delta: i32) -> Option<MonthKey>

The month delta months away, or None when the host will not go there.

Source

fn is_selectable(&self, day: Day) -> Selectability

Source

fn days_in(&self, start: Day, end: Day) -> Option<Vec<Day>>

Every day from start to end inclusive, or None when the host cannot enumerate them.

A range picker uses this to name the blocked days inside a range. With None it says it could not check, rather than claiming a range is clear because it never looked.

Source

fn clock(&self) -> Clock

Source

fn format_time(&self, time: TimeOfDay) -> SharedString

The time as the host would write it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§