Skip to main content

Module datetime

Module datetime 

Source
Expand description

day_pieces::datetime: core date and time pickers with native toolkit renderers and a composed DOM fallback (docs/datepicker.md; DESIGN.md §15).

ⓘ
let date = Signal::new(DayDate::new(2026, 7, 18).unwrap());
let time = Signal::new(DayTime::new(9, 30, 0).unwrap());
column((
    date_picker(date),                      // Compact: field/button → platform chooser
    date_picker(date).inline(),             // Inline: embedded calendar / wheels
    time_picker(time),
    row((date_picker(date), time_picker(time))),  // combined date+time = composition
))

Two pieces, date_picker and time_picker, rather than one combined date-time piece: a single combined control exists on only 3 of the 7 toolkits (NSDatePicker, UIDatePicker.dateAndTime, QDateTimeEdit), while separate date and time controls realize natively on all of them. Each piece maps a small style intent (Style::Compact / Style::Inline) to the platform’s closest idiomatic control, never promising identical chrome (Android’s Material chooser is a modal dialog, iOS’s a popover, Qt’s a calendar popup; that difference is the platform, docs/datepicker.md has the full table).

The bound signal is two-way: a user pick sets it; the app setting it updates the native control. Values are civil (zoneless) DayDate/DayTime; time zones are the app’s business. The piece’s node also accepts Event::TextChanged carrying an ISO value ("2026-07-18" / "09:30") as a synthetic set, so dayscript’s existing input: step drives any picker on any backend.

Structs§

DatePicker
A native date picker bound two-way to a DayDate signal. Build with date_picker.
DateProps
Full props (realize) for the date picker. style/min/max are set once at build; only the value patches.
DayDate
A civil (zoneless) calendar date, proleptic Gregorian. Ordered chronologically; Display and DayDate::parse_iso speak ISO-8601 (YYYY-MM-DD).
DayTime
A civil (zoneless) wall-clock time. Display and DayTime::parse_iso speak ISO-8601 (HH:MM, or HH:MM:SS when seconds are nonzero).
TimePicker
A native time picker bound two-way to a DayTime signal. Build with time_picker.
TimeProps
Full props (realize) for the time picker. style/seconds are set once at build; only the value patches.

Enums§

DatePatch
Style
How the picker presents (docs/datepicker.md has the per-toolkit table). Like PickerStyle, each intent maps to the platform’s closest idiomatic control, so chrome differs per platform.
TimePatch

Constants§

DATE_KIND
TIME_KIND

Traits§

DatePickerBuilder
Builder methods of DatePicker, reachable through a Decorated (docs/api-style.md “Typed builders and erasure”): generic modifiers and typed ones chain in any order.
TimePickerBuilder
Builder methods of DatePicker, reachable through a Decorated (docs/api-style.md “Typed builders and erasure”): generic modifiers and typed ones chain in any order.

Functions§

date_picker
date_picker(date): a field summoning the platform’s chooser; .inline() embeds it. date is a Signal<DayDate> or any other two-way binding (a day-model Field, mapped).
days_in_month
is_leap
support
How the pickers are realized on the compiled backend: Native (a platform picker control) or Emulated (GTK, where GTK4/libadwaita have no stock date/time picker, so the renderer composes native primitives: GtkCalendar in a popover, linked spin buttons; also mock).
time_picker
time_picker(time): a field summoning the platform’s chooser; .inline() embeds it.