Remove unnecessary wasm-specific code

This commit is contained in:
Paul Dicker 2023-06-06 14:02:25 +02:00 committed by Dirkjan Ochtman
parent 4ca58b74f6
commit afb1f1f214

View File

@ -95,33 +95,9 @@ impl Local {
}
/// Returns a `DateTime` which corresponds to the current date and time.
#[cfg(not(all(
target_arch = "wasm32",
feature = "wasmbind",
not(any(target_os = "emscripten", target_os = "wasi"))
)))]
#[must_use]
pub fn now() -> DateTime<Local> {
Utc::now().with_timezone(&Local)
}
/// Returns a `DateTime` which corresponds to the current date and time.
#[cfg(all(
target_arch = "wasm32",
feature = "wasmbind",
not(any(target_os = "emscripten", target_os = "wasi"))
))]
#[must_use]
pub fn now() -> DateTime<Local> {
use super::Utc;
let now: DateTime<Utc> = super::Utc::now();
// Workaround missing timezone logic in `time` crate
let offset =
FixedOffset::west_opt((js_sys::Date::new_0().get_timezone_offset() as i32) * 60)
.unwrap();
DateTime::from_utc(now.naive_utc(), offset)
}
}
impl TimeZone for Local {