Summary
parse_datetime accepts 3pm and 2024-06-15 3pm, but rejects the HH:MM am/pm forms that GNU date handles fine.
Found by a fuzz_date run on uutils/coreutils.
Reproduction
$ /usr/bin/date -d '2024-06-15 12:00 PM' '+%H:%M'
12:00
$ target/debug/coreutils date -d '2024-06-15 12:00 PM' '+%H:%M'
date: invalid date '2024-06-15 12:00 PM'
$ /usr/bin/date -d '2024-06-15 11:30am' '+%H:%M'
11:30
$ target/debug/coreutils date -d '2024-06-15 11:30am' '+%H:%M'
date: invalid date '2024-06-15 11:30am'
$ /usr/bin/date -d '2024-06-15 3:00 PM' '+%H:%M'
15:00
$ target/debug/coreutils date -d '2024-06-15 3:00 PM' '+%H:%M'
date: invalid date '2024-06-15 3:00 PM'
The forms that already work for reference:
$ target/debug/coreutils date -d '3pm' '+%H:%M'
15:00
$ target/debug/coreutils date -d '2024-06-15 3pm' '+%H:%M'
15:00
Test (in uutils/coreutils integration suite)
#[test]
fn test_date_input_hhmm_ampm() {
for input in [
"2024-06-15 12:00 PM",
"2024-06-15 11:30am",
"2024-06-15 3:00 PM",
] {
new_ucmd!()
.env("LC_ALL", "C")
.env("TZ", "UTC")
.arg("-d")
.arg(input)
.arg("+%H:%M")
.succeeds();
}
}
Summary
parse_datetimeaccepts3pmand2024-06-15 3pm, but rejects theHH:MM am/pmforms that GNUdatehandles fine.Found by a
fuzz_daterun onuutils/coreutils.Reproduction
The forms that already work for reference:
Test (in
uutils/coreutilsintegration suite)