Skip to content

date: width prefix in %N format specifier ignored if it is a negative number. #12034

Closed

Description

@Devel08

uu coreutils' date's width prefix in %N format specifier is ignored if its a negative number. What GNU coreutils does is that when the width prefix in %N is a negative number, it returns an output identical to what the abstract value of the width prefix is.
Maybe we can change width to be an isize and effective_width to be equal to width's abstract value if width < 0?

How to reproduce

$ cargo run date +%-2N
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s
     Running `target/debug/coreutils date '+%-2N'`
807837678

GNU coreutils' output

$ date +%-2N
36

Activity

  1. blixygetir commented on Apr 30, 2026

    @blixygetir
    Contributor

    I would like to work on this, I found the bug in the format_modifiers.rs file under the src/uu/date folder. I have changed the width type to isize allowing negative width inputs, displaying the output as per GNU.

  2. Devel08 commented on Apr 30, 2026

    @Devel08
    SponsorContributorAuthor

    @blixygetir Nice, maintainers here do not assign issues to contributors, you can directly open a pull request with your fix, referring to this issue and wait for a review

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