Skip to content

date input: unrecognized trailing tokens rejected (e.g. 8j, 8 j) #279

Open

Description

@sylvestre

Summary

GNU date silently ignores unrecognized trailing word-tokens and parses the preceding number as an hour. parse_datetime errors out instead.

Found by a fuzz_date run on uutils/coreutils.

Reproduction

$ TZ=UTC /usr/bin/date -u -d '8j' '+%H:%M:%S'
08:00:00
$ echo $?
0

$ TZ=UTC target/debug/coreutils date -u -d '8j' '+%H:%M:%S'
date: invalid date '8j'
$ echo $?
1

$ TZ=UTC /usr/bin/date -u -d '8 j' '+%H:%M:%S'
08:00:00

$ TZ=UTC target/debug/coreutils date -u -d '8 j' '+%H:%M:%S'
date: invalid date '8 j'

Test (in uutils/coreutils integration suite)

#[test]
fn test_date_ignores_unrecognized_trailing_tokens() {
    for input in ["8j", "8 j"] {
        new_ucmd!()
            .env("TZ", "UTC")
            .arg("-u")
            .arg("-d")
            .arg(input)
            .arg("+%H:%M:%S")
            .succeeds()
            .stdout_only("08:00:00\n");
    }
}

Activity

  1. added
    bug
    good first issue
    on Apr 5, 2026
  2. added a commit that references this issue on Apr 6, 2026
    104b258
  3. added a commit that references this issue on Jun 7, 2026
    9dd4fcf
  4. xtqqczze commented on Oct 12, 2026

    @xtqqczze
    Contributor

    @anastygnome Could you clarify your plans for addressing this issue?

  5. anastygnome commented on Oct 12, 2026

    @anastygnome
    Contributor

    I intend to back port the code here before removing it from uutils after parse_datetime gets a release

  6. sylvestre commented on Oct 12, 2026

    @sylvestre
    SponsorContributorAuthor

    i did a release yesterday :)

  7. anastygnome commented on Nov 8, 2026

    @anastygnome
    Contributor

    @xtqqczze Is coming in the series of PR I intend to push.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions