Skip to content

date: %#P case-swap flag incorrectly uppercases already-lowercase alt specifier #11659

Description

@sylvestre

Summary

%P is GNU's lowercase am/pm alternative to %p. The # flag requests case-swap. GNU treats %#P as a no-op (the value is already in the target case), emitting pm. uutils blindly flips case and emits PM.

Found by a fuzz_date run.

Reproduction

$ LC_ALL=C TZ=UTC /usr/bin/date -d '2024-06-15 13:45:30' '+%#P'
pm

$ LC_ALL=C TZ=UTC target/debug/coreutils date -d '2024-06-15 13:45:30' '+%#P'
PM

Test

#[test]
fn test_date_strftime_case_flag_on_alt_ampm() {
    new_ucmd!()
        .env("LC_ALL", "C")
        .env("TZ", "UTC")
        .arg("-d")
        .arg("2024-06-15 13:45:30")
        .arg("+%#P")
        .succeeds()
        .stdout_is("pm\n");
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions