diff --git a/src/uu/date/src/format_modifiers.rs b/src/uu/date/src/format_modifiers.rs index 7cdf32b174c..369a634a4a9 100644 --- a/src/uu/date/src/format_modifiers.rs +++ b/src/uu/date/src/format_modifiers.rs @@ -79,7 +79,7 @@ impl From for FormatError { /// Specifier: any letter or special sequence like :z, ::z, :::z fn format_spec_regex() -> &'static Regex { static RE: OnceLock = OnceLock::new(); - RE.get_or_init(|| Regex::new(r"%([_0^#+-]*)(\d*)(:*[a-zA-Z])").unwrap()) + RE.get_or_init(|| Regex::new(r"%([_0OE^#+-]*)(\d*)(:*[a-zA-Z])").unwrap()) } /// Check if format string contains any GNU modifiers and format if present. diff --git a/tests/by-util/test_date.rs b/tests/by-util/test_date.rs index 7096e2040ee..6e29600f83d 100644 --- a/tests/by-util/test_date.rs +++ b/tests/by-util/test_date.rs @@ -1965,7 +1965,6 @@ fn test_date_strftime_flag_on_composite() { } #[test] -#[ignore = "https://github.com/uutils/coreutils/issues/11656 — GNU date strips the `O` strftime modifier in C locale (e.g. `%Om` -> `%m`); uutils leaks it as literal `%om`."] fn test_date_strftime_o_modifier() { // In C locale the `O` modifier is a no-op (alternative numeric symbols). // GNU renders `%Om` as `06` for June; uutils renders it as the literal `%Om`. @@ -1979,6 +1978,20 @@ fn test_date_strftime_o_modifier() { .stdout_is("06-24-12\n"); } +#[test] +fn test_date_strftime_e_modifier() { + // In C locale the `E` modifier is a no-op (alternative era). + // GNU does not render `%Em`; uutils renders it as the literal `%Em` as `06` for June. + new_ucmd!() + .env("LC_ALL", "C") + .env("TZ", "UTC") + .arg("-d") + .arg("2024-06-15") + .arg("+%Em-%Ey-%El") + .succeeds() + .stdout_is("06-24-12\n"); +} + #[test] #[ignore = "https://github.com/uutils/parse_datetime/issues/280 — GNU date accepts bare timezone abbreviations (UT, GMT, ...) meaning `now in that TZ`; parse_datetime rejects them."] fn test_date_bare_timezone_abbreviation() {