Merge pull request #3858 from Byron/quick-fix

`now_since_unix_epoch_ms` now uses negative dates for times pre Unix-epoch
This commit is contained in:
Sebastian Thiel 2024-05-25 08:17:50 +02:00 committed by GitHub
commit 1dc8988c3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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")