1use chrono::{TimeZone, Utc};
2use std::time::{SystemTime, UNIX_EPOCH};
3
4pub fn unix_epoch_timestamp() -> usize {
6 let right_now = SystemTime::now();
7 let time_since = right_now
8 .duration_since(UNIX_EPOCH)
9 .expect("Time travel is not allowed");
10
11 time_since.as_millis() as usize
12}
13
14pub fn epoch_timestamp(year: u32) -> i64 {
16 let now = Utc::now().timestamp_millis();
17 let then = Utc
18 .with_ymd_and_hms(year as i32, 1, 1, 0, 0, 0)
19 .unwrap()
20 .timestamp_millis();
21
22 now - then
23}