diff --git a/src/find/matchers/mod.rs b/src/find/matchers/mod.rs index d8d4c018..a450ea80 100644 --- a/src/find/matchers/mod.rs +++ b/src/find/matchers/mod.rs @@ -59,7 +59,7 @@ use self::time::{ use self::type_matcher::{TypeMatcher, XtypeMatcher}; use self::user::{NoUserMatcher, UserMatcher}; use ::regex::Regex; -use chrono::{DateTime, Datelike, NaiveDateTime, Utc}; +use chrono::{DateTime, Datelike, NaiveDate, NaiveDateTime, Utc}; use fs::FileSystemMatcher; use ls::Ls; use std::{ @@ -372,6 +372,13 @@ fn convert_arg_to_comparable_value_and_suffix( /// When (time) is not provided, it will be automatically filled in as 00:00:00 /// such as: "jan 01, 2025" = "jan 01, 2025 00:00:00" -> 1735689600000 fn parse_date_str_to_timestamps(date_str: &str) -> Option { + if let Ok(datetime) = NaiveDateTime::parse_from_str(date_str, "%Y-%m-%d %H:%M:%S") { + return Some(datetime.and_utc().timestamp_millis()); + } + if let Ok(date) = NaiveDate::parse_from_str(date_str, "%Y-%m-%d") { + return Some(date.and_hms_opt(0, 0, 0)?.and_utc().timestamp_millis()); + } + let regex_pattern = r"^(?P\w{3} \d{2})?(?:, (?P\d{4}))?(?: (?P