date: fix strftime flags and widths on %N (nanoseconds)#11778
Open
sjhddh wants to merge 2 commits intouutils:mainfrom
Open
date: fix strftime flags and widths on %N (nanoseconds)#11778sjhddh wants to merge 2 commits intouutils:mainfrom
sjhddh wants to merge 2 commits intouutils:mainfrom
Conversation
GNU date treats %N width as precision (number of fractional-second digits) and its zeros as significant content rather than padding. Previously uutils ignored flags/widths on %N, producing incorrect output (e.g. `%-N` at @0 gave "0" instead of "000000000"). Add special handling for the %N specifier in apply_modifiers: - %-N: preserve all digits (zeros are content, not padding) - %3N: truncate to 3 fractional digits - %_3N: truncate to 3 digits, replace trailing zeros with spaces - %_N: full 9 digits, trailing zeros replaced with spaces Un-ignore the existing integration test for issue uutils#11658. Closes uutils#11658 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
GNU testsuite comparison: |
Contributor
|
Can you please run |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
Ran (The previous clippy fixes from commit ccff54f already resolved the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #11658
GNU
datetreats%Nwidth as precision (number of fractional-second digits) and its zeros as significant content, not padding. Previously uutils ignored or mishandled flags/widths on%N:%-Nat@0produced0instead of000000000%_3Nat@0produced0instead of0%3Nat@0produced0instead of000Changes
apply_nanosecond_modifiers()informat_modifiers.rswith special handling for%N:%-N: preserve all digits unchanged (zeros are content, not padding)%3N: truncate to first 3 fractional digits%_3N: truncate to 3 digits, replace trailing zeros with spaces%_N: full 9 digits, trailing zeros replaced with spacestest_date_strftime_n_width_and_flagsTest plan
format_modifiersunit tests pass (including 2 new nanosecond tests)test_dateintegration tests pass (previously ignored test now runs)%-Nat@0→000000000%_3Nat@0→0(0 + two spaces)%3Nat@0→000🤖 Generated with Claude Code