keepass/db/types/
times.rs1use chrono::NaiveDateTime;
2
3#[derive(Debug, Default, PartialEq, Eq, Clone)]
5#[non_exhaustive]
6pub struct Times {
7 pub last_modification: Option<NaiveDateTime>,
9}
10
11impl Times {
12 pub fn now() -> NaiveDateTime {
14 let timestamp = chrono::Utc::now().timestamp();
15 chrono::DateTime::from_timestamp(timestamp, 0).map_or(chrono::DateTime::UNIX_EPOCH.naive_utc(), |dt| dt.naive_utc())
16 }
17
18 pub fn new() -> Self {
20 Self { last_modification: Some(Self::now()) }
21 }
22}