use crate::*;
use chrono::{DateTime, Local, SecondsFormat};
#[derive(Debug, Clone, Copy)]
pub struct Time(DateTime<Local>);
impl Time {
pub(crate) fn new() -> Self {
Self(Local::now())
}
pub fn raw(&self) -> &DateTime<Local> {
&self.0
}
pub fn formatted(&self) -> String {
self.0.to_rfc3339_opts(SecondsFormat::Micros, true)
}
}
impl Output for Time {
fn for_write(&self, f: &mut impl std::fmt::Write) {
write!(f, "{}", self.formatted()).unwrap();
}
fn for_print(&self, f: &mut impl std::fmt::Write) {
write!(f, "{}", self.formatted()).unwrap();
}
}