From b609a7ef006086a6e234891b96a5d82a0f361d48 Mon Sep 17 00:00:00 2001 From: Ohad Ravid Date: Fri, 19 Jan 2024 08:55:51 +0200 Subject: [PATCH] Fix some clippy warnings --- src/datetime.rs | 5 ++++- src/lib.rs | 1 + src/utils.rs | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/datetime.rs b/src/datetime.rs index a37c582..d1df439 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -18,7 +18,10 @@ impl FromStr for WMIDateTime { let (datetime_part, tz_part) = s.split_at(21); let tz_min: i32 = tz_part.parse()?; let tz = FixedOffset::east_opt(tz_min * 60).unwrap(); - let dt = tz.datetime_from_str(datetime_part, "%Y%m%d%H%M%S.%f")?; + let dt = NaiveDateTime::parse_from_str(datetime_part, "%Y%m%d%H%M%S.%f")? + .and_local_timezone(tz) + .single() + .ok_or(WMIError::ParseDatetimeLocalError)?; Ok(Self(dt)) } diff --git a/src/lib.rs b/src/lib.rs index aaad3f7..0beade0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -262,6 +262,7 @@ #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(unused_unsafe)] +#![allow(clippy::arc_with_non_send_sync)] #![cfg(windows)] pub mod connection; diff --git a/src/utils.rs b/src/utils.rs index 4229cdb..7b6f6ff 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -16,6 +16,9 @@ pub enum WMIError { #[cfg(feature = "chrono")] #[error(transparent)] ParseDatetimeError(#[from] chrono::format::ParseError), + #[cfg(feature = "chrono")] + #[error("Cannot parse a non unique local timestamp")] + ParseDatetimeLocalError, #[cfg(feature = "time")] #[error(transparent)] ParseOffsetDatetimeError(#[from] time::Error),