File: cli.rs

package info (click to toggle)
rust-interim 0.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 196 kB
  • sloc: makefile: 2
file content (27 lines) | stat: -rw-r--r-- 775 bytes parent folder | download
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
pub fn main() {
    #[allow(unused_variables)]
    let arg = std::env::args().skip(1).collect::<Vec<String>>().join(" ");

    #[cfg(feature = "time")]
    {
        use interim::{parse_date_string, Dialect};
        use time::OffsetDateTime;
        println!(
            "{}",
            parse_date_string(arg.as_str(), OffsetDateTime::now_utc(), Dialect::Us).unwrap()
        );
    }
    #[cfg(feature = "chrono")]
    {
        use chrono::Local;
        use interim::{parse_date_string, Dialect};
        println!(
            "{}",
            parse_date_string(arg.as_str(), Local::now(), Dialect::Us).unwrap()
        );
    }
    #[cfg(not(any(feature = "time", feature = "chrono")))]
    {
        eprintln!("Please enable either time or chrono feature")
    }
}