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