From ecea9a51a7ef1bbfc25a68d11f3d3baaba857a37 Mon Sep 17 00:00:00 2001 From: Polyhistorian Date: Wed, 27 Jul 2022 22:48:24 +0300 Subject: [PATCH] Simplify timestamp.rs implementations --- src/model/timestamp.rs | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/model/timestamp.rs b/src/model/timestamp.rs index 35730d64e39..043698831f9 100644 --- a/src/model/timestamp.rs +++ b/src/model/timestamp.rs @@ -113,6 +113,20 @@ cfg_if::cfg_if! { f.write_str(&s) } } + + impl std::ops::Deref for Timestamp { + type Target = DateTime; + + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + impl From> for Timestamp { + fn from(dt: DateTime) -> Self { + Self(dt.with_timezone(&Utc)) + } + } } else { use dep_time::format_description::well_known::Rfc3339; use dep_time::serde::rfc3339; @@ -196,11 +210,7 @@ cfg_if::cfg_if! { f.write_str(&s) } } - } -} -cfg_if::cfg_if! { - if #[cfg(feature = "time")] { impl std::ops::Deref for Timestamp { type Target = OffsetDateTime; @@ -214,20 +224,6 @@ cfg_if::cfg_if! { Self(dt) } } - } else if #[cfg(feature = "chrono")] { - impl std::ops::Deref for Timestamp { - type Target = DateTime; - - fn deref(&self) -> &Self::Target { - &self.0 - } - } - - impl From> for Timestamp { - fn from(dt: DateTime) -> Self { - Self(dt.with_timezone(&Utc)) - } - } } }