From 1171a4e79aec078988defc999e9dd3eb31cc909f Mon Sep 17 00:00:00 2001 From: Roshan Ramani Date: Wed, 16 Sep 2026 14:54:51 +0530 Subject: [PATCH] fix(datetime): accept an eight-digit subsecond java date format token `SSSSSSSS` was missing from `JAVA_DATE_FORMAT_TOKENS`, so it tokenized as `SSSSSSS` followed by `S`, giving two consecutive subsecond components. The first consumed every digit and the second found none, so every input failed with "the 'subsecond' component could not be parsed". One to nine `S` all work except eight. Generated with Claude Opus 5 (Claude Code). --- .../src/java_date_time_format.rs | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/quickwit/quickwit-datetime/src/java_date_time_format.rs b/quickwit/quickwit-datetime/src/java_date_time_format.rs index 024a3c5dc23..7d755abeb75 100644 --- a/quickwit/quickwit-datetime/src/java_date_time_format.rs +++ b/quickwit/quickwit-datetime/src/java_date_time_format.rs @@ -32,8 +32,9 @@ const JAVA_DATE_FORMAT_TOKENS: &[&str] = &[ "yyyy", "xxxx", "SSSSSSSSS", // For nanoseconds - "SSSSSSS", // For microseconds - "SSSSSS", // For fractional seconds up to six digits + "SSSSSSSS", + "SSSSSSS", // For microseconds + "SSSSSS", // For fractional seconds up to six digits "SSSSS", "SSSS", "SSS", @@ -238,9 +239,8 @@ fn match_java_date_format_token( "HH" | "H" => build_hour_item(token), "mm" | "m" => build_minute_item(token), "ss" | "s" => build_second_item(token), - "SSSSSSSSS" | "SSSSSSS" | "SSSSSS" | "SSSSS" | "SSSS" | "SSS" | "SS" | "S" => { - build_fraction_of_second_item(token) - } + "SSSSSSSSS" | "SSSSSSSS" | "SSSSSSS" | "SSSSSS" | "SSSSS" | "SSSS" | "SSS" + | "SS" | "S" => build_fraction_of_second_item(token), "Z" => build_zone_offset(token), "ww" | "w[w]" | "w" => build_week_of_year_item(token), "e" => build_day_of_week_item(token), @@ -485,6 +485,18 @@ mod tests { assert_eq!(datetime, expected_datetime); } + #[test] + fn test_parse_java_datetime_format_every_subsecond_width() { + for num_digits in 1..=9 { + let format = format!("yyyy-MM-dd HH:mm:ss.{}", "S".repeat(num_digits)); + test_parse_java_datetime_aux( + &format, + "2021-01-01 11:00:03.123456789", + datetime!(2021-01-01 11:00:03.123456789 UTC), + ); + } + } + #[test] fn test_parse_java_datetime_format() { test_parse_java_datetime_aux("yyyyMMdd", "20210101", datetime!(2021-01-01 00:00:00 UTC));