From 4fda0d9ab881cf44ecfa1e4d842d1be1a235cbec Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 16 Feb 2026 21:50:25 +0100 Subject: [PATCH 1/2] date: add test for locale default format timezone position Covers date-locale-hour.sh --- tests/by-util/test_date.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/by-util/test_date.rs b/tests/by-util/test_date.rs index 8ccc4793bee..95b47eb12b5 100644 --- a/tests/by-util/test_date.rs +++ b/tests/by-util/test_date.rs @@ -2637,6 +2637,43 @@ fn test_locale_day_names() { } } +// GNU test date-locale-hour: Default format should match locale +#[test] +#[cfg(unix)] +fn test_date_locale_default_format_timezone_position() { + // Verify timezone appears after time, not between date and year + // Test with en_IE locale which should have timezone after time + let result = new_ucmd!() + .env("LC_ALL", "en_IE") + .env("TZ", "Europe/Brussels") + .arg("-d") + .arg("2025-10-11T13:00") + .run(); + + // Skip test if locale not available + if !result.succeeded() { + return; + } + + let output = result.stdout_str().trim(); + + // Find positions of key components + let year_pos = output.find("2025").expect("Should contain year"); + let time_pos = output.find("13:00").expect("Should contain time"); + let tz_pos = output + .find("CEST") + .or_else(|| output.find("CET")) + .expect("Should contain timezone"); + + // Timezone should be near time, not between date and year + // Valid: "Oct 11 2025 13:00:00 CEST" or "Oct 11 13:00:00 CEST 2025" + // Invalid: "Oct 11 CEST 2025 13:00:00" + assert!( + tz_pos >= time_pos || tz_pos > year_pos, + "Timezone should appear after time or after year, not between them. Got: {output}" + ); +} + #[test] fn test_percent_percent_not_replaced() { let cases = [ From 58fd19a9bbde2636cb6122fad1be27ae7e2bdf39 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 26 Sep 2026 13:59:35 +0200 Subject: [PATCH 2/2] date: use C locale and exact output in timezone position test --- tests/by-util/test_date.rs | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/tests/by-util/test_date.rs b/tests/by-util/test_date.rs index 95b47eb12b5..0c3d61bc99d 100644 --- a/tests/by-util/test_date.rs +++ b/tests/by-util/test_date.rs @@ -2637,41 +2637,17 @@ fn test_locale_day_names() { } } -// GNU test date-locale-hour: Default format should match locale +// GNU test date-locale-hour: the timezone must follow the time in the default format #[test] #[cfg(unix)] fn test_date_locale_default_format_timezone_position() { - // Verify timezone appears after time, not between date and year - // Test with en_IE locale which should have timezone after time - let result = new_ucmd!() - .env("LC_ALL", "en_IE") + new_ucmd!() + .env("LC_ALL", "C") .env("TZ", "Europe/Brussels") .arg("-d") .arg("2025-10-11T13:00") - .run(); - - // Skip test if locale not available - if !result.succeeded() { - return; - } - - let output = result.stdout_str().trim(); - - // Find positions of key components - let year_pos = output.find("2025").expect("Should contain year"); - let time_pos = output.find("13:00").expect("Should contain time"); - let tz_pos = output - .find("CEST") - .or_else(|| output.find("CET")) - .expect("Should contain timezone"); - - // Timezone should be near time, not between date and year - // Valid: "Oct 11 2025 13:00:00 CEST" or "Oct 11 13:00:00 CEST 2025" - // Invalid: "Oct 11 CEST 2025 13:00:00" - assert!( - tz_pos >= time_pos || tz_pos > year_pos, - "Timezone should appear after time or after year, not between them. Got: {output}" - ); + .succeeds() + .stdout_is("Sat Oct 11 13:00:00 CEST 2025\n"); } #[test]