Repository navigation
date: strip the O strftime modifier in the C locale - #13702
Merged
Merged
Conversation
cakebaker
reviewed
Aug 2, 2026
| /// exist, so GNU `date` treats it as a no-op: `%Om` renders exactly like | ||
| /// `%m` (issue #11656). jiff does not know the modifier and would emit it | ||
| /// literally, so strip it before jiff sees the format string. | ||
| fn strip_o_modifier(fmt: &str) -> String { |
Contributor
There was a problem hiding this comment.
The function contains a small bug: if the input contains %%%O, the O at the end gets dropped.
Contributor
Author
There was a problem hiding this comment.
Good catch, thanks. The root cause was broader than the trailing case:
the function assumed any O after a % was a modifier. It is only a
modifier when it actually modifies a specifier, so %O%m and %O5 were
mangled too.
Now the O is dropped only when a letter follows it. Verified byte-for-byte
against GNU date for %Om-%Oy-%Ol, %%Om, %%%O, %O, %O%m and %O5.
Contributor
|
Thanks for your PR! |
Devel08
pushed a commit
to Devel08/coreutils
that referenced
this pull request
Sep 28, 2026
* date: strip the O strftime modifier in the C locale * date: only strip O when it modifies a specifier
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.
Fixes #11656
In the C locale the
Ostrftime modifier requests alternative numericsymbols that do not exist, so GNU
datetreats it as a no-op:%Omrenders exactly like
%m. jiff does not know the modifier and emitted itliterally.
Strip the modifier from the format string before jiff sees it, mirroring
the existing
substitute_epoch_secondspass.%%is preserved so that anOfollowing a literal percent stays plain text.Before:
After (matches GNU):
The test for this behaviour already existed in
tests/by-util/test_date.rsmarked
#[ignore]; this PR removes the ignore.