Skip to content

Conversation

@naoNao89
Copy link
Contributor

This makes -d0, -d7, -d0700 mean “today at HH[:MM]” like GNU date. We pre-parse pure digits (1–2 => HH:00, 3–4 => HHMM), respect -u for UTC, and reject invalid times like 2400/2360.

Fixes #8898.

an earlier change routed -d through parse_datetime and didn’t carry over GNU’s pure-number rule; this brings us back in line with GNU.
reference: https://www.gnu.org/software/coreutils/manual/html_node/Pure-numbers-in-date-strings.html

Tests cover -d0, -d7, -d0700 (TZ=UTC0) and the invalid cases.

Implement GNU 'Pure numbers in date strings' for time-of-day tokens:
- 1–2 digits => HH:00 today
- 3–4 digits => HHMM today
- Validate ranges; reject invalid times (e.g., 2400, 2360)

Also:
- Add tests for -d0, -d7, -d0700 under TZ=UTC0 and invalid numeric inputs
- Reference GNU manual section for pure numbers
@naoNao89 naoNao89 force-pushed the fix/date-numeric-d-parsing branch from afdfad7 to 0047c7e Compare October 14, 2025 04:42
@github-actions
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

nice, i had a working patch for -d0 but that didn't support -d7, well done

@sylvestre sylvestre merged commit e2e5c76 into uutils:main Oct 14, 2025
121 checks passed
@naoNao89 naoNao89 deleted the fix/date-numeric-d-parsing branch October 14, 2025 10:36
@matttbe
Copy link
Contributor

matttbe commented Oct 14, 2025

Thank you for the fix and the review!

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 -d0 results to a different output

3 participants