now_since_unix_epoch_ms now uses negative dates for times pre Unix-epoch

This commit is contained in:
Sebastian Thiel 2024-05-25 07:44:17 +02:00
parent 1eae74eb54
commit 9245e3458f
No known key found for this signature in database
GPG Key ID: 9CB5EE7895E8268B

View File

@ -16,10 +16,10 @@ pub fn now_since_unix_epoch_ms() -> i64 {
.elapsed()
.map(|d| i64::try_from(d.as_millis()).expect("no system date is this far in the future"))
.unwrap_or_else(|_| {
i64::try_from(
-i64::try_from(
UNIX_EPOCH
.duration_since(std::time::SystemTime::now())
.expect("a date in the past")
.expect("'now' is in the past")
.as_millis(),
)
.expect("no time is that far in the past")