Skip to content

find: parse -newerXt dates with parse_datetime, in local time - #915

Merged
sylvestre merged 2 commits into
uutils:mainfrom
jayhemnani9910:newermt-date-syntax
Oct 23, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
jayhemnani9910:newermt-date-syntax

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

-newermt and the other -newerXt predicates accept only YYYY-MM-DD[ HH:MM:SS] and Mon DD[, YYYY][ HH:MM:SS], and read them as UTC. GNU find takes any date -d string and uses local time:

$ find t -newermt '2026-10-16 00:00'
GNU 4.10.0:  t/one ...
uutils:      find: I cannot figure out how to interpret ‘2026-10-16 00:00’ as a date or time

The same error comes for yesterday, 1 day ago, @1792540800, 2026-10-16T00:00:00, Oct 16 2026, 10/16/2026 and 2026-10-16 10:00 +0000. With TZ=Asia/Kolkata, -newermt '2026-10-20 05:00:00' was also 5.5 hours off.

parse_date_str_to_timestamps now calls parse_datetime::parse_datetime, the parser date -d and touch -d use in coreutils, as suggested in #384. An empty string still means the start of today, like GNU. parse_datetime 0.17 is a new dependency; it builds for wasm32-wasip1. #871 (chrono to jiff) rewrites the same function; whichever lands second needs a small rebase.

The unit test now computes its expected values in local time, so it passes in any time zone, and it covers @epoch, an explicit offset, 1 Jan 2025 and yesterday. find_newer_xy also runs those forms on the command line and fails without the change. cargo test: 429 passed, clippy and fmt clean, also under TZ=UTC, Asia/Kolkata and America/New_York. With TZ=Asia/Kolkata, 21 of 22 date strings select the same files as GNU find 4.10.0 (the error text for an invalid one differs only in the program name); the other one hits files whose mtime equals the reference time exactly, fixed in #914. Four of them were also checked under UTC and America/New_York.

Part of #384.

Copilot AI balanced review requested due to automatic review settings October 22, 2026 05:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.58%. Comparing base (e176572) to head (dc967d5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #915   +/-   ##
=======================================
  Coverage   92.57%   92.58%           
=======================================
  Files          37       37           
  Lines        7746     7750    +4     
  Branches      393      391    -2     
=======================================
+ Hits         7171     7175    +4     
  Misses        435      435           
  Partials      140      140           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 15 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 20 untouched benchmarks


Comparing jayhemnani9910:newermt-date-syntax (dc967d5) with main (e176572)

Open in CodSpeed

@github-actions

Copy link
Copy Markdown

Commit 9634207 has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 317 / PASSED: 275 / FAILED: 36 / SKIPPED: 6
  Reference: TOTAL: 317 / PASSED: 274 / FAILED: 37 / SKIPPED: 6

Changes from main branch:
  TOTAL: +0
  PASSED: +1
  FAILED: -1

Test improvements (1):
  + common/newermt_epoch_minus_one

Comment thread src/find/matchers/mod.rs Outdated
@@ -403,38 +402,17 @@ fn convert_arg_to_comparable_value_and_suffix(
/// When (time) is not provided, it will be automatically filled in as 00:00:00

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doc comment is now wrong (UTC timestamps, only one format)
please replace it with a single line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in dc967d5, it's one line now.

Comment thread tests/test_find.rs
"2000-01-01T00:00",
"1 Jan 2000",
"@946684800",
"yesterday",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these only check that it doesn't fail
could you please add a test which checks the selected files, with TZ set, so the local time part is covered?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added find_newermt_uses_local_time in dc967d5. It creates two files with mtimes of 23:00 and 04:00 UTC on either side of 2000-01-01. With TZ=UTC0, -newermt '2000-01-01 03:00:00' selects only the later file; with TZ=UTC-5 it selects both. On the old parser, which read the date as UTC, the UTC-5 case selects only the later file.

Copilot AI balanced review requested due to automatic review settings October 22, 2026 20:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

Copy link
Copy Markdown

Commit dc967d5 has test result changes:

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 316 / PASSED: 274 / FAILED: 36 / SKIPPED: 6
  Reference: TOTAL: 317 / PASSED: 274 / FAILED: 37 / SKIPPED: 6

Changes from main branch:
  TOTAL: -1
  PASSED: +0
  FAILED: -1

Test improvements (1):
  + common/newermt_epoch_minus_one

No result in this run (1) - hung, crashed, or renamed:
  ? posix/depth_slash (was PASS)

@sylvestre
sylvestre merged commit d8ba0a0 into uutils:main Oct 23, 2026
34 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

@jayhemnani9910
jayhemnani9910 deleted the newermt-date-syntax branch November 13, 2026 14:32
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.

3 participants