fedimovies/src/utils/datetime.rs

12 lines
345 B
Rust
Raw Normal View History

2023-01-22 20:40:05 +00:00
use chrono::{DateTime, Duration, NaiveDateTime, Utc};
2023-01-17 00:09:09 +00:00
pub fn get_min_datetime() -> DateTime<Utc> {
let native = NaiveDateTime::from_timestamp_opt(0, 0)
.expect("0 should be a valid argument");
DateTime::from_utc(native, Utc)
}
2023-01-22 20:40:05 +00:00
pub fn days_before_now(days: u32) -> DateTime<Utc> {
Utc::now() - Duration::days(days.into())
}