Skip to content

date: support MMDDhhmm[[CC]YY][.ss] positional argument for setting date#11534

Open
aguimaraes wants to merge 1 commit intouutils:mainfrom
aguimaraes:date-positional-set-format
Open

date: support MMDDhhmm[[CC]YY][.ss] positional argument for setting date#11534
aguimaraes wants to merge 1 commit intouutils:mainfrom
aguimaraes:date-positional-set-format

Conversation

@aguimaraes
Copy link
Copy Markdown
Contributor

Fixes #6398

The date command accepts a bare positional argument to set the system clock:

date 03271430 # March 27, 14:30, current year
date 0327143025 # 2-digit year (25 -> 2025)
date 032714302025 # 4-digit year
date 032714302025.30 # with seconds

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.rs rather than the parse_datetime crate because this format is specific to the date command positional argument. It follows the existing pattern in this codebase where touch has its own parse_timestamp() for the similar [[CC]YY]MMDDhhmm[.ss] format.

The implementation rearranges the input into CCYYMMDDhhmm[.ss] and delegates to jiff::fmt::strtime::parse for validation, same approach as touch::parse_timestamp(). Two-digit years use the same century rule as touch: 00-68 -> 20xx, 69-99 -> 19xx.

@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

GNU test failed: tests/misc/io-errors. tests/misc/io-errors is passing on 'main'. Maybe you have to rebase?
Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/rm/isatty (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tty/tty-eof (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/tee/tee is no longer failing!
Note: The gnu test tests/cut/bounded-memory is now being skipped but was previously passing.
Note: The gnu test tests/cut/cut-huge-range is now being skipped but was previously passing.
Congrats! The gnu test tests/printf/printf-surprise is now passing!

@aguimaraes aguimaraes force-pushed the date-positional-set-format branch from 01e8f66 to edbe04d Compare March 28, 2026 15:03
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/tail/pipe-f is now being skipped but was previously passing.
Note: The gnu test tests/tail/tail-n0f is now being skipped but was previously passing.
Note: The gnu test tests/unexpand/bounded-memory is now being skipped but was previously passing.
Congrats! The gnu test tests/basenc/bounded-memory is now passing!
Congrats! The gnu test tests/cp/link-heap is now passing!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 28, 2026

Merging this PR will improve performance by 4.97%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 301 untouched benchmarks
⏩ 46 skipped benchmarks1

Performance Changes

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)

Open in CodSpeed

Footnotes

  1. 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.

@aguimaraes aguimaraes force-pushed the date-positional-set-format branch from edbe04d to 5e0e12b Compare March 28, 2026 15:44
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/cut/bounded-memory (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/pr/bounded-memory (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/misc/io-errors is no longer failing!
Note: The gnu test tests/rm/many-dir-entries-vs-OOM is now being skipped but was previously passing.
Note: The gnu test tests/tail/pipe-f is now being skipped but was previously passing.
Congrats! The gnu test tests/unexpand/bounded-memory is now passing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

date: date setting format error

1 participant