2017-07-03 07:45:14 +00:00
|
|
|
use datetime::TimeZone;
|
2017-08-20 19:29:23 +00:00
|
|
|
use ansi_term::Style;
|
2017-07-03 07:45:14 +00:00
|
|
|
|
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,
|
2017-08-20 19:29:23 +00:00
|
|
|
tz: &Option<TimeZone>,
|
|
|
|
format: &TimeFormat) -> TextCell {
|
2017-05-22 07:52:45 +00:00
|
|
|
|
|
|
|
if let Some(ref tz) = *tz {
|
2017-08-20 19:29:23 +00:00
|
|
|
let datestamp = format.format_zoned(self, tz);
|
|
|
|
TextCell::paint(style, datestamp)
|
2017-05-22 07:52:45 +00:00
|
|
|
}
|
|
|
|
else {
|
2017-08-20 19:29:23 +00:00
|
|
|
let datestamp = format.format_local(self);
|
|
|
|
TextCell::paint(style, datestamp)
|
2017-05-22 07:52:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|