use std::str::FromStr; use chrono::{DateTime, Utc, TimeZone}; use crate::error; /// A time in UTC. /// /// Just a wrapper around Chrono::Utc #[derive(Debug)] pub struct Time(DateTime); impl Time { pub fn now() -> Time { Time(Utc::now()) } pub fn new(y: i32, mo: u32, d: u32, h: u32, mi: u32, s: u32) -> Time { Time(Utc.ymd(y, mo, d).and_hms(h, mi, s)) } } impl From> for Time { fn from(dt: DateTime) -> Time { Time(dt) } } impl FromStr for Time { type Err = error::Error; fn from_str(s: &str) -> error::Result