Skip to content

date input: bare timezone abbreviations (ut, UT, gmt, …) rejected #280

@sylvestre

Description

@sylvestre

Summary

GNU date -d accepts bare timezone abbreviations (UT, ut, GMT, gmt, …) and interprets them as "now, expressed in that timezone". parse_datetime rejects them as invalid.

Found by a fuzz_date run on uutils/coreutils.

Reproduction

$ TZ=UTC+1 /usr/bin/date -d 'ut' '+%Z'
UTC

$ TZ=UTC+1 target/debug/coreutils date -d 'ut' '+%Z'
date: invalid date 'ut'
$ echo $?
1

$ TZ=UTC+1 /usr/bin/date -d 'GMT' '+%Z'
UTC

$ TZ=UTC+1 target/debug/coreutils date -d 'GMT' '+%Z'
date: invalid date 'GMT'

Test (in uutils/coreutils integration suite)

#[test]
fn test_date_bare_timezone_abbreviation() {
    for input in ["ut", "UT", "gmt", "GMT"] {
        new_ucmd!()
            .env("TZ", "UTC+1")
            .arg("-d")
            .arg(input)
            .arg("+%Z")
            .succeeds()
            .stdout_is("UTC\n");
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions