Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Match library search date: token case-insensitively

NetterSilver9d4f33a77cb9
diff --git a/crates/catalog/src/query.rs b/crates/catalog/src/query.rs
index 7b5ad5ecd..efa62ea6d 100644
--- a/crates/catalog/src/query.rs
+++ b/crates/catalog/src/query.rs
@@ -226,7 +226,7 @@ fn token_matches(p: &Photo, tok: &str) -> bool {
"person" | "who" => has_person(p, val),
"type" | "kind" => format!("{:?}", p.kind).eq_ignore_ascii_case(val),
"edited" => (val == "true" || val == "yes") == p.is_edited(),
- "date" => p.captured.as_deref().is_some_and(|c| c.starts_with(val)),
+ "date" => p.captured.as_deref().is_some_and(|c| c.get(..val.len()).is_some_and(|h| h.eq_ignore_ascii_case(val))),
"copy" | "virtual" => (val == "true" || val == "yes") == p.copy_of.is_some(),
"name" | "file" => p.file_name.to_lowercase().contains(val),
// Not a known field: the colon is part of a plain word ("10:30", "Re:"), its value unquoted
diff --git a/crates/catalog/src/tests.rs b/crates/catalog/src/tests.rs
index 0b31ca975..6813d0a91 100644
--- a/crates/catalog/src/tests.rs
+++ b/crates/catalog/src/tests.rs
@@ -12,6 +12,17 @@ fn photo(c: &mut Catalog, name: &str, date: &str) -> PhotoId {
id
}
+#[test]
+fn date_token_matches_time_part_case_insensitively() {
+ let mut c = Catalog::new();
+ let a = photo(&mut c, "a.jpg", "2026-05-01T10:00:00");
+ let q = |c: &Catalog, text: &str| c.query(&Filter { text: text.into(), ..Default::default() }, &Sort::default());
+ assert_eq!(q(&c, "date:2026-05-01T10"), vec![a]);
+ assert_eq!(q(&c, "date:2026-05-01t10"), vec![a]);
+ assert_eq!(q(&c, "date:2026-05"), vec![a]);
+ assert!(q(&c, "date:2026-05-01T11").is_empty());
+}
+
#[test]
fn apply_and_inverse_roundtrip() {
let mut c = Catalog::new();