1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

date: Properly support %#z, instead of rejecting the format

It's easy to just replace %#z with %z as the capitalization makes
no sense anyway.
This commit is contained in:
Nicolas Boichat 2025-04-28 16:37:40 +08:00
parent 053e6b4d08
commit 25e4410c3b
3 changed files with 9 additions and 12 deletions

View file

@ -381,10 +381,12 @@ fn test_invalid_format_string() {
}
#[test]
fn test_unsupported_format() {
let result = new_ucmd!().arg("+%#z").fails();
result.no_stdout();
assert!(result.stderr_str().starts_with("date: invalid format %#z"));
fn test_capitalized_numeric_time_zone() {
// %z +hhmm numeric time zone (e.g., -0400)
// # is supposed to capitalize, which makes little sense here, but chrono crashes
// on such format so it's good to test.
let re = Regex::new(r"^[+-]\d{4,4}\n$").unwrap();
new_ucmd!().arg("+%#z").succeeds().stdout_matches(&re);
}
#[test]