chore(deps): Replace `chrono` with `jiff`
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Shun Sakai · committed by Shun Sakai · parent 7d57f61 · Browse files · 4 files·+35 added−178 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+35 added−178 removed
- other:+35 added−178 removed
Provenance
- Commit
bbac767- Tree
ecadc49- Author
Shun Sakai <sorairolake@protonmail.ch>- Committer
Shun Sakai <sorairolake@protonmail.ch>- Parent
7d57f61
4 files changed+35 added−178 removed
modified:src/filter/time.rs+21 added-25 removed
1-use chrono::{DateTime, Local, NaiveDate, NaiveDateTime};2-use jiff::{Span, Zoned};1+use jiff::{civil::DateTime, tz::TimeZone, Span, Timestamp, Zoned};2 3 use std::time::SystemTime;4 5 /// Filter based on time ranges.6 unmodified lines12 impl TimeFilter {13 fn from_str(ref_time: &SystemTime, s: &str) -> Option<SystemTime> {14 s.parse::<Span>()15 .and_then(|duration| {17- Zoned::try_from(*ref_time).and_then(|zoned| zoned.checked_sub(duration))16+ Zoned::try_from(*ref_time).and_then(|zdt| zdt.checked_sub(duration))17 })19- .map(SystemTime::from)18 .ok()19 .or_else(|| {22- DateTime::parse_from_rfc3339(s)23- .map(|dt| dt.into())20+ let local_tz = TimeZone::system();21+ s.parse::<Timestamp>()22+ .map(|ts| ts.to_zoned(TimeZone::UTC))23 .ok()24 .or_else(|| {26- NaiveDate::parse_from_str(s, "%F")27- .ok()?28- .and_hms_opt(0, 0, 0)?29- .and_local_timezone(Local)30- .latest()25+ s.parse::<DateTime>()26+ .map(|dt| local_tz.to_ambiguous_zoned(dt))27+ .and_then(|zdt| zdt.later())28+ .ok()29 })30 .or_else(|| {33- NaiveDateTime::parse_from_str(s, "%F %T")34- .ok()?35- .and_local_timezone(Local)36- .latest()37- })38- .or_else(|| {31 let timestamp_secs = s.strip_prefix('@')?.parse().ok()?;40- DateTime::from_timestamp(timestamp_secs, 0).map(Into::into)32+ Timestamp::from_second(timestamp_secs)33+ .map(|ts| ts.to_zoned(TimeZone::UTC))34+ .ok()35 })42- .map(|dt| dt.into())36 })37+ .map(SystemTime::from)38 }39 40 pub fn before(ref_time: &SystemTime, s: &str) -> Option<TimeFilter> {41 TimeFilter::from_str(ref_time, s).map(TimeFilter::Before)17 unmodified lines59 use std::time::Duration;60 61 #[test]62 fn is_time_filter_applicable() {69- let ref_time = NaiveDateTime::parse_from_str("2010-10-10 10:10:10", "%F %T")63+ let local_tz = TimeZone::system();64+ let ref_time = local_tz65+ .to_ambiguous_zoned("2010-10-10 10:10:10".parse::<DateTime>().unwrap())66+ .later()67 .unwrap()71- .and_local_timezone(Local)72- .latest()73- .unwrap()68 .into();69 70 assert!(TimeFilter::after(&ref_time, "1min")71 .unwrap()46 unmodified lines118 assert!(TimeFilter::after(&ref_time, same_day)119 .unwrap()120 .applies_to(&t1m_ago));121 128- let ref_time = DateTime::parse_from_rfc3339("2010-10-10T10:10:10+00:00")122+ let ref_time = "2010-10-10T10:10:10+00:00"123+ .parse::<Timestamp>()124 .unwrap()125 .into();126 let t1m_ago = ref_time - Duration::from_secs(60);127 let t10s_before = "2010-10-10T10:10:00+00:00";11 unmodified lines139 .unwrap()140 .applies_to(&t1m_ago));141 142 let ref_timestamp = 1707723412u64; // Mon Feb 12 07:36:52 UTC 2024148- let ref_time = DateTime::parse_from_rfc3339("2024-02-12T07:36:52+00:00")143+ let ref_time = "2024-02-12T07:36:52+00:00"144+ .parse::<Timestamp>()145 .unwrap()146 .into();147 let t1m_ago = ref_time - Duration::from_secs(60);148 let t1s_later = ref_time + Duration::from_secs(1);16 unmodified linesmodified:Cargo.lock+12 added-146 removed
10 unmodified lines11 "memchr",12 ]13 14 [[package]]15-name = "android-tzdata"16-version = "0.1.1"17-source = "registry+https://github.com/rust-lang/crates.io-index"18-checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"19-20-[[package]]21-name = "android_system_properties"22-version = "0.1.5"23-source = "registry+https://github.com/rust-lang/crates.io-index"24-checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"25-dependencies = [26- "libc",27-]28-29-[[package]]15 name = "anstream"16 version = "0.6.15"17 source = "registry+https://github.com/rust-lang/crates.io-index"18 checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"58 unmodified lines77 "nix 0.24.3",78 ]79 80 [[package]]96-name = "autocfg"97-version = "1.3.0"98-source = "registry+https://github.com/rust-lang/crates.io-index"99-checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"100-101-[[package]]81 name = "bitflags"82 version = "1.3.2"83 source = "registry+https://github.com/rust-lang/crates.io-index"84 checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"14 unmodified lines99 "serde",100 ]101 102 [[package]]124-name = "bumpalo"125-version = "3.16.0"126-source = "registry+https://github.com/rust-lang/crates.io-index"127-checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"128-129-[[package]]103 name = "cc"104 version = "1.1.13"105 source = "registry+https://github.com/rust-lang/crates.io-index"106 checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48"13 unmodified lines120 source = "registry+https://github.com/rust-lang/crates.io-index"121 checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"122 123 [[package]]151-name = "chrono"152-version = "0.4.39"153-source = "registry+https://github.com/rust-lang/crates.io-index"154-checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825"155-dependencies = [156- "android-tzdata",157- "iana-time-zone",158- "num-traits",159- "windows-targets",160-]161-162-[[package]]124 name = "clap"125 version = "4.5.31"126 source = "registry+https://github.com/rust-lang/crates.io-index"127 checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767"48 unmodified lines176 source = "registry+https://github.com/rust-lang/crates.io-index"177 checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"178 179 [[package]]219-name = "core-foundation-sys"220-version = "0.8.7"221-source = "registry+https://github.com/rust-lang/crates.io-index"222-checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"223-224-[[package]]180 name = "crossbeam-channel"181 version = "0.5.14"182 source = "registry+https://github.com/rust-lang/crates.io-index"183 checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471"86 unmodified lines270 dependencies = [271 "aho-corasick",272 "anyhow",273 "argmax",319- "chrono",274 "clap",275 "clap_complete",276 "crossbeam-channel",277 "ctrlc",69 unmodified lines347 "windows-sys 0.52.0",348 ]349 350 [[package]]397-name = "iana-time-zone"398-version = "0.1.60"399-source = "registry+https://github.com/rust-lang/crates.io-index"400-checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"401-dependencies = [402- "android_system_properties",403- "core-foundation-sys",404- "iana-time-zone-haiku",405- "js-sys",406- "wasm-bindgen",407- "windows-core",408-]409-410-[[package]]411-name = "iana-time-zone-haiku"412-version = "0.1.2"413-source = "registry+https://github.com/rust-lang/crates.io-index"414-checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"415-dependencies = [416- "cc",417-]418-419-[[package]]351 name = "ignore"352 version = "0.4.23"353 source = "registry+https://github.com/rust-lang/crates.io-index"354 checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b"40 unmodified lines395 source = "registry+https://github.com/rust-lang/crates.io-index"396 checksum = "d699bc6dfc879fb1bf9bdff0d4c56f0884fc6f0d0eb0fba397a6d00cd9a6b85e"397 dependencies = [398 "jiff-static",399+ "jiff-tzdb-platform",400 "log",401 "portable-atomic",402 "portable-atomic-util",403 "serde",404+ "windows-sys 0.59.0",405 ]406 407 [[package]]408 name = "jiff-static"6 unmodified lines415 "syn",416 ]417 418 [[package]]486-name = "js-sys"487-version = "0.3.70"419+name = "jiff-tzdb"420+version = "0.1.3"421 source = "registry+https://github.com/rust-lang/crates.io-index"489-checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a"422+checksum = "962e1dfe9b2d75a84536cf5bf5eaaa4319aa7906c7160134a22883ac316d5f31"423+424+[[package]]425+name = "jiff-tzdb-platform"426+version = "0.1.2"427+source = "registry+https://github.com/rust-lang/crates.io-index"428+checksum = "a63c62e404e7b92979d2792352d885a7f8f83fd1d0d31eea582d77b2ceca697e"429 dependencies = [491- "wasm-bindgen",430+ "jiff-tzdb",431 ]432 433 [[package]]434 name = "lazy_static"87 unmodified lines522 "windows-sys 0.52.0",523 ]524 525 [[package]]587-name = "num-traits"588-version = "0.2.19"589-source = "registry+https://github.com/rust-lang/crates.io-index"590-checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"591-dependencies = [592- "autocfg",593-]594-595-[[package]]526 name = "once_cell"527 version = "1.19.0"528 source = "registry+https://github.com/rust-lang/crates.io-index"529 checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"228 unmodified lines758 "wit-bindgen-rt",759 ]760 761 [[package]]832-name = "wasm-bindgen"833-version = "0.2.93"834-source = "registry+https://github.com/rust-lang/crates.io-index"835-checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5"836-dependencies = [837- "cfg-if",838- "once_cell",839- "wasm-bindgen-macro",840-]841-842-[[package]]843-name = "wasm-bindgen-backend"844-version = "0.2.93"845-source = "registry+https://github.com/rust-lang/crates.io-index"846-checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b"847-dependencies = [848- "bumpalo",849- "log",850- "once_cell",851- "proc-macro2",852- "quote",853- "syn",854- "wasm-bindgen-shared",855-]856-857-[[package]]858-name = "wasm-bindgen-macro"859-version = "0.2.93"860-source = "registry+https://github.com/rust-lang/crates.io-index"861-checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf"862-dependencies = [863- "quote",864- "wasm-bindgen-macro-support",865-]866-867-[[package]]868-name = "wasm-bindgen-macro-support"869-version = "0.2.93"870-source = "registry+https://github.com/rust-lang/crates.io-index"871-checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"872-dependencies = [873- "proc-macro2",874- "quote",875- "syn",876- "wasm-bindgen-backend",877- "wasm-bindgen-shared",878-]879-880-[[package]]881-name = "wasm-bindgen-shared"882-version = "0.2.93"883-source = "registry+https://github.com/rust-lang/crates.io-index"884-checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"885-886-[[package]]762 name = "winapi"763 version = "0.3.9"764 source = "registry+https://github.com/rust-lang/crates.io-index"765 checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"23 unmodified lines789 source = "registry+https://github.com/rust-lang/crates.io-index"790 checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"791 792 [[package]]918-name = "windows-core"919-version = "0.52.0"920-source = "registry+https://github.com/rust-lang/crates.io-index"921-checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"922-dependencies = [923- "windows-targets",924-]925-926-[[package]]793 name = "windows-sys"794 version = "0.52.0"795 source = "registry+https://github.com/rust-lang/crates.io-index"796 checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"85 unmodified linesmodified:Cargo.toml+1 added-6 removed
46 unmodified lines474849505151525354555657585960615758596029 unmodified lines46 unmodified linesnormpath = "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"] }jiff = "0.2.4"
[dependencies.clap]version = "4.5.31"features = ["suggestions", "color", "wrap_help", "cargo", "derive"]
[dependencies.chrono]version = "0.4.39"default-features = falsefeatures = ["std", "clock"]
[dependencies.lscolors]version = "0.20"default-features = falsefeatures = ["nu-ansi-term"]29 unmodified linesmodified:CHANGELOG.md+1 added-1 removed
8 unmodified lines9 10 11 ## Changes12 13-- Replace `humantime` crate with `jiff` crate, see #1690 (@sorairolake)13+- Replace `humantime` crate and `chrono` crate with `jiff` crate, see #1690 (@sorairolake)14 15 ## Other16 17 788 unmodified lines