find: show the year for old files in -ls by SichenLiang · Pull Request #904 · uutils/findutils · GitHub
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

@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

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.

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