exa/src/output/render/times.rs

29 lines
746 B
Rust
Raw Normal View History

use datetime::TimeZone;
use ansi_term::Style;
2018-12-07 23:43:31 +00:00
use crate::output::cell::TextCell;
use crate::output::time::TimeFormat;
2017-05-22 07:52:45 +00:00
2018-12-17 01:51:55 +00:00
pub trait Render {
fn render(self, style: Style,
tz: &Option<TimeZone>,
format: &TimeFormat) -> TextCell;
}
impl Render for std::time::Duration {
fn render(self, style: Style,
tz: &Option<TimeZone>,
format: &TimeFormat) -> TextCell {
2017-05-22 07:52:45 +00:00
if let Some(ref tz) = *tz {
let datestamp = format.format_zoned(self, tz);
TextCell::paint(style, datestamp)
2017-05-22 07:52:45 +00:00
}
else {
let datestamp = format.format_local(self);
TextCell::paint(style, datestamp)
2017-05-22 07:52:45 +00:00
}
}
}