diff --git a/Cargo.lock b/Cargo.lock index a788a8744..e17f84fd3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2308,7 +2308,7 @@ dependencies = [ "clap 4.0.17", "libc", "uucore", - "winapi", + "windows-sys 0.42.0", ] [[package]] diff --git a/src/uu/date/Cargo.toml b/src/uu/date/Cargo.toml index de504f8c5..ffca6d3a4 100644 --- a/src/uu/date/Cargo.toml +++ b/src/uu/date/Cargo.toml @@ -23,7 +23,7 @@ uucore = { version=">=0.0.16", package="uucore", path="../../uucore" } libc = "0.2" [target.'cfg(windows)'.dependencies] -winapi = { version = "0.3", features = ["minwinbase", "sysinfoapi", "minwindef"] } +windows-sys = { version = "0.42.0", default-features = false, features = ["Win32_Foundation", "Win32_System_SystemInformation"] } [[bin]] name = "date" diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index 43b54898d..076cdbf43 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -23,10 +23,7 @@ use uucore::error::FromIo; use uucore::error::{UResult, USimpleError}; use uucore::{format_usage, show_error}; #[cfg(windows)] -use winapi::{ - shared::minwindef::WORD, - um::{minwinbase::SYSTEMTIME, sysinfoapi::SetSystemTime}, -}; +use windows_sys::Win32::{Foundation::SYSTEMTIME, System::SystemInformation::SetSystemTime}; // Options const DATE: &str = "date"; @@ -409,16 +406,16 @@ fn set_system_datetime(date: DateTime) -> UResult<()> { /// https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-systemtime fn set_system_datetime(date: DateTime) -> UResult<()> { let system_time = SYSTEMTIME { - wYear: date.year() as WORD, - wMonth: date.month() as WORD, + wYear: date.year() as u16, + wMonth: date.month() as u16, // Ignored wDayOfWeek: 0, - wDay: date.day() as WORD, - wHour: date.hour() as WORD, - wMinute: date.minute() as WORD, - wSecond: date.second() as WORD, + wDay: date.day() as u16, + wHour: date.hour() as u16, + wMinute: date.minute() as u16, + wSecond: date.second() as u16, // TODO: be careful of leap seconds - valid range is [0, 999] - how to handle? - wMilliseconds: ((date.nanosecond() / 1_000_000) % 1000) as WORD, + wMilliseconds: ((date.nanosecond() / 1_000_000) % 1000) as u16, }; let result = unsafe { SetSystemTime(&system_time) };