lash-core 0.1.0-alpha.62

Sans-IO turn machine and runtime kernel for the lash agent runtime.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::time::{Duration, SystemTime, UNIX_EPOCH};

pub fn current_epoch_ms() -> u64 {
    <crate::SystemClock as crate::Clock>::timestamp_ms(&crate::SystemClock)
}

pub fn system_time_from_epoch_ms(epoch_ms: u64) -> SystemTime {
    UNIX_EPOCH + Duration::from_millis(epoch_ms)
}

pub fn epoch_ms_from_system_time(time: SystemTime) -> u64 {
    time.duration_since(UNIX_EPOCH)
        .unwrap_or_default()
        .as_millis() as u64
}