Files
continuwuity/src/core/utils/time.rs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
419 B
Rust
Raw Normal View History

2024-07-03 00:57:50 +00:00
use std::time::{SystemTime, UNIX_EPOCH};
#[inline]
#[must_use]
#[allow(clippy::as_conversions)]
pub fn millis_since_unix_epoch() -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("time is valid")
.as_millis() as u64
}
2024-07-03 01:08:54 +00:00
#[must_use]
pub fn rfc2822_from_seconds(epoch: i64) -> String {
use chrono::{DateTime, Utc};
DateTime::<Utc>::from_timestamp(epoch, 0)
.unwrap_or_default()
.to_rfc2822()
}