mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
date: replace nix by rustix
This commit is contained in:
Generated
+2
-1
@@ -3442,9 +3442,10 @@ dependencies = [
|
||||
"icu_locale",
|
||||
"jiff",
|
||||
"jiff-icu",
|
||||
"nix",
|
||||
"libc",
|
||||
"parse_datetime",
|
||||
"regex",
|
||||
"rustix",
|
||||
"tempfile",
|
||||
"uucore",
|
||||
"windows-sys 0.61.2",
|
||||
|
||||
Generated
+2
-1
@@ -1970,9 +1970,10 @@ dependencies = [
|
||||
"icu_locale",
|
||||
"jiff",
|
||||
"jiff-icu",
|
||||
"nix",
|
||||
"libc",
|
||||
"parse_datetime",
|
||||
"regex",
|
||||
"rustix",
|
||||
"uucore",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
@@ -44,7 +44,8 @@ regex = { workspace = true }
|
||||
uucore = { workspace = true, features = ["parser", "i18n-datetime"] }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
nix = { workspace = true, features = ["time"] }
|
||||
libc = { workspace = true }
|
||||
rustix = { workspace = true, features = ["time"] }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
windows-sys = { workspace = true, features = [
|
||||
|
||||
+11
-7
@@ -985,12 +985,12 @@ fn get_clock_resolution() -> Timestamp {
|
||||
/// as `CLOCK_REALTIME` is required to be supported.
|
||||
/// Failure would indicate a non-conforming or otherwise broken implementation.
|
||||
fn get_clock_resolution() -> Timestamp {
|
||||
use nix::time::{ClockId, clock_getres};
|
||||
use rustix::time::{ClockId, clock_getres};
|
||||
|
||||
let timespec = clock_getres(ClockId::CLOCK_REALTIME).unwrap();
|
||||
let timespec = clock_getres(ClockId::Realtime);
|
||||
|
||||
#[allow(clippy::unnecessary_cast)] // Cast required on 32-bit platforms
|
||||
Timestamp::constant(timespec.tv_sec() as _, timespec.tv_nsec() as _)
|
||||
#[allow(clippy::unnecessary_cast, reason = "needed for 32 bit target")]
|
||||
Timestamp::constant(timespec.tv_sec as _, timespec.tv_nsec as _)
|
||||
}
|
||||
|
||||
#[cfg(all(unix, target_os = "redox"))]
|
||||
@@ -1047,12 +1047,16 @@ fn set_system_datetime(_date: Zoned) -> UResult<()> {
|
||||
/// `<https://linux.die.net/man/3/clock_settime>`
|
||||
/// `<https://www.gnu.org/software/libc/manual/html_node/Time-Types.html>`
|
||||
fn set_system_datetime(date: Zoned) -> UResult<()> {
|
||||
use nix::{sys::time::TimeSpec, time::ClockId};
|
||||
use rustix::time::{ClockId, Timespec, clock_settime};
|
||||
|
||||
let ts = date.timestamp();
|
||||
let timespec = TimeSpec::new(ts.as_second() as _, ts.subsec_nanosecond() as _);
|
||||
let timespec = Timespec {
|
||||
tv_sec: ts.as_second() as _,
|
||||
tv_nsec: ts.subsec_nanosecond() as _,
|
||||
};
|
||||
|
||||
nix::time::clock_settime(ClockId::CLOCK_REALTIME, timespec)
|
||||
clock_settime(ClockId::Realtime, timespec)
|
||||
.map_err(std::io::Error::from)
|
||||
.map_err_context(|| translate!("date-error-cannot-set-date"))
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ macro_rules! cfg_langinfo {
|
||||
cfg_langinfo! {
|
||||
use std::ffi::CStr;
|
||||
use std::sync::OnceLock;
|
||||
use nix::libc;
|
||||
|
||||
#[cfg(test)]
|
||||
use std::sync::Mutex;
|
||||
|
||||
Reference in New Issue
Block a user