diff options
Diffstat (limited to 'src/date.rs')
-rw-r--r-- | src/date.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/date.rs b/src/date.rs index e5d4ebd..3254c11 100644 --- a/src/date.rs +++ b/src/date.rs @@ -1,11 +1,13 @@ -use std::process::Command; +use crate::load_config::Settings; +use chrono::prelude::*; -pub fn fmt_date(ft: &str) -> String { - let cmd = format!("date +\"{}\"", ft); - let cmd = Command::new("sh").arg("-c").args(&[cmd]).output().unwrap(); - let result = String::from_utf8_lossy(&cmd.stdout) - .to_string() - .trim() - .to_string(); - format!(" {} │", result) +pub fn fmt_date(setting: &Settings) -> String { + let now = Local::now(); + + format!( + " {} {} {}", + setting.time.icon, + now.format(&setting.time.format), + setting.seperator + ) } |