use chrono::{DateTime, NaiveDateTime, TimeZone, Utc};
#[must_use]
pub fn datetime_to_ms(s: &str) -> Option<i64> {
let truncated = s.get(..15)?;
let naive = NaiveDateTime::parse_from_str(truncated, "%Y%m%dT%H%M%S").ok()?;
Some(Utc.from_utc_datetime(&naive).timestamp_millis())
}
#[must_use]
pub fn ms_to_display(ms: i64) -> String {
DateTime::from_timestamp_millis(ms).map_or_else(
|| "?".to_owned(),
|dt| dt.with_timezone(&chrono::Local).format("%Y-%m-%d %H:%M").to_string(),
)
}
#[must_use]
pub fn now_ms() -> i64 {
Utc::now().timestamp_millis()
}