浏览代码

correctly right-align timestamp column

Denis Cornehl 3 年之前
父节点
当前提交
2e9080d8b1
共有 2 个文件被更改,包括 7 次插入9 次删除
  1. 1 0
      src/output/table.rs
  2. 6 9
      src/output/time.rs

+ 1 - 0
src/output/table.rs

@@ -157,6 +157,7 @@ impl Column {
             Self::HardLinks  |
             Self::Inode      |
             Self::Blocks     |
+            Self::Timestamp(_) | 
             Self::GitStatus  => Alignment::Right,
             _                => Alignment::Left,
         }

+ 6 - 9
src/output/time.rs

@@ -122,15 +122,12 @@ fn long_zoned(time: SystemTime, zone: &TimeZone) -> String {
 
 #[allow(trivial_numeric_casts)]
 fn relative(time: SystemTime) -> String {
-    format!(
-        "{:>13}", 
-        timeago::Formatter::new().convert(
-            Duration::from_secs(
-                max(0, Instant::now().seconds() - systemtime_epoch(time))
-                // this .unwrap is safe since the call above can never result in a 
-                // value < 0
-                .try_into().unwrap()
-            )
+    timeago::Formatter::new().convert(
+        Duration::from_secs(
+            max(0, Instant::now().seconds() - systemtime_epoch(time))
+            // this .unwrap is safe since the call above can never result in a 
+            // value < 0
+            .try_into().unwrap()
         )
     )
 }