diff options
-rw-r--r-- | src/main.rs | 9 | ||||
-rw-r--r-- | src/ui/widgets/tui_footer.rs | 4 | ||||
-rw-r--r-- | src/util/format.rs | 2 |
3 files changed, 12 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 3e2b8bc..03bf646 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,6 +77,15 @@ lazy_static! { static ref HOME_DIR: Option<PathBuf> = dirs_next::home_dir(); static ref USERNAME: String = whoami::username(); static ref HOSTNAME: String = whoami::hostname(); + + static ref TIMEZONE_STR: String = { + let offset = chrono::Local::now().offset().local_minus_utc() / 3600; + if offset.is_positive() { + format!(" UTC+{} ", offset.abs()) + } else { + format!(" UTC-{} ", offset.abs()) + } + }; } #[derive(Clone, Debug, StructOpt)] diff --git a/src/ui/widgets/tui_footer.rs b/src/ui/widgets/tui_footer.rs index adfe90d..dc42ee6 100644 --- a/src/ui/widgets/tui_footer.rs +++ b/src/ui/widgets/tui_footer.rs @@ -8,7 +8,7 @@ use crate::config::option::TabDisplayOption; use crate::fs::{JoshutoDirList, LinkType}; use crate::util::format; use crate::util::unix; -use crate::THEME_T; +use crate::{THEME_T, TIMEZONE_STR}; pub struct TuiFooter<'a> { dirlist: &'a JoshutoDirList, @@ -73,7 +73,7 @@ impl<'a> Widget for TuiFooter<'a> { Span::raw(format!("{}/{}", i + 1, self.dirlist.len())), Span::raw(" "), Span::raw(mtime_str), - Span::raw(" UTC "), + Span::raw(TIMEZONE_STR.as_str()), Span::raw(size_str), Span::raw(" "), Span::styled( diff --git a/src/util/format.rs b/src/util/format.rs index cd73605..0c515bb 100644 --- a/src/util/format.rs +++ b/src/util/format.rs @@ -23,6 +23,6 @@ pub fn file_size_to_string(file_size: u64) -> String { pub fn mtime_to_string(mtime: time::SystemTime) -> String { const MTIME_FORMATTING: &str = "%Y-%m-%d %H:%M"; - let datetime: chrono::DateTime<chrono::offset::Utc> = mtime.into(); + let datetime: chrono::DateTime<chrono::offset::Local> = mtime.into(); datetime.format(MTIME_FORMATTING).to_string() } |