diff --git a/src/builtins/ls.rs b/src/builtins/ls.rs index 521c107..88a1895 100644 --- a/src/builtins/ls.rs +++ b/src/builtins/ls.rs @@ -1,6 +1,6 @@ use std::{fs::metadata, path::PathBuf, str::FromStr}; -use chrono::{DateTime, Datelike, Local, Timelike}; +use chrono::{DateTime, Datelike, Local}; use crate::error::ShellError; @@ -69,14 +69,9 @@ fn format_filesize(filesize: u64) -> String { fn format_date(date: DateTime) -> String { let now: DateTime = Local::now(); if date.day() != now.day() || date.month() != now.month() || date.year() != now.year() { - format!("{}-{:02}-{:02}", date.year(), date.month(), date.day()) + date.format("%F").to_string() } else { - format!( - "{:02}:{:02}:{:02}", - date.hour(), - date.minute(), - date.second() - ) + date.format("%T").to_string() } }