From 7dfb2dab7cb2998c824cb85ee73b22b22752eb0a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 07:34:25 +0000 Subject: [PATCH 1/2] feat: Add comprehensive data parsing support Now it should be mostly en-par with Git. Co-authored-by: Byron <63622+Byron@users.noreply.github.com> --- gix-date/src/parse.rs | 326 ++++++++++++++++++ .../fixtures/generate_git_date_baseline.sh | 163 ++++++++- .../generate_git_date_baseline.tar | Bin 50176 -> 52736 bytes gix-date/tests/time/baseline.rs | 25 +- gix-date/tests/time/parse.rs | 241 ++++++++++++- 5 files changed, 732 insertions(+), 23 deletions(-) diff --git a/gix-date/src/parse.rs b/gix-date/src/parse.rs index 7f71c95180c..4ce2c964ea5 100644 --- a/gix-date/src/parse.rs +++ b/gix-date/src/parse.rs @@ -156,6 +156,9 @@ pub(crate) mod function { Time::new(val.timestamp().as_second(), val.offset().seconds()) } else if let Ok(val) = strptime_relaxed(ISO8601_STRICT.0, input) { Time::new(val.timestamp().as_second(), val.offset().seconds()) + } else if let Some(val) = parse_git_date_format(input) { + // Git-style flexible date parsing (ISO8601 with dots, compact formats, Z suffix, etc.) + val } else if let Ok(val) = strptime_relaxed(GITOXIDE.0, input) { Time::new(val.timestamp().as_second(), val.offset().seconds()) } else if let Ok(val) = strptime_relaxed(DEFAULT.0, input) { @@ -282,6 +285,329 @@ pub(crate) mod function { Time { seconds, offset }.into() } + /// Parse Git-style flexible date formats that aren't covered by standard strptime: + /// - ISO8601 with dots: `2008.02.14 20:30:45 -0500` + /// - Compact ISO8601: `20080214T203045`, `20080214T20:30:45`, `20080214T2030`, `20080214T20` + /// - Z suffix for UTC: `1970-01-01 00:00:00 Z` + /// - 2-digit hour offset: `2008-02-14 20:30:45 -05` + /// - Colon-separated offset: `2008-02-14 20:30:45 -05:00` + /// - Subsecond precision (ignored): `20080214T203045.019-04:00` + fn parse_git_date_format(input: &str) -> Option