Pass FileTimes to uu_touch

This commit is contained in:
ysthakur 2024-03-21 13:28:00 -04:00
parent e1506c57ff
commit acacb3450a
2 changed files with 20 additions and 4 deletions

18
Cargo.lock generated
View File

@ -658,9 +658,9 @@ dependencies = [
[[package]]
name = "chrono"
version = "0.4.34"
version = "0.4.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b"
checksum = "8eaf5903dcbc0a39312feb77df2ff4c76387d591b9fc7b04a238dcf8bb62639a"
dependencies = [
"android-tzdata",
"iana-time-zone",
@ -2697,6 +2697,18 @@ dependencies = [
"libc",
]
[[package]]
name = "nix"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4"
dependencies = [
"bitflags 2.4.2",
"cfg-if",
"cfg_aliases",
"libc",
]
[[package]]
name = "nom"
version = "7.1.3"
@ -6209,7 +6221,7 @@ dependencies = [
"clap",
"glob",
"libc",
"nix 0.27.1",
"nix 0.28.0",
"once_cell",
"os_display",
"uucore_procs 0.0.24",

View File

@ -2,6 +2,7 @@ use std::io::ErrorKind;
use std::path::PathBuf;
use chrono::{DateTime, FixedOffset};
use filetime::FileTime;
use nu_engine::CallExt;
use nu_protocol::ast::Call;
@ -125,7 +126,10 @@ impl Command for UTouch {
right_span: date_span,
});
}
Source::Timestamp(timestamp.item.into())
Source::Timestamp(FileTime::from_unix_time(
timestamp.item.timestamp(),
timestamp.item.timestamp_subsec_nanos(),
))
} else if let Some(reference_file) = reference_file {
Source::Reference(reference_file)
} else {