date: support MMDDhhmm[[CC]YY][.ss] positional argument for setting date#11534
date: support MMDDhhmm[[CC]YY][.ss] positional argument for setting date#11534aguimaraes wants to merge 2 commits intouutils:mainfrom
Conversation
|
GNU testsuite comparison: |
01e8f66 to
edbe04d
Compare
|
GNU testsuite comparison: |
Merging this PR will improve performance by 5.55%
Performance Changes
Comparing Footnotes
|
edbe04d to
5e0e12b
Compare
|
GNU testsuite comparison: |
| } | ||
|
|
||
| /// Parse a positional argument with format `MMDDhhmm[[CC]YY][.ss]` | ||
| fn parse_positional_set_datetime(s: &str, utc: bool) -> Option<Zoned> { |
There was a problem hiding this comment.
could you please add some unit tests for this function
There was a problem hiding this comment.
sure, working on it right now
There was a problem hiding this comment.
done, I think that works, do you need me to rebase?
The fuzzer found a crash but I think it was pre-existing and I saw some PRs to solve it.
|
GNU testsuite comparison: |
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.