diff --git a/src/datetime/mod.rs b/src/datetime/mod.rs index 7f7d9023c4..76be8543d6 100644 --- a/src/datetime/mod.rs +++ b/src/datetime/mod.rs @@ -874,11 +874,7 @@ impl DateTime { feature = "std", all( feature = "now", - not(all( - target_arch = "wasm32", - feature = "wasmbind", - not(any(target_os = "emscripten", target_os = "wasi")) - )) + any(not(target_arch = "wasm32"), target_os = "emscripten", target_os = "wasi") ) ))] pub(crate) fn try_from_system_time(t: std::time::SystemTime) -> Result, Error> { diff --git a/src/offset/local/mod.rs b/src/offset/local/mod.rs index bf476aac76..d9e59d350d 100644 --- a/src/offset/local/mod.rs +++ b/src/offset/local/mod.rs @@ -11,7 +11,7 @@ use rkyv::{Archive, Deserialize, Serialize}; use super::fixed::FixedOffset; use super::{MappedLocalTime, TimeZone}; -use crate::{DateTime, NaiveDateTime, Utc}; +use crate::NaiveDateTime; #[cfg(unix)] #[path = "unix.rs"] @@ -120,8 +120,8 @@ impl Local { /// Returns a `DateTime` which corresponds to the current date, time and offset from /// UTC. /// - /// See also the similar [`Utc::now()`] which returns `DateTime`, i.e. without the local - /// offset. + /// See also the similar [`Utc::now()`](crate::Utc::now) which returns `DateTime`, i.e. + /// without the local offset. /// /// # Example /// @@ -144,8 +144,14 @@ impl Local { /// let offset = FixedOffset::east(5 * 60 * 60).unwrap(); /// let now_with_offset = Local::now().with_timezone(&offset); /// ``` - pub fn now() -> DateTime { - Utc::now().with_timezone(&Local) + #[cfg(any( + not(target_arch = "wasm32"), + feature = "wasmbind", + target_os = "emscripten", + target_os = "wasi", + ))] + pub fn now() -> crate::DateTime { + crate::Utc::now().with_timezone(&Local) } } diff --git a/src/offset/utc.rs b/src/offset/utc.rs index 6efc289cca..919563a82c 100644 --- a/src/offset/utc.rs +++ b/src/offset/utc.rs @@ -4,23 +4,12 @@ //! The UTC (Coordinated Universal Time) time zone. use core::fmt; -#[cfg(all( - feature = "now", - not(all( - target_arch = "wasm32", - feature = "wasmbind", - not(any(target_os = "emscripten", target_os = "wasi")) - )) -))] -use std::time::SystemTime; #[cfg(any(feature = "rkyv-16", feature = "rkyv-32", feature = "rkyv-64"))] use rkyv::{Archive, Deserialize, Serialize}; use super::{FixedOffset, MappedLocalTime, Offset, TimeZone}; use crate::naive::NaiveDateTime; -#[cfg(feature = "now")] -use crate::DateTime; #[cfg(all(feature = "now", doc))] use crate::OutOfRange; @@ -82,14 +71,10 @@ impl Utc { /// Panics if the system clock is set to a time in the extremely distant past or future, such /// that it is out of the range representable by `DateTime`. It is assumed that this /// crate will no longer be in use by that time. - #[cfg(not(all( - target_arch = "wasm32", - feature = "wasmbind", - not(any(target_os = "emscripten", target_os = "wasi")) - )))] + #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten", target_os = "wasi"))] #[must_use] - pub fn now() -> DateTime { - DateTime::try_from_system_time(SystemTime::now()).expect( + pub fn now() -> crate::DateTime { + crate::DateTime::try_from_system_time(std::time::SystemTime::now()).expect( "system clock is set to a time extremely far into the past or future; cannot convert", ) } @@ -101,9 +86,9 @@ impl Utc { not(any(target_os = "emscripten", target_os = "wasi")) ))] #[must_use] - pub fn now() -> DateTime { + pub fn now() -> crate::DateTime { let now = js_sys::Date::new_0(); - DateTime::::from(now) + crate::DateTime::::from(now) } }