diff --git a/Cargo.lock b/Cargo.lock index 8de56a3..1e31fc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -540,6 +540,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "beef" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" + [[package]] name = "bigdecimal" version = "0.4.10" @@ -784,16 +790,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "chrono-english" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38a56613410c9249673f4676ab8d27c70949814accb27b6b738009e2ff1034a1" -dependencies = [ - "chrono", - "scanlex", -] - [[package]] name = "chrono-tz" version = "0.10.4" @@ -3817,6 +3813,16 @@ dependencies = [ "web-time", ] +[[package]] +name = "interim" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9ce9099a85f468663d3225bf87e85d0548968441e1db12248b996b24f0f5b5a" +dependencies = [ + "chrono", + "logos", +] + [[package]] name = "io-close" version = "0.3.7" @@ -4723,6 +4729,40 @@ version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" +[[package]] +name = "logos" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff472f899b4ec2d99161c51f60ff7075eeb3097069a36050d8037a6325eb8154" +dependencies = [ + "logos-derive", +] + +[[package]] +name = "logos-codegen" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "192a3a2b90b0c05b27a0b2c43eecdb7c415e29243acc3f89cc8247a5b693045c" +dependencies = [ + "beef", + "fnv", + "lazy_static", + "proc-macro2", + "quote", + "regex-syntax", + "rustc_version", + "syn 2.0.119", +] + +[[package]] +name = "logos-derive" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "605d9697bcd5ef3a42d38efc51541aa3d6a4a25f7ab6d1ed0da5ac632a26b470" +dependencies = [ + "logos-codegen", +] + [[package]] name = "loom" version = "0.7.2" @@ -6162,12 +6202,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scanlex" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "088c5d71572124929ea7549a8ce98e1a6fd33d0a38367b09027b382e67c033db" - [[package]] name = "schannel" version = "0.1.29" @@ -6249,7 +6283,6 @@ dependencies = [ "base64 0.22.1", "blake3", "chrono", - "chrono-english", "clap", "colored", "crossbeam-channel", @@ -6260,6 +6293,7 @@ dependencies = [ "gix", "hex", "indicatif 0.18.6", + "interim", "lancedb", "model2vec-rs", "ndarray 0.17.2", diff --git a/Cargo.toml b/Cargo.toml index f0ff7a3..2c3569b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ shlex = "1.3" # Shell-like parsing for quoted strings in CLI reqwest = { version = "0.13", features = ["blocking", "gzip"] } # HTTP client for manifest downloads flate2 = "1.1" # gzip compression/decompression chrono = "0.4.44" -chrono-english = "0.1" # Natural language date parsing +interim = { version = "0.2", features = ["chrono_0_4"] } # Natural language date parsing base64 = "0.22" # Base64 decoding for MIME-encoded email bodies [[bin]] diff --git a/src/date_utils.rs b/src/date_utils.rs index 01e5884..e632026 100644 --- a/src/date_utils.rs +++ b/src/date_utils.rs @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 //! Date parsing utilities for lore email filtering //! -//! Uses chrono-english for natural language date parsing, supporting formats like: +//! Uses interim for natural language date parsing, supporting formats like: //! - Relative: "yesterday", "1 day ago", "2 weeks ago", "3 months ago" //! - Absolute: "2024-01-01" (YYYY-MM-DD ISO format) //! @@ -16,28 +16,27 @@ use chrono::Utc; /// The lore table stores dates in RFC 2822 format, so we must convert our /// filter dates to the same format for SQL string comparison to work. /// -/// Uses chrono-english for flexible natural language date parsing. Examples: +/// Uses interim for flexible natural language date parsing. Examples: /// - "yesterday", "today", "tomorrow" /// - "7 days ago", "2 weeks ago", "3 months ago" /// - "2024-01-15" (YYYY-MM-DD ISO format) -/// - And various other formats supported by chrono-english +/// - And various other formats supported by interim pub fn parse_date(date_str: &str) -> Result { let date_str = date_str.trim(); - // Use chrono-english to parse the date relative to current time + // Use interim to parse the date relative to current time let parsed = - chrono_english::parse_date_string(date_str, Utc::now(), chrono_english::Dialect::Us) - .map_err(|e| { - anyhow!( - "Invalid date format: '{}'. Error: {}.\n\ + interim::parse_date_string(date_str, Utc::now(), interim::Dialect::Us).map_err(|e| { + anyhow!( + "Invalid date format: '{}'. Error: {}.\n\ Supported formats include:\n\ - 'yesterday', 'today'\n\ - '7 days ago', '2 weeks ago', '3 months ago'\n\ - 'YYYY-MM-DD' (e.g., '2024-01-15')", - date_str, - e - ) - })?; + date_str, + e + ) + })?; Ok(parsed.to_rfc2822()) } @@ -125,8 +124,8 @@ mod tests { #[test] fn test_natural_language_formats() { - // Test additional natural language formats supported by chrono-english - // Note: chrono-english supports many formats, but not all intuitive ones work + // Test additional natural language formats supported by interim + // Note: interim supports many formats, but not all intuitive ones work let test_cases = vec![ "3 months ago", "2024-01-15", // Standard ISO format