From c670a0b366fae3f660b908aa406048c7df1b6af4 Mon Sep 17 00:00:00 2001 From: Shun Sakai Date: Wed, 12 Mar 2025 18:15:37 +0900 Subject: [PATCH] chore(deps): Replace `humantime` with `jiff` --- CHANGELOG.md | 1 + Cargo.lock | 61 +++++++++++++++++++++++++++++++++++----------- Cargo.toml | 2 +- src/filter/time.rs | 6 +++-- tests/tests.rs | 6 ++++- 5 files changed, 58 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e891da1f..c5c3ee42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ## Changes +- Replace `humantime` crate with `jiff` crate, see #1690 (@sorairolake) ## Other diff --git a/Cargo.lock b/Cargo.lock index 8fbb8ee5..00bd80fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -326,9 +326,9 @@ dependencies = [ "faccess", "filetime", "globset", - "humantime", "ignore", "jemallocator", + "jiff", "libc", "lscolors", "nix 0.29.0", @@ -393,12 +393,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - [[package]] name = "iana-time-zone" version = "0.1.60" @@ -464,6 +458,30 @@ dependencies = [ "libc", ] +[[package]] +name = "jiff" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d699bc6dfc879fb1bf9bdff0d4c56f0884fc6f0d0eb0fba397a6d00cd9a6b85e" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde", +] + +[[package]] +name = "jiff-static" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d16e75759ee0aa64c57a56acbf43916987b20c77373cb7e808979e02b93c9f9" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "js-sys" version = "0.3.70" @@ -581,19 +599,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] -name = "proc-macro2" -version = "1.0.86" +name = "portable-atomic" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "proc-macro2" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -692,9 +725,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.75" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 8244aa7b..3732f4f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,6 @@ ignore = "0.4.23" regex = "1.11.1" regex-syntax = "0.8" ctrlc = "3.2" -humantime = "2.1" globset = "0.4" anyhow = "1.0" etcetera = "0.9" @@ -49,6 +48,7 @@ normpath = "1.1.1" crossbeam-channel = "0.5.14" clap_complete = {version = "4.5.44", optional = true} faccess = "0.2.4" +jiff = { version = "0.2.4", default-features = false, features = ["std"] } [dependencies.clap] version = "4.5.31" diff --git a/src/filter/time.rs b/src/filter/time.rs index cd175425..4f2139b8 100644 --- a/src/filter/time.rs +++ b/src/filter/time.rs @@ -1,6 +1,7 @@ use chrono::{DateTime, Local, NaiveDate, NaiveDateTime}; +use jiff::Span; -use std::time::SystemTime; +use std::time::{Duration, SystemTime}; /// Filter based on time ranges. #[derive(Debug, PartialEq, Eq)] @@ -11,7 +12,8 @@ pub enum TimeFilter { impl TimeFilter { fn from_str(ref_time: &SystemTime, s: &str) -> Option { - humantime::parse_duration(s) + s.parse::() + .and_then(Duration::try_from) .map(|duration| *ref_time - duration) .ok() .or_else(|| { diff --git a/tests/tests.rs b/tests/tests.rs index 81010cfa..8bba4051 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -8,6 +8,7 @@ use std::path::Path; use std::time::{Duration, SystemTime}; use test_case::test_case; +use jiff::Timestamp; use normpath::PathExt; use regex::escape; @@ -2288,7 +2289,10 @@ fn test_modified_relative() { #[cfg(test)] fn change_file_modified>(path: P, iso_date: &str) { - let st = humantime::parse_rfc3339(iso_date).expect("invalid date"); + let st = iso_date + .parse::() + .map(SystemTime::from) + .expect("invalid date"); let ft = filetime::FileTime::from_system_time(st); filetime::set_file_times(path, ft, ft).expect("time modification failde"); }