Remove year field on timestamp column

It's now in the locals of the Table struct, and didn't really belong in the column anyway.
This commit is contained in:
Ben S 2015-05-12 03:02:38 +01:00
parent 7f48748e70
commit 5af0f5793e
3 changed files with 22 additions and 26 deletions

View File

@ -11,7 +11,7 @@ use unicode_width::UnicodeWidthStr;
pub enum Column { pub enum Column {
Permissions, Permissions,
FileSize(SizeFormat), FileSize(SizeFormat),
Timestamp(TimeType, i64), Timestamp(TimeType),
Blocks, Blocks,
User, User,
Group, Group,
@ -46,15 +46,15 @@ impl Column {
/// to have a header row printed. /// to have a header row printed.
pub fn header(&self) -> &'static str { pub fn header(&self) -> &'static str {
match *self { match *self {
Column::Permissions => "Permissions", Column::Permissions => "Permissions",
Column::FileSize(_) => "Size", Column::FileSize(_) => "Size",
Column::Timestamp(t, _) => t.header(), Column::Timestamp(t) => t.header(),
Column::Blocks => "Blocks", Column::Blocks => "Blocks",
Column::User => "User", Column::User => "User",
Column::Group => "Group", Column::Group => "Group",
Column::HardLinks => "Links", Column::HardLinks => "Links",
Column::Inode => "inode", Column::Inode => "inode",
Column::GitStatus => "Git", Column::GitStatus => "Git",
} }
} }
} }

View File

@ -15,8 +15,6 @@ use std::os::unix::fs::MetadataExt;
use getopts; use getopts;
use natord; use natord;
use datetime::local::{LocalDateTime, DatePiece};
use self::Misfire::*; use self::Misfire::*;
/// The *Options* struct represents a parsed version of the user's /// The *Options* struct represents a parsed version of the user's
@ -555,18 +553,16 @@ impl Columns {
columns.push(Group); columns.push(Group);
} }
let current_year = LocalDateTime::now().year();
if self.time_types.modified { if self.time_types.modified {
columns.push(Timestamp(TimeType::FileModified, current_year)); columns.push(Timestamp(TimeType::FileModified));
} }
if self.time_types.created { if self.time_types.created {
columns.push(Timestamp(TimeType::FileCreated, current_year)); columns.push(Timestamp(TimeType::FileCreated));
} }
if self.time_types.accessed { if self.time_types.accessed {
columns.push(Timestamp(TimeType::FileAccessed, current_year)); columns.push(Timestamp(TimeType::FileAccessed));
} }
if cfg!(feature="git") { if cfg!(feature="git") {

View File

@ -183,15 +183,15 @@ impl Table {
fn display(&mut self, file: &File, column: &Column) -> Cell { fn display(&mut self, file: &File, column: &Column) -> Cell {
match *column { match *column {
Column::Permissions => self.render_permissions(file.permissions()), Column::Permissions => self.render_permissions(file.permissions()),
Column::FileSize(fmt) => self.render_size(file.size(), fmt), Column::FileSize(fmt) => self.render_size(file.size(), fmt),
Column::Timestamp(t, _) => self.render_time(file.timestamp(t)), Column::Timestamp(t) => self.render_time(file.timestamp(t)),
Column::HardLinks => self.render_links(file.links()), Column::HardLinks => self.render_links(file.links()),
Column::Inode => self.render_inode(file.inode()), Column::Inode => self.render_inode(file.inode()),
Column::Blocks => self.render_blocks(file.blocks()), Column::Blocks => self.render_blocks(file.blocks()),
Column::User => self.render_user(file.user()), Column::User => self.render_user(file.user()),
Column::Group => self.render_group(file.group()), Column::Group => self.render_group(file.group()),
Column::GitStatus => self.render_git_status(file.git_status()), Column::GitStatus => self.render_git_status(file.git_status()),
} }
} }