forked from slint-ui/slint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
booker.rs
27 lines (23 loc) · 852 Bytes
/
booker.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
use chrono::NaiveDate;
use slint::SharedString;
slint::slint!(import { Booker } from "booker.slint";);
pub fn main() {
let booker = Booker::new().unwrap();
booker.on_validate_date(|date: SharedString| {
NaiveDate::parse_from_str(date.as_str(), "%d.%m.%Y").is_ok()
});
booker.on_compare_date(|date1: SharedString, date2: SharedString| {
let date1 = match NaiveDate::parse_from_str(date1.as_str(), "%d.%m.%Y") {
Err(_) => return false,
Ok(x) => x,
};
let date2 = match NaiveDate::parse_from_str(date2.as_str(), "%d.%m.%Y") {
Err(_) => return false,
Ok(x) => x,
};
date1 <= date2
});
booker.run().unwrap();
}