Crates.io | zeitstempel |
lib.rs | zeitstempel |
version | 0.1.1 |
source | src |
created_at | 2021-03-03 16:36:37.279101 |
updated_at | 2021-03-18 08:09:24.121672 |
description | A timestamp you can serialize, and it might include suspend time. |
homepage | |
repository | https://github.com/badboy/zeitstempel |
max_upload_size | |
id | 363258 |
size | 30,089 |
zeitstempel is German for "timestamp".
Time's hard. Correct time is near impossible.
This crate has one purpose: give me a timestamp as an integer, coming from a monotonic clock source, include time across suspend/hibernation of the host machine and let me compare it to other timestamps.
It becomes the developer's responsibility to only compare timestamps obtained from this clock source. Timestamps are not comparable across operating system reboots.
std::time::Instant
?std::time::Instant
fulfills some of our requirements:
However:
use std::{thread, time::Duration};
let start = zeitstempel::now();
thread::sleep(Duration::from_millis(2));
let diff = Duration::from_nanos(zeitstempel::now() - start);
assert!(diff >= Duration::from_millis(2));
We support the following operating systems:
For other operating systems there's a fallback to std::time::Instant
,
compared against a process-global fixed reference point.
We don't guarantee that measured time includes time the system spends in sleep or hibernation.
* To use native Windows 10 functionality enable the win10plus
feature. Otherwise it will use the fallback.
MPL 2.0. See LICENSE.