diff --git a/src/lib.rs b/src/lib.rs index 2808abb5..d81cfe1e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -429,12 +429,6 @@ mod oldtime; // this reexport is to aid the transition and should not be in the prelude! pub use oldtime::Duration; -#[cfg(all( - feature = "clock", - not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind")) -))] -mod sys; - #[cfg(feature = "__doctest")] #[cfg_attr(feature = "__doctest", cfg(doctest))] use doc_comment::doctest; diff --git a/src/offset/local.rs b/src/offset/local.rs index 1e598f2b..13484507 100644 --- a/src/offset/local.rs +++ b/src/offset/local.rs @@ -7,12 +7,12 @@ use rkyv::{Archive, Deserialize, Serialize}; use super::fixed::FixedOffset; +#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind")))] +use super::sys::{self, Timespec}; use super::{LocalResult, TimeZone}; #[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind")))] use crate::naive::NaiveTime; use crate::naive::{NaiveDate, NaiveDateTime}; -#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind")))] -use crate::sys::{self, Timespec}; use crate::{Date, DateTime}; #[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind")))] use crate::{Datelike, Timelike}; diff --git a/src/offset/mod.rs b/src/offset/mod.rs index 237b5505..9ec96200 100644 --- a/src/offset/mod.rs +++ b/src/offset/mod.rs @@ -25,6 +25,12 @@ use crate::naive::{NaiveDate, NaiveDateTime, NaiveTime}; use crate::Weekday; use crate::{Date, DateTime}; +#[cfg(all( + feature = "clock", + not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind")) +))] +mod sys; + /// The conversion result from the local time to the timezone-aware datetime types. #[derive(Clone, PartialEq, Debug, Copy, Eq, Hash)] pub enum LocalResult { diff --git a/src/sys/mod.rs b/src/offset/sys/mod.rs similarity index 94% rename from src/sys/mod.rs rename to src/offset/sys/mod.rs index 25fd87a5..cc7ead33 100644 --- a/src/sys/mod.rs +++ b/src/offset/sys/mod.rs @@ -35,21 +35,21 @@ use inner::{local_tm_to_time, time_to_local_tm, utc_tm_to_time}; /// /// For example a timespec of 1.2 seconds after the beginning of the epoch would /// be represented as {sec: 1, nsec: 200000000}. -pub(crate) struct Timespec { - pub(crate) sec: i64, - pub(crate) nsec: i32, +pub(super) struct Timespec { + sec: i64, + nsec: i32, } impl Timespec { /// Constructs a timespec representing the current time in UTC. - pub(crate) fn now() -> Timespec { + pub(super) fn now() -> Timespec { let st = SystemTime::now().duration_since(UNIX_EPOCH).expect("system time before Unix epoch"); Timespec { sec: st.as_secs() as i64, nsec: st.subsec_nanos() as i32 } } /// Converts this timespec into the system's local time. - pub(crate) fn local(self) -> Tm { + pub(super) fn local(self) -> Tm { let mut tm = Tm { tm_sec: 0, tm_min: 0, @@ -118,7 +118,7 @@ pub(crate) struct Tm { impl Tm { /// Convert time to the seconds from January 1, 1970 - pub(crate) fn to_timespec(&self) -> Timespec { + pub(super) fn to_timespec(&self) -> Timespec { let sec = match self.tm_utcoff { 0 => utc_tm_to_time(self), _ => local_tm_to_time(self), diff --git a/src/sys/stub.rs b/src/offset/sys/stub.rs similarity index 100% rename from src/sys/stub.rs rename to src/offset/sys/stub.rs diff --git a/src/sys/unix.rs b/src/offset/sys/unix.rs similarity index 100% rename from src/sys/unix.rs rename to src/offset/sys/unix.rs diff --git a/src/sys/windows.rs b/src/offset/sys/windows.rs similarity index 100% rename from src/sys/windows.rs rename to src/offset/sys/windows.rs