scsys-time 0.3.2

temporal abstractions, primitives, and utilities for the scsys ecosystem
Documentation
/*
    Appellation: time <test>
    Contrib: @FL03
*/
use core::time::Duration;
use scsys_time::{Timestamp, systime};

fn absdiff<A, B, C>(a: A, b: B) -> C
where
    A: PartialOrd<B> + core::ops::Sub<B, Output = C>,
    B: core::ops::Sub<A, Output = C>,
{
    if a > b { a - b } else { b - a }
}

#[test]
fn test_timestamp() {
    let now = systime();
    let ts = Timestamp::<u128>::now();

    let tsd = Duration::from_millis(ts.0 as u64);
    assert!(absdiff(now, tsd) < Duration::from_millis(1));
}