1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
pub use self::{specs::*, timestamp::Timestamp, utils::*};
pub(crate) mod timestamp;
pub(crate) mod specs {
use chrono::{TimeZone, Utc};
pub trait Temporal {
fn timestamp(&self) -> i64;
}
pub trait TemporalExt<Tz: TimeZone = Utc>: Temporal {
fn now() -> chrono::DateTime<Tz>;
}
}
pub(crate) mod utils {
use chrono::{DateTime, TimeZone, Utc};
pub fn chrono_datetime_now() -> DateTime<Utc> {
Utc::now()
}
pub fn chrono_into_bson<T: TimeZone>(data: DateTime<T>) -> bson::DateTime {
bson::DateTime::from_chrono(data)
}
pub fn timestamp() -> i64 {
Utc::now().timestamp()
}
}