diff options
-rw-r--r-- | examples/main.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/main.rs b/examples/main.rs new file mode 100644 index 0000000..920accc --- /dev/null +++ b/examples/main.rs @@ -0,0 +1,20 @@ +extern crate kairos; + +fn main() { + // not sure whether this is actually fast or something, but we don't care here, do we? + let s = ::std::env::args().skip(1).fold(String::new(), |acc, obj| format!("{} {}", acc, obj)); + let s = s.trim(); // because kairos is not yet whitespace tolerant + + println!("Parsing: '{}'", s); + match kairos::timetype::TimeType::parse(&s) { + Ok(tt) => { + println!("{:?}", tt); + + match tt.calculate() { + Ok(r) => println!("{:?}", r), + Err(e) => println!("Error calculating: {:?}", e), + } + }, + Err(e) => println!("Error -> {:?}", e), + } +} |