uutils/coreutils

date: strftime flags propagate into composite specifiers (%-D, %-F, …)

Ouverte

#11 657 ouverte le 5 avr. 2026

 (4 commentaires) (0 réaction) (0 personne assignée)Rust (2 000 forks)batch import
U - datefuzzinggood first issue

Métriques du dépôt

Stars
 (23 947 étoiles)
Métriques de merge PR
 (Merge moyen 5j 23h) (239 PRs mergées en 30 j)

Description

Summary

GNU date treats composite strftime specifiers (%D, %F, %T, %r, %R, %c, %x, %X) as atomic: flags like - apply to the whole expansion, not to inner sub-fields. uutils lets the - flag propagate into the inner %m, producing 6/15/24 instead of 06/15/24.

Found by a fuzz_date run.

Reproduction

$ LC_ALL=C TZ=UTC /usr/bin/date -d '2024-06-15' '+%-D'
06/15/24

$ LC_ALL=C TZ=UTC target/debug/coreutils date -d '2024-06-15' '+%-D'
6/15/24

Test

#[test]
fn test_date_strftime_flag_on_composite() {
    new_ucmd!()
        .env("LC_ALL", "C")
        .env("TZ", "UTC")
        .arg("-d")
        .arg("2024-06-15")
        .arg("+%-D")
        .succeeds()
        .stdout_is("06/15/24\n");
}

Guide contributeur