minitimer 0.1.7

A mini timer of delayed tasks. Only asynchronous tasks are possible on tokio runtime, and dynamic add/cancel/remove is supported.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::time::SystemTime;

/// Returns the current UNIX timestamp in seconds.
///
/// # Returns
/// The number of seconds since the UNIX epoch (1970-01-01 00:00:00 UTC).
///
/// # Panics
/// Panics if the system time is before the UNIX epoch.
pub fn timestamp() -> u64 {
    match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
        Ok(n) => n.as_secs(),
        Err(_) => panic!("SystemTime before UNIX EPOCH!"),
    }
}