From 94360097a83f03230fc4c6222cacb1ce106e55cd Mon Sep 17 00:00:00 2001 From: PoiScript Date: Mon, 16 Sep 2019 15:20:46 +0800 Subject: [PATCH] feat(elements): able to convert Datetime into Utc --- orgize/src/elements/timestamp.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/orgize/src/elements/timestamp.rs b/orgize/src/elements/timestamp.rs index 9115dba..dfe3a31 100644 --- a/orgize/src/elements/timestamp.rs +++ b/orgize/src/elements/timestamp.rs @@ -66,6 +66,12 @@ mod chrono { } } + impl Into> for Datetime<'_> { + fn into(self) -> DateTime { + (&self).into() + } + } + impl Into 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> for &Datetime<'_> { + fn into(self) -> DateTime { + DateTime::from_utc(self.into(), Utc) + } + } } #[cfg_attr(test, derive(PartialEq))]