Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/date/src/format_modifiers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl From<jiff::Error> for FormatError {
/// Specifier: any letter or special sequence like :z, ::z, :::z
fn format_spec_regex() -> &'static Regex {
static RE: OnceLock<Regex> = 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.
Expand Down
15 changes: 14 additions & 1 deletion tests/by-util/test_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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() {
Expand Down
Loading