1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: MIT |
3 | |
4 | use chrono::NaiveDate; |
5 | use slint::SharedString; |
6 | |
7 | slint::slint!(import { Booker } from "booker.slint" ;); |
8 | |
9 | pub fn main() { |
10 | let booker = Booker::new().unwrap(); |
11 | booker.on_validate_date(|date: SharedString| { |
12 | NaiveDate::parse_from_str(s:date.as_str(), fmt:"%d.%m.%Y" ).is_ok() |
13 | }); |
14 | booker.on_compare_date(|date1: SharedString, date2: SharedString| { |
15 | let date1: NaiveDate = match NaiveDate::parse_from_str(s:date1.as_str(), fmt:"%d.%m.%Y" ) { |
16 | Err(_) => return false, |
17 | Ok(x: NaiveDate) => x, |
18 | }; |
19 | let date2: NaiveDate = match NaiveDate::parse_from_str(s:date2.as_str(), fmt:"%d.%m.%Y" ) { |
20 | Err(_) => return false, |
21 | Ok(x: NaiveDate) => x, |
22 | }; |
23 | date1 <= date2 |
24 | }); |
25 | |
26 | booker.run().unwrap(); |
27 | } |
28 | |