date: parse <digits>j as a local time of day#12747
Open
eyupcanakman wants to merge 1 commit into
Open
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
43011fa to
a584e5c
Compare
cakebaker
reviewed
Jun 10, 2026
Comment on lines
+425
to
+432
| let time_digits = match input.strip_suffix(['j', 'J']) { | ||
| Some(prefix) | ||
| if !prefix.is_empty() && prefix.chars().all(|c| c.is_ascii_digit()) => | ||
| { | ||
| prefix | ||
| } | ||
| _ => input, | ||
| }; |
Contributor
There was a problem hiding this comment.
I would perform the checks only once, on lines 433 - 435. It allows you to simplify the code above to something like:
Suggested change
| let time_digits = match input.strip_suffix(['j', 'J']) { | |
| Some(prefix) | |
| if !prefix.is_empty() && prefix.chars().all(|c| c.is_ascii_digit()) => | |
| { | |
| prefix | |
| } | |
| _ => input, | |
| }; | |
| let time_digits = input.strip_suffix(['j', 'J']).unwrap_or(input); |
Contributor
Author
There was a problem hiding this comment.
Done. Collapsed it to the single strip_suffix and dropped the redundant digit guard, since is_pure_digits already revalidates time_digits below.
The military timezone letter J means local time, so a time followed by j/J (9j, 1230J) is the same time-of-day form as the bare number. GNU accepts these, but we rejected them because J was only handled as the bare string "j". Strip the suffix and route it through the existing pure-digit path. Fixes uutils#12684.
a584e5c to
832a239
Compare
|
GNU testsuite comparison: |
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.
date -d 9jwas rejected even though GNU reads it as 09:00 today. The military timezoneJmeans local time, so a number followed byj/J(9j,1230J) is just the bare time-of-day form. The fix strips the suffix and handles it like the bare number.Fixes #12684.