mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-23 04:22:06 +00:00
Timestamps will need more work
This commit is contained in:
parent
4a5cb5361d
commit
b5d5509657
@ -5,51 +5,5 @@ mod inode;
|
||||
mod links;
|
||||
mod permissions;
|
||||
mod size;
|
||||
mod times;
|
||||
mod users;
|
||||
|
||||
use output::cell::TextCell;
|
||||
use output::colours::Colours;
|
||||
use fs::fields as f;
|
||||
|
||||
use datetime::{LocalDateTime, TimeZone, DatePiece};
|
||||
use datetime::fmt::DateFormat;
|
||||
use locale;
|
||||
|
||||
|
||||
|
||||
#[allow(trivial_numeric_casts)]
|
||||
impl f::Time {
|
||||
pub fn render(&self, colours: &Colours, tz: &Option<TimeZone>,
|
||||
date_and_time: &DateFormat<'static>, date_and_year: &DateFormat<'static>,
|
||||
time: &locale::Time, current_year: i64) -> TextCell {
|
||||
|
||||
// TODO(ogham): This method needs some serious de-duping!
|
||||
// zoned and local times have different types at the moment,
|
||||
// so it's tricky.
|
||||
|
||||
if let Some(ref tz) = *tz {
|
||||
let date = tz.to_zoned(LocalDateTime::at(self.0 as i64));
|
||||
|
||||
let datestamp = if date.year() == current_year {
|
||||
date_and_time.format(&date, time)
|
||||
}
|
||||
else {
|
||||
date_and_year.format(&date, time)
|
||||
};
|
||||
|
||||
TextCell::paint(colours.date, datestamp)
|
||||
}
|
||||
else {
|
||||
let date = LocalDateTime::at(self.0 as i64);
|
||||
|
||||
let datestamp = if date.year() == current_year {
|
||||
date_and_time.format(&date, time)
|
||||
}
|
||||
else {
|
||||
date_and_year.format(&date, time)
|
||||
};
|
||||
|
||||
TextCell::paint(colours.date, datestamp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
45
src/output/render/times.rs
Normal file
45
src/output/render/times.rs
Normal file
@ -0,0 +1,45 @@
|
||||
use output::cell::TextCell;
|
||||
use output::colours::Colours;
|
||||
use fs::fields as f;
|
||||
|
||||
use datetime::{LocalDateTime, TimeZone, DatePiece};
|
||||
use datetime::fmt::DateFormat;
|
||||
use locale;
|
||||
|
||||
|
||||
#[allow(trivial_numeric_casts)]
|
||||
impl f::Time {
|
||||
pub fn render(&self, colours: &Colours, tz: &Option<TimeZone>,
|
||||
date_and_time: &DateFormat<'static>, date_and_year: &DateFormat<'static>,
|
||||
time: &locale::Time, current_year: i64) -> TextCell {
|
||||
|
||||
// TODO(ogham): This method needs some serious de-duping!
|
||||
// zoned and local times have different types at the moment,
|
||||
// so it's tricky.
|
||||
|
||||
if let Some(ref tz) = *tz {
|
||||
let date = tz.to_zoned(LocalDateTime::at(self.0 as i64));
|
||||
|
||||
let datestamp = if date.year() == current_year {
|
||||
date_and_time.format(&date, time)
|
||||
}
|
||||
else {
|
||||
date_and_year.format(&date, time)
|
||||
};
|
||||
|
||||
TextCell::paint(colours.date, datestamp)
|
||||
}
|
||||
else {
|
||||
let date = LocalDateTime::at(self.0 as i64);
|
||||
|
||||
let datestamp = if date.year() == current_year {
|
||||
date_and_time.format(&date, time)
|
||||
}
|
||||
else {
|
||||
date_and_year.format(&date, time)
|
||||
};
|
||||
|
||||
TextCell::paint(colours.date, datestamp)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user