tiempo-rs/src/time.rs

36 lines
639 B
Rust

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<Utc>);
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<DateTime<Utc>> for Time {
fn from(dt: DateTime<Utc>) -> Time {
Time(dt)
}
}
impl FromStr for Time {
type Err = error::Error;
fn from_str(s: &str) -> error::Result<Time> {
unimplemented!()
}
}