Skip to content

date: does not respect width/padding character in output format string #7344

Closed

Description

@jfinkels

Steps to reproduce:

date -d "1999-12-08" +%03d

What happens now: uutils date terminates with an error message:

date: invalid format %03d

What I expected to happen: GNU date prints the day number with a width of three padded by zeros:

008

Notes: this is causing a failure in GNU test file tests/date/date.pl. This is not specific to %d:

$ date -d "1999-12-08" +%05y
00099
$ date -d "1999-12-08" +%05a
00Wed

Activity

  1. BigPapa314 commented on Feb 23, 2025

    @BigPapa314
    Contributor

    Seams that the format strings are processed by chrono so it might seam to have to be fixed there.

  2. BigPapa314 commented on Feb 23, 2025

    @BigPapa314
    Contributor

    Opened an issue: #1663

  3. cakebaker commented on Aug 3, 2025

    @cakebaker
    Contributor

    The first two examples have been fixed in the meantime, though the first example returns an incorrect value (see #8427):

    $ cargo run -q date -d "1999-12-08" +%03d
    007
    $ cargo run -q date -d "1999-12-08" +%05y
    00099
    

    The third example still doesn't have padding (plus the value is incorrect, probably related to #8427), so I will keep this issue open.

    $ cargo run -q date -d "1999-12-08" +%05a
    Tue
    
  4. cakebaker commented on Oct 27, 2025

    @cakebaker
    Contributor

    The value is now correct, but still no padding:

    $ cargo run -q date -d "1999-12-08" +%05a
    Wed
    
  5. ChrisDryden commented on Feb 4, 2026

    @ChrisDryden
    Collaborator

    This issue was fixed a while ago in the migration to Jiff all of the test cases in the comments here are working as expected

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions