use std::fmt;
use humantime::format_rfc3339_nanos;
pub struct Rfc3339Timestamp {
time: std::time::SystemTime,
}
impl Rfc3339Timestamp {
pub fn new(time: std::time::SystemTime) -> Self {
Rfc3339Timestamp { time }
}
}
impl fmt::Debug for Rfc3339Timestamp {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
struct TimestampValue<'a>(&'a Rfc3339Timestamp);
impl fmt::Debug for TimestampValue<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}
f.debug_tuple("Timestamp")
.field(&TimestampValue(self))
.finish()
}
}
impl fmt::Display for Rfc3339Timestamp {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
format_rfc3339_nanos(self.time).fmt(f)
}
}