tour/
tour.rs

1use freedom_dates::*;
2
3fn main() {
4    let good_communism = "2023-02-08T12:00:00-07:00";
5    let bad_communism = "Comrade, today is the eighth of Februrary, in the year 2023.";
6    let pre_history = "1775-07-04";
7
8    let liberated = FreedomDate::liberate(good_communism).unwrap();
9    let too_communist = FreedomDate::liberate(bad_communism).unwrap_err();
10    let pre_historic_nonsense = FreedomDate::liberate(pre_history).unwrap_err();
11
12    println!("'{good_communism}' is liberated: `{liberated}`\n");
13    println!("'{bad_communism}' is impossible to comprehend: `{too_communist}`\n");
14    println!("'{pre_history}' is not a real date: `{pre_historic_nonsense}`\n");
15
16    // `From<u64>` is implemented for FreedomDates
17    let birthday_of_freedom: FreedomDate = 0.into();
18    println!("The Birthday of Freedom is {birthday_of_freedom}\n");
19
20    // FreedomDates implement the FreedomTime trait
21    let one_day = Duration::days(1);
22    let day_after_freedom = birthday_of_freedom + one_day;
23    println!(
24        "The day after Freedom was born, {day_after_freedom}, {} seconds had passed.",
25        day_after_freedom.freedomstamp()
26    );
27}