aboutsummaryrefslogtreecommitdiff
path: root/src/date.rs
diff options
context:
space:
mode:
authormustafa salih <mustafasalih1991@gmail.com>2020-12-22 07:30:27 +0300
committermustafa salih <mustafasalih1991@gmail.com>2020-12-22 07:30:27 +0300
commitd34ef0dd0392674d1a7a8f098b9c57945e96683a (patch)
treec55292749bfefcc6ac8643e2933949bf72973f63 /src/date.rs
parent7075f7cf2889076df5f932b17489eee01c6bcccd (diff)
Added rsblocks.yml file and yaml parser to customize
Diffstat (limited to 'src/date.rs')
-rw-r--r--src/date.rs20
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
+ )
}