From a730f60cc0e3a46ae869098ea8355cd3e4c4bee1 Mon Sep 17 00:00:00 2001 From: Ray Kohler Date: Mon, 4 Aug 2025 08:40:02 -0400 Subject: fix: honor timezone in inspector stats (#2853) * fix: honor timezone in inspector stats fixes: #2567 * docs: fix rustdoc warning about URL markup * fix: pass timezone by value, as suggested by clippy (oops) --- crates/atuin-client/src/settings.rs | 2 +- crates/atuin/src/command/client/search/inspector.rs | 11 ++++++++--- crates/atuin/src/command/client/search/interactive.rs | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/atuin-client/src/settings.rs b/crates/atuin-client/src/settings.rs index 2ffba5e4..87fe8d32 100644 --- a/crates/atuin-client/src/settings.rs +++ b/crates/atuin-client/src/settings.rs @@ -134,7 +134,7 @@ impl From for interim::Dialect { /// Note that the parsing of this struct needs to be done before starting any /// multithreaded runtime, otherwise it will fail on most Unix systems. /// -/// See: https://github.com/atuinsh/atuin/pull/1517#discussion_r1447516426 +/// See: #[derive(Clone, Copy, Debug, Eq, PartialEq, DeserializeFromStr, Serialize)] pub struct Timezone(pub UtcOffset); impl fmt::Display for Timezone { diff --git a/crates/atuin/src/command/client/search/inspector.rs b/crates/atuin/src/command/client/search/inspector.rs index 4201ba30..079eab28 100644 --- a/crates/atuin/src/command/client/search/inspector.rs +++ b/crates/atuin/src/command/client/search/inspector.rs @@ -3,7 +3,7 @@ use time::macros::format_description; use atuin_client::{ history::{History, HistoryStats}, - settings::Settings, + settings::{Settings, Timezone}, }; use ratatui::{ Frame, @@ -85,6 +85,7 @@ pub fn draw_stats_table( f: &mut Frame<'_>, parent: Rect, history: &History, + tz: Timezone, stats: &HistoryStats, theme: &Theme, ) { @@ -95,7 +96,10 @@ pub fn draw_stats_table( let rows = [ Row::new(vec!["Host".to_string(), host.to_string()]), Row::new(vec!["User".to_string(), user.to_string()]), - Row::new(vec!["Time".to_string(), history.timestamp.to_string()]), + Row::new(vec![ + "Time".to_string(), + history.timestamp.to_offset(tz.0).to_string(), + ]), Row::new(vec!["Duration".to_string(), format_duration(duration)]), Row::new(vec![ "Avg duration".to_string(), @@ -255,6 +259,7 @@ pub fn draw( history: &History, stats: &HistoryStats, theme: &Theme, + tz: Timezone, ) { let vert_layout = Layout::default() .direction(Direction::Vertical) @@ -267,7 +272,7 @@ pub fn draw( .split(vert_layout[1]); draw_commands(f, vert_layout[0], history, stats, theme); - draw_stats_table(f, stats_layout[0], history, stats, theme); + draw_stats_table(f, stats_layout[0], history, tz, stats, theme); draw_stats_charts(f, stats_layout[1], stats, theme); } diff --git a/crates/atuin/src/command/client/search/interactive.rs b/crates/atuin/src/command/client/search/interactive.rs index 41f6a961..d58052b1 100644 --- a/crates/atuin/src/command/client/search/interactive.rs +++ b/crates/atuin/src/command/client/search/interactive.rs @@ -762,6 +762,7 @@ impl State { &results[self.results_state.selected()], &stats.expect("Drawing inspector, but no stats"), theme, + settings.timezone, ); } -- cgit v1.3.1