nix-configs/programs/jrnl/src/utils.rs
2024-04-20 20:11:04 +02:00

16 lines
374 B
Rust

use chrono::{DateTime, FixedOffset};
pub fn format_datetime(ts: DateTime<FixedOffset>) -> String {
ts.format("%A, %-d. %B %Y %R").to_string()
}
pub fn format_datetime_padded(ts: DateTime<FixedOffset>) -> String {
format!(
"{:>9}{}{:<9}{}",
ts.format("%A, "),
ts.format("%d. "),
ts.format("%B"),
ts.format(" %Y %R"),
)
}