Split core and TUI crates
This commit is contained in:
9
crates/tele-core/src/utils.rs
Normal file
9
crates/tele-core/src/utils.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
use chrono::{DateTime, Local, NaiveDate, Utc};
|
||||
|
||||
pub fn get_day(timestamp: i32) -> i64 {
|
||||
let epoch = NaiveDate::from_ymd_opt(1970, 1, 1).expect("valid epoch date");
|
||||
let msg_day = DateTime::<Utc>::from_timestamp(timestamp as i64, 0)
|
||||
.map(|dt| dt.with_timezone(&Local).date_naive())
|
||||
.unwrap_or(epoch);
|
||||
msg_day.signed_duration_since(epoch).num_days()
|
||||
}
|
||||
Reference in New Issue
Block a user