date: support MMDDhhmm[[CC]YY][.ss] positional argument for setting date#11534
Open
aguimaraes wants to merge 1 commit intouutils:mainfrom
Open
date: support MMDDhhmm[[CC]YY][.ss] positional argument for setting date#11534aguimaraes wants to merge 1 commit intouutils:mainfrom
aguimaraes wants to merge 1 commit intouutils:mainfrom
Conversation
|
GNU testsuite comparison: |
01e8f66 to
edbe04d
Compare
|
GNU testsuite comparison: |
Merging this PR will improve performance by 4.97%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | cp_large_file[16] |
278.1 µs | 265 µs | +4.97% |
Comparing aguimaraes:date-positional-set-format (5e0e12b) with main (15f57d0)
Footnotes
-
46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
edbe04d to
5e0e12b
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.
Fixes #6398
The
datecommand accepts a bare positional argument to set the system clock:Previously, any positional argument without a
+prefix was rejected with "invalid date". This was already documented in the usage string but never implemented.The parser lives in
date.rsrather than theparse_datetimecrate because this format is specific to thedatecommand positional argument. It follows the existing pattern in this codebase wheretouchhas its ownparse_timestamp()for the similar[[CC]YY]MMDDhhmm[.ss]format.The implementation rearranges the input into
CCYYMMDDhhmm[.ss]and delegates tojiff::fmt::strtime::parsefor validation, same approach astouch::parse_timestamp(). Two-digit years use the same century rule astouch: 00-68 -> 20xx, 69-99 -> 19xx.