diff --git a/src/datetime/mod.rs b/src/datetime/mod.rs index 63554a0fcd..967f6a5f72 100644 --- a/src/datetime/mod.rs +++ b/src/datetime/mod.rs @@ -93,7 +93,10 @@ impl DateTime { /// ``` #[inline] #[must_use] - pub fn from_naive_utc_and_offset(datetime: NaiveDateTime, offset: Tz::Offset) -> DateTime { + pub const fn from_naive_utc_and_offset( + datetime: NaiveDateTime, + offset: Tz::Offset, + ) -> DateTime { DateTime { datetime, offset } } @@ -655,14 +658,6 @@ impl DateTime { NaiveDateTime::from_timestamp_millis(millis).as_ref().map(NaiveDateTime::and_utc) } - // FIXME: remove when our MSRV is 1.61+ - // This method is used by `NaiveDateTime::and_utc` because `DateTime::from_naive_utc_and_offset` - // can't be made const yet. - // Trait bounds in const function / implementation blocks were not supported until 1.61. - pub(crate) const fn from_naive_utc(datetime: NaiveDateTime) -> Self { - DateTime { datetime, offset: Utc } - } - /// The Unix Epoch, 1970-01-01 00:00:00 UTC. pub const UNIX_EPOCH: Self = Self { datetime: NaiveDateTime::UNIX_EPOCH, offset: Utc }; } diff --git a/src/naive/datetime/mod.rs b/src/naive/datetime/mod.rs index e3daaa65f1..de9976de9e 100644 --- a/src/naive/datetime/mod.rs +++ b/src/naive/datetime/mod.rs @@ -1066,8 +1066,7 @@ impl NaiveDateTime { /// ``` #[must_use] pub const fn and_utc(&self) -> DateTime { - // FIXME: use `DateTime::from_naive_utc_and_offset` when our MSRV is 1.61+. - DateTime::from_naive_utc(*self) + DateTime::from_naive_utc_and_offset(*self, Utc) } /// The minimum possible `NaiveDateTime`.