}
fn naive_to_diff_utc(
naive: chrono::NaiveDateTime,
now: chrono::DateTime<chrono::Utc>,
) -> (chrono::DateTime<chrono::Utc>, chrono::Duration) {
let ts = chrono::DateTime::<chrono::Utc>::from_utc(naive, chrono::Utc);
(ts, now - ts)
}
fn diff_utc_to_string((ts, diff): (chrono::DateTime<chrono::Utc>, chrono::Duration)) -> String {
let (part, part_diff) = if diff.num_weeks() != 0 {
("weeks", diff.num_weeks())
} else if diff.num_days() != 0 {
("days", diff.num_days())
} else if diff.num_hours() != 0 {
("hours", diff.num_hours())
} else if diff.num_minutes() != 0 {
("minutes", diff.num_minutes())
} else {
("seconds", diff.num_seconds())
};
format!(
"{} ({} {})",
ts.format("%Y %b %d %H:%M UTC"),
part_diff,
part
)