From b780121e291bed43d5ee12c2e3b3879d7d5787df Mon Sep 17 00:00:00 2001 From: "zhuxiujia@qq.com" Date: Fri, 29 Dec 2023 18:55:17 +0800 Subject: [PATCH] update windows-sys --- Cargo.toml | 11 +++++++---- benches/bench.rs | 4 ++-- src/datetime.rs | 24 ++++++++++++++---------- src/sys/windows.rs | 27 ++++++++++++++------------- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0338fed..7ad47e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fastdate" -version = "0.3.27" +version = "0.3.28" edition = "2021" description = "Rust fast date carte" readme = "Readme.md" @@ -18,6 +18,9 @@ serde_json = "1" [target.'cfg(unix)'.dependencies] libc = "0.2" -[target.'cfg(windows)'.dependencies] -winapi = { version = "0.3", features = ["std", "minwinbase", "minwindef", "timezoneapi"] } - +[target.'cfg(windows)'.dependencies.windows-sys] +version = "0.52.0" +features = [ + "Win32_Foundation", + "Win32_System_Time", +] diff --git a/benches/bench.rs b/benches/bench.rs index fbfc2bc..37d6756 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -142,10 +142,10 @@ fn bench_from_timestamp_millis(b: &mut Bencher) { //181 ns/iter (+/- 2) #[bench] fn bench_format(b: &mut Bencher) { - let dt=DateTime::from_str("1997-12-13T11:12:13.123456+09:00").unwrap(); + let dt = DateTime::from_str("1997-12-13T11:12:13.123456+09:00").unwrap(); b.iter(|| { std::hint::black_box({ dt.format("YYYY-MM-DD/hh/mm/ss.000000"); }); }); -} \ No newline at end of file +} diff --git a/src/datetime.rs b/src/datetime.rs index 9613beb..7bc3e6b 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -178,7 +178,11 @@ impl DateTime { } write!(result, ".{:09}", self.nano()).unwrap() } else if result.ends_with(".000000") { - if (index + 3) < fmt.len() && chars[index + 1] == '0' as u8 && chars[index + 2] == '0' as u8 && chars[index + 3] == '0' as u8 { + if (index + 3) < fmt.len() + && chars[index + 1] == '0' as u8 + && chars[index + 2] == '0' as u8 + && chars[index + 3] == '0' as u8 + { index += 1; continue; } @@ -445,7 +449,7 @@ impl DateTime { Self { inner: time1::OffsetDateTime::from(s), } - .set_offset(offset) + .set_offset(offset) } /// stand "0000-00-00 00:00:00.000000000" @@ -656,7 +660,7 @@ impl From for DateTime { "{:04}-{:02}-{:02} 00:00:00.000000000Z", arg.year, arg.mon, arg.day )) - .unwrap() + .unwrap() } } @@ -675,7 +679,7 @@ impl From