pub struct CalendarState {
pub year: i32,
pub month: u32,
pub selected_day: Option<u32>,
/* private fields */
}Expand description
State for the calendar date picker widget.
Fields§
§year: i32Current display year.
month: u32Current display month (1–12).
selected_day: Option<u32>Currently selected day, if any (single-date mode).
Implementations§
Source§impl CalendarState
impl CalendarState
Sourcepub fn from_ym(year: i32, month: u32) -> Self
pub fn from_ym(year: i32, month: u32) -> Self
Create a CalendarState for a specific year and month.
Sourcepub fn with_range(&mut self) -> &mut Self
pub fn with_range(&mut self) -> &mut Self
Enable date-range selection (start/end via Shift-extend).
Single-date mode remains the default; call this to opt in. Returns
&mut Self for chaining. Available since 0.21.0.
§Example
use slt::CalendarState;
let mut cal = CalendarState::from_ym(2024, 3);
cal.with_range();Sourcepub fn with_time(&mut self) -> &mut Self
pub fn with_time(&mut self) -> &mut Self
Enable hour/minute selection, rendered as HH:MM below the grid.
Off by default — no time row is rendered unless enabled. Returns
&mut Self for chaining. Available since 0.21.0.
§Example
use slt::CalendarState;
let mut cal = CalendarState::from_ym(2024, 3);
cal.with_time();Sourcepub fn mode(&self) -> CalendarSelect
pub fn mode(&self) -> CalendarSelect
The active selection mode (Single by default).
Available since 0.21.0.
§Example
use slt::{CalendarSelect, CalendarState};
let cal = CalendarState::from_ym(2024, 3);
assert_eq!(cal.mode(), CalendarSelect::Single);Sourcepub fn selected_date(&self) -> Option<(i32, u32, u32)>
pub fn selected_date(&self) -> Option<(i32, u32, u32)>
Returns the selected date as (year, month, day), if any.
Sourcepub fn selected_range(&self) -> Option<(CalDate, CalDate)>
pub fn selected_range(&self) -> Option<(CalDate, CalDate)>
The normalized selected range as (start, end) with start <= end.
Returns None in single-date mode or until an anchor has been set in
range mode. Endpoints are absolute CalDates, so a range may span
month or year boundaries. Available since 0.21.0.
§Example
use slt::CalendarState;
let mut cal = CalendarState::from_ym(2024, 3);
cal.with_range();
assert!(cal.selected_range().is_none());Sourcepub fn selected_time(&self) -> Option<(u8, u8)>
pub fn selected_time(&self) -> Option<(u8, u8)>
The selected (hour, minute) when time is enabled, else None.
Available since 0.21.0.
§Example
use slt::CalendarState;
let mut cal = CalendarState::from_ym(2024, 3);
assert!(cal.selected_time().is_none());
cal.with_time();
assert_eq!(cal.selected_time(), Some((0, 0)));Sourcepub fn prev_month(&mut self)
pub fn prev_month(&mut self)
Navigate to the previous month.
Sourcepub fn next_month(&mut self)
pub fn next_month(&mut self)
Navigate to the next month.
Trait Implementations§
Source§impl Clone for CalendarState
impl Clone for CalendarState
Source§fn clone(&self) -> CalendarState
fn clone(&self) -> CalendarState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more