From 02b3386ed62e5bc7b4ebe0256665b5a7d424b336 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 26 Mar 2023 00:42:03 -0400 Subject: replace chrono with time --- src/data.rs | 6 +++--- src/prompt.rs | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/data.rs b/src/data.rs index d30068e..3e761c1 100644 --- a/src/data.rs +++ b/src/data.rs @@ -12,7 +12,7 @@ pub struct PromptData { pub home: Option, pub user: Option, pub is_root: bool, - pub time: chrono::DateTime, + pub time: time::OffsetDateTime, pub power_info: power::PowerInfo, pub vcs_info: Option>, } @@ -92,8 +92,8 @@ fn is_root() -> bool { users::get_current_uid() == 0 } -fn time() -> chrono::DateTime { - chrono::Local::now() +fn time() -> time::OffsetDateTime { + time::OffsetDateTime::now_local().unwrap() } fn power_info() -> power::PowerInfo { diff --git a/src/prompt.rs b/src/prompt.rs index 1ab60d2..6c95c0e 100644 --- a/src/prompt.rs +++ b/src/prompt.rs @@ -181,11 +181,14 @@ impl Prompt { &self, t: &mut dyn term::Terminal, ) { + let desc = + time::format_description::parse("[hour]:[minute]:[second]") + .unwrap(); self.print_host(t, "["); self.colors.print( t, "default", - &format!("{}", self.data.time.format("%H:%M:%S")), + &self.data.time.format(&desc).unwrap(), ); self.print_host(t, "]"); } -- cgit v1.2.3-54-g00ecf