pub struct DateTimePicker(/* private fields */);Expand description
Pick a day and a time: the month grid, then the time under it (Tab
moves between them). Returns the DateTime.
use rich_interact::datetime::{Date, DateTime, Time};
use rich_interact::headless::{self, Script};
use rich_interact::{DateTimePicker, Outcome};
let start = DateTime::new(Date::new(2026, 10, 17), Time::new(9, 0, 0));
let picker = DateTimePicker::new("Meeting").value(start);
let script = Script::new().keys("right tab").text("1430").keys("enter");
let (outcome, record) = headless::run(picker, script, 40, 16);
let expected = DateTime::new(Date::new(2026, 10, 18), Time::new(14, 30, 0));
assert_eq!(outcome.unwrap(), Outcome::Done(expected));
assert_eq!(record.last_frame(), "? Meeting › 2026-10-18 14:30");Implementations§
Source§impl DateTimePicker
impl DateTimePicker
pub fn new(prompt: impl Into<String>) -> DateTimePicker
pub fn theme(self, theme: Theme) -> Self
Sourcepub fn with_mouse(self, on: bool) -> Self
pub fn with_mouse(self, on: bool) -> Self
Report the mouse (#476): a click selects a day (a second click on it picks it) or focuses a time field, and the wheel turns the month or the focused field.
Sourcepub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self
pub fn rebind(self, action: &str, keys: impl IntoIterator<Item = Key>) -> Self
Make keys do action (see date_keymap) on this picker
only; no keys unbinds it.
Sourcepub fn today(self, today: Date) -> Self
pub fn today(self, today: Date) -> Self
The day marked as today and t goes to (default: today in
UTC).
Sourcepub fn seconds(self, on: bool) -> Self
pub fn seconds(self, on: bool) -> Self
Pick the seconds too. Without them (the default) the picker works to the minute, whatever order the builders come in: the start, the default and a typed answer drop their seconds, the earliest rounds up to a minute and the latest down.
Sourcepub fn twelve_hour(self, on: bool) -> Self
pub fn twelve_hour(self, on: bool) -> Self
Show a 12-hour clock with AM and PM (a and p set them).
Sourcepub fn default(self, at: DateTime) -> Self
pub fn default(self, at: DateTime) -> Self
Answer this moment without a terminal and to an empty line, and
start at it unless value says where to start.
Sourcepub fn min(self, at: DateTime) -> Self
pub fn min(self, at: DateTime) -> Self
The earliest moment that can be picked: days before its day are dimmed, and on its day an earlier time is refused.
Trait Implementations§
Source§impl Component for DateTimePicker
impl Component for DateTimePicker
Source§fn focus_step(&mut self, forward: bool) -> bool
fn focus_step(&mut self, forward: bool) -> bool
Tab inside: the next part, if there is one.
Source§fn focus_enter(&mut self, forward: bool) -> bool
fn focus_enter(&mut self, forward: bool) -> bool
Tab from outside: the first part, or the last going back.
Source§fn default_value(&self) -> Option<DateTime>
fn default_value(&self) -> Option<DateTime>
The default, unless the picker would refuse it: outside the range, or refused by the validator.
type Output = DateTime
Source§fn start(&mut self, _context: &Context<'_>) -> Flow<DateTime>
fn start(&mut self, _context: &Context<'_>) -> Flow<DateTime>
Done or Cancel finishes the component
without waiting for an event. The default does nothing.Source§fn handle(&mut self, event: &Event, _context: &Context<'_>) -> Flow<DateTime>
fn handle(&mut self, event: &Event, _context: &Context<'_>) -> Flow<DateTime>
Outcome::Interrupted.Source§fn mouse(&self) -> bool
fn mouse(&self) -> bool
run then enables mouse reporting
for the session.Source§fn keymap(&self) -> Keymap
fn keymap(&self) -> Keymap
keymap). A container’s include its focused
child’s, before its own. The default declares none.Source§fn prompt(
&mut self,
io: &mut dyn LineIo,
) -> Result<Option<DateTime>, NotInteractive>
fn prompt( &mut self, io: &mut dyn LineIo, ) -> Result<Option<DateTime>, NotInteractive>
Auto Trait Implementations§
impl !Freeze for DateTimePicker
impl !RefUnwindSafe for DateTimePicker
impl !Sync for DateTimePicker
impl !UnwindSafe for DateTimePicker
impl Send for DateTimePicker
impl Unpin for DateTimePicker
impl UnsafeUnpin for DateTimePicker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<C> ComponentExt for Cwhere
C: Component,
impl<C> ComponentExt for Cwhere
C: Component,
Source§fn map<'a, M>(
self,
done: impl FnMut(Self::Output) -> Flow<M> + 'a,
) -> Map<'a, Self, M>where
Self: 'a,
fn map<'a, M>(
self,
done: impl FnMut(Self::Output) -> Flow<M> + 'a,
) -> Map<'a, Self, M>where
Self: 'a,
M’s flow: Flow::Done(m) to
finish the whole composition with m, Flow::Continue to carry on
(the component stays, showing its answer, and focus moves past it).
Cancelling cancels the composition unless
on_cancel says otherwise.