Repository navigation
find: show the year for old files in -ls - #904
SichenLiang wants to merge 1 commit into
Conversation
-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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance
|
| /// 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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
sorry but it needs to be rebased |
-lsand-flsalways 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.GNU shows
Jun 15 2020here; uutils showedJun 15 12:00. The column still uses UTC and English month names.Fixes #898