tiempo-rs/src/time.rs

36 lines
639 B
Rust
Raw Normal View History

2021-06-18 11:27:19 -05:00
use std::str::FromStr;
use chrono::{DateTime, Utc, TimeZone};
2021-06-18 11:27:19 -05:00
use crate::error;
/// A time in UTC.
///
/// Just a wrapper around Chrono::Utc
#[derive(Debug)]
pub struct Time(DateTime<Utc>);
2021-06-18 11:27:19 -05:00
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)
2021-06-18 11:27:19 -05:00
}
}
impl FromStr for Time {
type Err = error::Error;
fn from_str(s: &str) -> error::Result<Time> {
unimplemented!()
}
}