Function clamp_date

Source
pub fn clamp_date(
    value: DateValue,
    min: Option<DateValue>,
    max: Option<DateValue>,
) -> DateValue
Expand description

Clamps a date to optional inclusive bounds.

The lower bound is applied before the upper bound. If min > max, the result is therefore max; callers should normally provide ordered bounds.

ยงExamples

use ailloli_ui_core::date_picker::clamp_date;
use ailloli_ui_core::DateValue;

let min = DateValue::new(2026, 1, 10);
assert_eq!(clamp_date(DateValue::new(2026, 1, 1), Some(min), None), min);