diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-01-07 10:41:50 -0500 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-01-07 10:41:50 -0500 |
commit | 9656a03394ae931b7b1bf4e359e9caabcde5dd9e (patch) | |
tree | 8a71bc9ce1304a4acf988a9ae59fb91637602ee9 | |
parent | 7771167a9b86853dc3947d35f90c89a28e279873 (diff) |
add support for showing file modified time
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/joshuto/ui.rs | 15 |
2 files changed, 15 insertions, 1 deletions
@@ -8,6 +8,7 @@ license = "LGPL-3" [dependencies] clap = "2.32.0" +chrono = "0.4.6" fs_extra = "1.1.0" lazy_static = "1.2.0" libc = "0.2.46" diff --git a/src/joshuto/ui.rs b/src/joshuto/ui.rs index e4072ea..2815226 100644 --- a/src/joshuto/ui.rs +++ b/src/joshuto/ui.rs @@ -1,8 +1,10 @@ extern crate ncurses; extern crate wcwidth; +extern crate chrono; use std::fs; use std::path; +use std::time; use joshuto::structs; use joshuto::config::theme; @@ -144,7 +146,14 @@ fn wprint_file_size(win: ncurses::WINDOW, mut file_size: f64) ncurses::waddstr(win, format!("{:.2}{}", file_size, FILE_UNITS[index]).as_str()); } - ncurses::waddstr(win, " "); +} + +pub fn wprint_file_mtime(win: ncurses::WINDOW, mtime: time::SystemTime) +{ + const MTIME_FORMATTING: &str = "%Y-%m-%d %H:%M"; + + let datetime: chrono::DateTime<chrono::offset::Utc> = mtime.into(); + ncurses::waddstr(win, format!("{}", datetime.format(MTIME_FORMATTING)).as_str()); } pub fn wprint_file_info(win: ncurses::WINDOW, file: &structs::JoshutoDirEntry) @@ -159,6 +168,10 @@ pub fn wprint_file_info(win: ncurses::WINDOW, file: &structs::JoshutoDirEntry) ncurses::waddstr(win, unix::stringify_mode(mode).as_str()); ncurses::waddstr(win, " "); + wprint_file_mtime(win, file.metadata.modified); + + ncurses::waddstr(win, " "); + if file.metadata.file_type.is_dir() { } else if file.path.is_dir() { if mode >> 9 & unix::S_IFLNK >> 9 == mode >> 9 { |