|
|
@@ -13,7 +13,7 @@ use pad::Alignment;
|
|
|
use number_prefix::{binary_prefix, decimal_prefix, Prefixed, Standalone, PrefixNames};
|
|
|
|
|
|
use datetime;
|
|
|
-use datetime::local::LocalDateTime;
|
|
|
+use datetime::local::{LocalDateTime, DatePiece};
|
|
|
|
|
|
use column::{Column, Cell};
|
|
|
use column::Column::*;
|
|
|
@@ -99,15 +99,15 @@ impl<'a> File<'a> {
|
|
|
/// Get the data for a column, formatted as a coloured string.
|
|
|
pub fn display<U: Users>(&self, column: &Column, users_cache: &mut U) -> Cell {
|
|
|
match *column {
|
|
|
- Permissions => self.permissions_string(),
|
|
|
- FileSize(f) => self.file_size(f),
|
|
|
- Timestamp(t) => self.timestamp(t),
|
|
|
- HardLinks => self.hard_links(),
|
|
|
- Inode => self.inode(),
|
|
|
- Blocks => self.blocks(),
|
|
|
- User => self.user(users_cache),
|
|
|
- Group => self.group(users_cache),
|
|
|
- GitStatus => self.git_status(),
|
|
|
+ Permissions => self.permissions_string(),
|
|
|
+ FileSize(f) => self.file_size(f),
|
|
|
+ Timestamp(t, y) => self.timestamp(t, y),
|
|
|
+ HardLinks => self.hard_links(),
|
|
|
+ Inode => self.inode(),
|
|
|
+ Blocks => self.blocks(),
|
|
|
+ User => self.user(users_cache),
|
|
|
+ Group => self.group(users_cache),
|
|
|
+ GitStatus => self.git_status(),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -303,8 +303,7 @@ impl<'a> File<'a> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fn timestamp(&self, time_type: TimeType) -> Cell {
|
|
|
- let format = date_format!("{:Y} {:M} {2>:D} {2>:h}:{02>:m}");
|
|
|
+ fn timestamp(&self, time_type: TimeType, current_year: i64) -> Cell {
|
|
|
|
|
|
// Need to convert these values from milliseconds into seconds.
|
|
|
let time_in_seconds = match time_type {
|
|
|
@@ -314,6 +313,14 @@ impl<'a> File<'a> {
|
|
|
} as i64 / 1000;
|
|
|
|
|
|
let date = LocalDateTime::at(time_in_seconds);
|
|
|
+
|
|
|
+ let format = if date.year() == current_year {
|
|
|
+ date_format!("{2>:D} {:M} {2>:h}:{02>:m}")
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ date_format!("{2>:D} {:M} {4>:Y}")
|
|
|
+ };
|
|
|
+
|
|
|
Cell::paint(Blue.normal(), format.format(date).as_slice())
|
|
|
}
|
|
|
|