From d34ef0dd0392674d1a7a8f098b9c57945e96683a Mon Sep 17 00:00:00 2001 From: mustafa salih Date: Tue, 22 Dec 2020 07:30:27 +0300 Subject: Added rsblocks.yml file and yaml parser to customize --- src/date.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/date.rs') 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 + ) } -- cgit v1.2.3