feat(elements): able to convert Datetime into Utc

This commit is contained in:
PoiScript 2019-09-16 15:20:46 +08:00
parent 7d838b4c03
commit 94360097a8

View file

@ -66,6 +66,12 @@ mod chrono {
}
}
impl Into<DateTime<Utc>> for Datetime<'_> {
fn into(self) -> DateTime<Utc> {
(&self).into()
}
}
impl Into<NaiveDate> for &Datetime<'_> {
fn into(self) -> NaiveDate {
NaiveDate::from_ymd(self.year.into(), self.month.into(), self.day.into())
@ -87,6 +93,12 @@ mod chrono {
NaiveDateTime::new(self.into(), self.into())
}
}
impl Into<DateTime<Utc>> for &Datetime<'_> {
fn into(self) -> DateTime<Utc> {
DateTime::from_utc(self.into(), Utc)
}
}
}
#[cfg_attr(test, derive(PartialEq))]