Skip to content

DatePicker / Calendar: no time-of-day support (datetime picker) #3114

Description

@yisier

Summary

DatePicker / Calendar can only represent a date. There is no way to pick or display a time of day, so applications that edit DATETIME / TIMESTAMP-like values have to hand-roll the time part and keep it in sync with CalendarState.

Environment

  • gpui-kit / gpui-component / gpui-base 0.6.1 (latest on crates.io as of 2026-09)
  • gpui-pre 0.3.5
  • Windows (x86_64-pc-windows-gnu)

Current behavior / evidence

  • gpui_base::calendar::Date is Single(Option<NaiveDate>) | Range(Option<NaiveDate>, Option<NaiveDate>) — the controlled value is chrono::NaiveDate only.
  • gpui_component::time only exposes calendar and date_picker; there is no TimePicker and no NaiveTime usage anywhere in the crate.
  • DatePickerState::date_format defaults to "%Y/%m/%d"; there is no time format / precision option.

Use case

A database management GUI. When the user edits a MySQL DATETIME / TIMESTAMP cell, the picker must set YYYY-MM-DD HH:MM:SS. DatePicker can pick the day but not the time, and Calendar has no time affordance, so we currently compose Calendar with our own time spinner + validation.

Possible solutions (any one would unblock this)

  1. Add a standalone TimePicker (hour / minute / second, 12/24h, stepper and/or text input) that apps can compose with the existing Calendar.
  2. Add optional time support to DatePickerState — e.g. a NaiveDateTime-based Date variant, plus with_time / time_format / precision options and time columns in the popup.
  3. At minimum, document that the picker is date-only and that time is expected to be supplied by the app.

Note from the workaround

When composing Calendar inside an app-drawn popup, the calendar root uses track_focus, so a mouse-down moves focus to the calendar and blurs whatever input the app is editing (in our case an in-cell editor that commits on blur). We had to add capture_any_mouse_down(|_, window, _| window.prevent_default()) on the popup to keep focus in the editor. A future TimePicker would ideally not steal focus from its trigger by design.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions