Skip to content

find: show the year for old files in -ls - #904

Open
SichenLiang wants to merge 1 commit into
uutils:mainfrom
SichenLiang:ls-year-old-files
Open

SichenLiang wants to merge 1 commit into
uutils:mainfrom
SichenLiang:ls-year-old-files

Conversation

@SichenLiang

Copy link
Copy Markdown
Contributor

-ls and -fls always printed the time of day in the date column, even for old files. GNU find prints the time only for timestamps from 180 days before find started through one hour after it, and prints the year outside that window.

$ touch -d '2020-06-15 12:00' old
$ TZ=UTC0 LC_ALL=C find old -ls

GNU shows Jun 15 2020 here; uutils showed Jun 15 12:00. The column still uses UTC and English month names.

Fixes #898

-ls and -fls always printed the time of day in the date column. Print
it only for timestamps from 180 days before find started through one
hour after it, and print the year outside that window.

Keep the column in UTC with English month names.
@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.54%. Comparing base (2b15f5d) to head (cddc1dc).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #904      +/-   ##
==========================================
+ Coverage   92.52%   92.54%   +0.01%     
==========================================
  Files          36       36              
  Lines        7694     7712      +18     
  Branches      391      392       +1     
==========================================
+ Hits         7119     7137      +18     
  Misses        437      437              
  Partials      138      138              

☔ 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 14, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 15 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 20 untouched benchmarks


Comparing SichenLiang:ls-year-old-files (cddc1dc) with main (2b15f5d)

Open in CodSpeed

Comment thread src/find/matchers/ls.rs
/// timestamps from 180 days before find started until one hour after it,
/// comparing whole seconds, and the year for anything else.
fn format_date(modified: SystemTime, now: SystemTime) -> impl std::fmt::Display {
const RECENT_PAST_SECS: i64 = 180 * 24 * 60 * 60;

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.

where does the exact 180 days / 1 hour window come from?
the manual doesn't say, so i'd like to know how it was checked

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.

Those numbers came from probing GNU findutils 4.11.0 not the manual. With LC_ALL=C and TZ=UTC0, I set a file's mtime relative to the start of each run and checked whether find -ls printed the time or the year.

At exactly 180 days old (15,552,000 seconds), GNU still prints the time; one second older gets the year. The future boundary is the same that is exactly 3,600 seconds ahead still gets the time, while 3,601 seconds gets the year. I repeated the one-second boundary checks three times and also tried several nearby offsets.

It is not the six-month cutoff used by ls: a file 15,778,476 seconds old already gets the year from GNU find. This PR matched GNU at every point I checked.

@sylvestre

Copy link
Copy Markdown
Contributor

sorry but it needs to be rebased

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.

find: -ls shows the time instead of the year for old files

2 participants