Function parse_time

Source
pub fn parse_time(input: &str, format: TimeFormat) -> Option<TimeValue>
Expand description

Parses a time in the exact representation selected by format.

The 24-hour form requires hour:minute with values in 0..=23 and 0..=59. The 12-hour form requires a space plus case-insensitive AM or PM, and an hour in 1..=12. Numeric fields need not be zero-padded. Returns None for malformed or out-of-range input.

ยงExamples

use ailloli_ui_core::{TimeFormat, TimeValue};
use ailloli_ui_core::time_picker::parse_time;

assert_eq!(parse_time("2:05 PM", TimeFormat::Hour12), Some(TimeValue::new(14, 5)));
assert_eq!(parse_time("25:00", TimeFormat::Hour24), None);