Skip to content

Commit cc20af5

Browse files
committed
date/test: %x format specifier respects locale settings
The test is ignored as we didn't fix it yet uutils#10284
1 parent 8a62f36 commit cc20af5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/by-util/test_date.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,3 +1469,31 @@ fn test_date_posix_format_specifiers() {
14691469
.stdout_is(format!("{expected}\n"));
14701470
}
14711471
}
1472+
1473+
/// Test that %x format specifier respects locale settings
1474+
/// This is a regression test for locale-aware date formatting
1475+
#[test]
1476+
#[ignore = "https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2137410"]
1477+
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
1478+
fn test_date_format_x_locale_aware() {
1479+
// With C locale, %x should output MM/DD/YY (US format)
1480+
new_ucmd!()
1481+
.env("TZ", "UTC")
1482+
.env("LC_ALL", "C")
1483+
.arg("-d")
1484+
.arg("1997-01-19 08:17:48")
1485+
.arg("+%x")
1486+
.succeeds()
1487+
.stdout_is("01/19/97\n");
1488+
1489+
// With French locale, %x should output DD/MM/YYYY (European format)
1490+
// GNU date outputs: 19/01/1997
1491+
new_ucmd!()
1492+
.env("TZ", "UTC")
1493+
.env("LC_ALL", "fr_FR.UTF-8")
1494+
.arg("-d")
1495+
.arg("1997-01-19 08:17:48")
1496+
.arg("+%x")
1497+
.succeeds()
1498+
.stdout_is("19/01/1997\n");
1499+
}

0 commit comments

Comments
 (0)