bento-kit 0.1.1

A bento box of common Rust utilities: id generation, timing, masking
Documentation
//! Run with: `cargo run --example time_demo`

#[cfg(feature = "time")]
fn main() {
    use bento_kit::time::{format_now_local, format_now_utc, now_millis, TimeUse};
    use std::thread::sleep;
    use std::time::Duration;

    println!("now (utc)   = {}", format_now_utc("%Y-%m-%d %H:%M:%S"));
    println!("now (local) = {}", format_now_local("%Y-%m-%d %H:%M:%S %Z"));
    println!("now millis  = {}", now_millis());

    let mut t = TimeUse::new();

    t.start(Some("connect"));
    sleep(Duration::from_millis(20));
    println!("connect = {:?}", t.stop(Some("connect")));

    t.start(Some("query"));
    sleep(Duration::from_millis(40));
    println!("query   = {:?}", t.stop(Some("query")));

    sleep(Duration::from_millis(10));
    println!("total   = {:?}", t.stop(None));
}

#[cfg(not(feature = "time"))]
fn main() {
    eprintln!("Run with --features time");
}