mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Remove time dependency from date
Also upgrades humantime_to_duration to the latest version, it switched from time to chrono. Because touch still depends on time, its humantime_to_duration package version deviates from the workspace version.
This commit is contained in:
parent
82f5fec688
commit
42a22c12f1
5 changed files with 45 additions and 21 deletions
47
Cargo.lock
generated
47
Cargo.lock
generated
|
@ -272,7 +272,10 @@ checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android-tzdata",
|
"android-tzdata",
|
||||||
"iana-time-zone",
|
"iana-time-zone",
|
||||||
|
"js-sys",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
"time 0.1.45",
|
||||||
|
"wasm-bindgen",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -421,7 +424,7 @@ dependencies = [
|
||||||
"sha1",
|
"sha1",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"textwrap",
|
"textwrap",
|
||||||
"time",
|
"time 0.3.20",
|
||||||
"unindent",
|
"unindent",
|
||||||
"uu_arch",
|
"uu_arch",
|
||||||
"uu_base32",
|
"uu_base32",
|
||||||
|
@ -1079,7 +1082,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi",
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1151,7 +1154,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "714764645f21cc70c4c151d7798dd158409641f37ad820bed65224aae403cbed"
|
checksum = "714764645f21cc70c4c151d7798dd158409641f37ad820bed65224aae403cbed"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"regex",
|
"regex",
|
||||||
"time",
|
"time 0.3.20",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "humantime_to_duration"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e0a674b970a2bbad01671718ca07604ca89258dd5e25d9af835c14ac6e0bc792"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"regex",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1434,7 +1447,7 @@ checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"wasi",
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
"windows-sys 0.45.0",
|
"windows-sys 0.45.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2289,6 +2302,17 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time"
|
||||||
|
version = "0.1.45"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.3.20"
|
version = "0.3.20"
|
||||||
|
@ -2528,9 +2552,8 @@ version = "0.0.19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"humantime_to_duration",
|
"humantime_to_duration 0.3.0",
|
||||||
"libc",
|
"libc",
|
||||||
"time",
|
|
||||||
"uucore",
|
"uucore",
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
@ -3224,8 +3247,8 @@ version = "0.0.19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"filetime",
|
"filetime",
|
||||||
"humantime_to_duration",
|
"humantime_to_duration 0.2.1",
|
||||||
"time",
|
"time 0.3.20",
|
||||||
"uucore",
|
"uucore",
|
||||||
"windows-sys 0.48.0",
|
"windows-sys 0.48.0",
|
||||||
]
|
]
|
||||||
|
@ -3401,7 +3424,7 @@ dependencies = [
|
||||||
"sm3",
|
"sm3",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"time",
|
"time 0.3.20",
|
||||||
"uucore_procs",
|
"uucore_procs",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
"wild",
|
"wild",
|
||||||
|
@ -3446,6 +3469,12 @@ dependencies = [
|
||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.10.0+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.11.0+wasi-snapshot-preview1"
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
|
|
|
@ -286,7 +286,7 @@ fundu = "0.5.1"
|
||||||
gcd = "2.3"
|
gcd = "2.3"
|
||||||
glob = "0.3.1"
|
glob = "0.3.1"
|
||||||
half = "2.2"
|
half = "2.2"
|
||||||
humantime_to_duration = "0.2.1"
|
humantime_to_duration = "0.3.0"
|
||||||
indicatif = "0.17"
|
indicatif = "0.17"
|
||||||
is-terminal = "0.4.7"
|
is-terminal = "0.4.7"
|
||||||
itertools = "0.10.5"
|
itertools = "0.10.5"
|
||||||
|
|
|
@ -17,8 +17,6 @@ path = "src/date.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = { workspace=true }
|
chrono = { workspace=true }
|
||||||
#/ TODO: check if we can avoid chrono+time
|
|
||||||
time = { workspace=true }
|
|
||||||
clap = { workspace=true }
|
clap = { workspace=true }
|
||||||
uucore = { workspace=true }
|
uucore = { workspace=true }
|
||||||
humantime_to_duration = { workspace=true }
|
humantime_to_duration = { workspace=true }
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// spell-checker:ignore (chrono) Datelike Timelike ; (format) DATEFILE MMDDhhmm ; (vars) datetime datetimes humantime
|
// spell-checker:ignore (chrono) Datelike Timelike ; (format) DATEFILE MMDDhhmm ; (vars) datetime datetimes humantime
|
||||||
|
|
||||||
use chrono::format::{Item, StrftimeItems};
|
use chrono::format::{Item, StrftimeItems};
|
||||||
use chrono::{DateTime, Duration as ChronoDuration, FixedOffset, Local, Offset, Utc};
|
use chrono::{DateTime, Duration, FixedOffset, Local, Offset, Utc};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use chrono::{Datelike, Timelike};
|
use chrono::{Datelike, Timelike};
|
||||||
use clap::{crate_version, Arg, ArgAction, Command};
|
use clap::{crate_version, Arg, ArgAction, Command};
|
||||||
|
@ -18,7 +18,6 @@ use libc::{clock_settime, timespec, CLOCK_REALTIME};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufRead, BufReader};
|
use std::io::{BufRead, BufReader};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use time::Duration;
|
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
#[cfg(not(any(target_os = "redox")))]
|
#[cfg(not(any(target_os = "redox")))]
|
||||||
use uucore::error::FromIo;
|
use uucore::error::FromIo;
|
||||||
|
@ -226,13 +225,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
let iter = std::iter::once(date);
|
let iter = std::iter::once(date);
|
||||||
Box::new(iter)
|
Box::new(iter)
|
||||||
}
|
}
|
||||||
DateSource::Human(ref input) => {
|
DateSource::Human(relative_time) => {
|
||||||
// Get the current DateTime<FixedOffset> and convert the input time::Duration to chrono::Duration
|
// Get the current DateTime<FixedOffset> for things like "1 year ago"
|
||||||
// for things like "1 year ago"
|
|
||||||
let current_time = DateTime::<FixedOffset>::from(Local::now());
|
let current_time = DateTime::<FixedOffset>::from(Local::now());
|
||||||
let input_chrono = ChronoDuration::seconds(input.as_seconds_f32() as i64)
|
let iter = std::iter::once(Ok(current_time + relative_time));
|
||||||
+ ChronoDuration::nanoseconds(input.subsec_nanoseconds() as i64);
|
|
||||||
let iter = std::iter::once(Ok(current_time + input_chrono));
|
|
||||||
Box::new(iter)
|
Box::new(iter)
|
||||||
}
|
}
|
||||||
DateSource::File(ref path) => {
|
DateSource::File(ref path) => {
|
||||||
|
|
|
@ -18,7 +18,8 @@ path = "src/touch.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
filetime = { workspace=true }
|
filetime = { workspace=true }
|
||||||
clap = { workspace=true }
|
clap = { workspace=true }
|
||||||
humantime_to_duration = { workspace=true }
|
# TODO: use workspace dependency (0.3) when switching from time to chrono
|
||||||
|
humantime_to_duration = "0.2.1"
|
||||||
time = { workspace=true, features = ["parsing", "formatting", "local-offset", "macros"] }
|
time = { workspace=true, features = ["parsing", "formatting", "local-offset", "macros"] }
|
||||||
uucore = { workspace=true, features=["libc"] }
|
uucore = { workspace=true, features=["libc"] }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue