Skip to content

date: fix %N modifier handling#12064

Open
dragutreis wants to merge 2 commits intouutils:mainfrom
dragutreis:fix/date-nanosecond-modifiers
Open

date: fix %N modifier handling#12064
dragutreis wants to merge 2 commits intouutils:mainfrom
dragutreis:fix/date-nanosecond-modifiers

Conversation

@dragutreis
Copy link
Copy Markdown

Fixes #11658

Fix %N (nanoseconds) strftime modifier handling to match GNU behavior:

  • %_3N now correctly truncates to 3 digits and right-fills trailing zeros with spaces (e.g., "0 " instead of "0")
  • %-N now correctly returns all 9 digits when no width is specified (e.g., "000000000" instead of "0")

The fix handles %N's unique semantics: width truncates from the right (not expands), _ flag right-fills with spaces, and - without width is a no-op.

Includes unit tests and integration tests.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 29, 2026

GNU testsuite comparison:

GNU test failed: tests/tail/retry. tests/tail/retry is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/rm/isatty (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/env/env-signal-handler was skipped on 'main' but is now failing.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

date: strftime ignores flags and widths on %N (nanoseconds)

1 participant