JFLib

Date and time input#

Source: lib/ui/datepick.rs

datepick -- date and time input

  time_box(id, &mut hour, &mut minute) -> EV    two number boxes "HH : MM" (EV_ACT changed)
  weekday_toggles(id, &mut mask) -> EV          seven toggle buttons, bit 0 = Monday ..
                                                bit 6 = Sunday (EV_ACT changed); they wrap
                                                where the row is narrower (BOX_WRAP)
  date_picker(id, &mut y, &mut m, &mut d) -> EV a button with the date (the user's format,
                                                i18n::fmt_date) that opens a month calendar
                                                starting on the locale's first weekday
                                                (EV_ACT when a day was picked; it closes the
                                                calendar only, a flyout around it stays)
  calendar(id, &mut y, &mut m, &mut d, &DateRange) -> EV
                                                the calendar in place, for any panel or flyout:
                                                a month of days (CAL_DAY), of ISO weeks
                                                (CAL_WEEK: a row is a week, the date its
                                                Monday) or a year of months (CAL_MONTH: the 1st);
                                                only dates between min and max can be picked
                                                (EV_ACT when the user picked)
  The civil helpers (days in a month, weekday, ISO weeks) are jflib::datetime's.

Ids: parts (id << 3 | k) | 0x80000000; calendar cells ((id ^ 0x3C3C) << 6 | cell) | 0x80000000
(a day 0 .. 41, a week row 0 .. 5, a month 0 .. 11).
/// what a calendar picks (DateRange::mode): a day
CAL_DAY: u32 = 0
/// an ISO 8601 week (Monday to Sunday): the date is its Monday, the rows start on Monday and show
/// the week's number (datetime::iso_week)
CAL_WEEK: u32 = 1
/// a month: the date is its 1st, the calendar shows the twelve months of a year
CAL_MONTH: u32 = 2
  • struct DateRange what a calendar picks and between which dates (calendar): mode CAL_DAY, CAL_WEEK or CAL_MONTH; min and max (year, month, day) inclusive -- in CAL_WEEK the weeks that hold them, in CAL_MONTH their months
    • mode: u32
    • min: (i32, u32, u32)
    • max: (i32, u32, u32)

impl DateRange

  • const DAYS: DateRange = DateRange::new(CAL_DAY, (1, 1, 1), (9999, 12, 31)) days of the years 1 to 9999
  • const fn new(mode: u32, min: (i32, u32, u32), max: (i32, u32, u32)) -> DateRange

impl Ui

  • fn time_box(&mut self, id: u32, hour: &mut i32, minute: &mut i32) -> u32 ui_time_box(id, &mut hour, &mut minute) -> EV_* (EV_ACT changed)
  • fn weekday_toggles(&mut self, id: u32, mask: &mut u32) -> u32 ui_weekday_toggles(id, &mut mask) -> EV_* (EV_ACT changed); bit 0 = Monday. The buttons wrap where the row has less room than the seven of them (a narrow card)
  • fn date_picker(&mut self, id: u32, y: &mut i32, m: &mut u32, d: &mut u32) -> u32 ui_date_picker(id, &mut y, &mut m, &mut d) -> EV_* (EV_ACT when a day was picked). A pick closes the calendar's popup and the popups inside it, not a flyout the picker sits in (popup_close_id)
  • fn calendar(&mut self, id: u32, y: &mut i32, m: &mut u32, d: &mut u32, range: &DateRange) -> u32 ui_calendar(id, &mut y, &mut m, &mut d, &range) -> EV_* (EV_ACT when the user picked): a month calendar in place, no popup -- a panel's, or the content of a flyout of the app's own. range.mode picks a day (CAL_DAY: the weeks start on the locale's first weekday), an ISO week (CAL_WEEK: rows from Monday with the week's number; y, m, d become its Monday) or a month (CAL_MONTH: a year of months; y, m, d become its 1st); what lies outside range.min .. range.max is drawn disabled. The arrows show the month (the year) before and after; the calendar shows the month of y, m, d again when the app changes the date.

Source: docs/API.md in the JFLib repository.