date: skip '-' flag for composite strftime specifiers - #14163
Open
MadeNavaneeth wants to merge 1 commit into
Open
date: skip '-' flag for composite strftime specifiers#14163MadeNavaneeth wants to merge 1 commit into
MadeNavaneeth wants to merge 1 commit into
Conversation
sylvestre
reviewed
Aug 26, 2026
Comment on lines
+239
to
+249
| // GNU treats composite specifiers (D, F, T, r, R, c, x, X) | ||
| // as atomic: the `-` flag applies to the whole expansion, | ||
| // not to inner sub-fields. Since jiff already expands them | ||
| // correctly, strip the `-` flag so apply_modifiers doesn't | ||
| // remove leading zeros from inner fields like %m in %D. | ||
| if !parsed.flags.is_empty() || parsed.width.is_some() { | ||
| // GNU treats composite specifiers (D, F, T, r, R, c, x, X) | ||
| // as atomic: flags like `-` apply to the whole expansion, | ||
| // not to inner sub-fields. Since jiff already expands them | ||
| // correctly, strip the `-` flag so apply_modifiers doesn't | ||
| // remove leading zeros from inner fields like %m in %D. |
Contributor
There was a problem hiding this comment.
i don't think it needs 10 lines of comment
Contributor
There was a problem hiding this comment.
please make this comment shorter
Contributor
|
needs a test too |
|
GNU testsuite comparison: |
MadeNavaneeth
force-pushed
the
fix/date-strftime-composite-flags
branch
from
August 27, 2026 00:21
8ecdcf5 to
c055443
Compare
GNU date treats composite strftime specifiers (%D, %F, %T, %r, %R, %c, %x, %X) as atomic: flags like '-' apply to the whole expansion, not to inner sub-fields. uutils let the '-' flag propagate into inner specifiers, producing e.g. '6/15/24' for %-D instead of '06/15/24'. Strip the '-' flag from composite specifiers before applying modifiers, so inner fields keep their default padding while width and other flags still work. Fixes uutils#11657
MadeNavaneeth
force-pushed
the
fix/date-strftime-composite-flags
branch
from
August 27, 2026 04:16
c055443 to
b4d5b00
Compare
cakebaker
reviewed
Aug 27, 2026
| // not to inner sub-fields. Since jiff already expands them | ||
| // correctly, strip the `-` flag so apply_modifiers doesn't | ||
| // remove leading zeros from inner fields like %m in %D. | ||
| if !parsed.flags.is_empty() || parsed.width.is_some() { |
Contributor
There was a problem hiding this comment.
This condition is identical to the condition on line 238.
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 #11657
The problem
GNU
datetreats composite strftime specifiers (%D,%F,%T,%r,%R,%c,%x,%X) as atomic: flags like-apply to the whole expansion, not to inner sub-fields. uutils let the-flag propagate into inner specifiers:The fix
Strip the
-flag from composite specifiers before applying modifiers, so inner fields keep their default padding while width and other flags still work.Verification
%-Dnow correctly outputs06/15/24(matching GNU)