diff options
author | Jesse Luehrs <doy@tozt.net> | 2023-03-26 00:42:03 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2023-03-26 00:42:03 -0400 |
commit | 02b3386ed62e5bc7b4ebe0256665b5a7d424b336 (patch) | |
tree | c5d7d6cbdfe0a61b1fc460a4a1ae5eddec1c60e2 /src | |
parent | 222bc5c66f7a4b80c04e805b72c70d0385784b25 (diff) | |
download | fancy-prompt-02b3386ed62e5bc7b4ebe0256665b5a7d424b336.tar.gz fancy-prompt-02b3386ed62e5bc7b4ebe0256665b5a7d424b336.zip |
replace chrono with time
Diffstat (limited to 'src')
-rw-r--r-- | src/data.rs | 6 | ||||
-rw-r--r-- | src/prompt.rs | 5 |
2 files changed, 7 insertions, 4 deletions
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<std::path::PathBuf>, pub user: Option<String>, pub is_root: bool, - pub time: chrono::DateTime<chrono::Local>, + pub time: time::OffsetDateTime, pub power_info: power::PowerInfo, pub vcs_info: Option<Box<dyn vcs::VcsInfo>>, } @@ -92,8 +92,8 @@ fn is_root() -> bool { users::get_current_uid() == 0 } -fn time() -> chrono::DateTime<chrono::Local> { - 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<Output = W>, ) { + 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, "]"); } |