Duration



examples/datetime/duration/src/main.rs
fn main() {
    let duration = std::time::Duration::from_secs(3);
    println!("as is       {:?}", duration);
    println!("as seconds: {:?}", duration.as_secs());
    println!("as millis:  {:?}", duration.as_millis());
    println!("as micros:  {:?}", duration.as_micros());
    println!("as nanos:   {:?}", duration.as_nanos());
    println!();

    let dur = std::time::Duration::new(2, 4);
    println!("{:?}", dur);
    println!("as seconds: {:?}", dur.as_secs());
    println!();

    let d = duration + dur;
    println!("{:?}", d);

    let d = duration - dur;
    println!("{:?}", d);
}

as is       3s
as seconds: 3
as millis:  3000
as micros:  3000000
as nanos:   3000000000

2.000000004s
as seconds: 2

5.000000004s
999.999996ms