eza-community / eza-community/eza

feat: check recent files based on age, not fixed date

Open
#574 3 comments 0 reactions 0 assignees View on GitHub
area: display type: feature
Dominant language
Rust
Stars
23.3k
Forks
523
PR merge metrics
No merged PRs in 30d

Description

[The GNU coreutils manual on file timestamp formatting](https://www.gnu.org/software/coreutils/manual/html_node/Formatting-file-timestamps.html) defines _recent_ as:
> A timestamp is considered to be _recent_ if it is less than six months old, and is not dated in the future. If a timestamp dated today is not listed in recent form, the timestamp is in the future, which means you probably have clock skew problems [...]

The current _same year_ check used by eza will produce misleading results for future dates (examples below).

## Setup and Tests

```shell
touch --date="2 year ago" ./2_year
touch --date="10 month ago" ./10_month
touch --date="9 month ago" ./9_month
touch --date="4 month ago" ./4_month
touch --date="now" ./today
touch --date="next hour" ./future_today
touch --date="next month" ./future_next_month
touch --date="next year" ./future_next_year

ls -AFl --sort=time --reverse --time-style="iso"
eza -AFl --sort=time --time-style="iso"
```

Time of test is `2023-10-27 21:57`, example output:
```
$ ls -AFl --sort=time --reverse --time-style="iso"
2021-10-27 2_year
2022-12-27 10_month
2023-01-27 9_month
06-27 21:57 4_month
10-27 21:57 today
2023-10-27 future_today
2023-11-27 future_next_month
2024-10-27 future_next_year

$ eza -AFl --sort=time --time-style="iso"
2021-10-27 2_year
2022-12-27 10_month
01-27 21:57 9_month
06-27 21:57 4_month
10-27 21:57 today
10-27 22:57 future_today
11-27 21:57 future_next_month
2024-10-27 future_next_year
```

### Problems

- *recent* boundary is a fixed date, not an interval. 9 months and 10 months are both less than a year, but because 10 months is pushed over `--01-01` it is not considered *recent*.
- future dates in the same year are considered *recent*. Next month `2023-11-27` is printed as `11-27`, comming from coreutils the user might think it means `2022-11-27`.

## Proposal

- do not count future dates as _recent_, no matter what the checks are.
- provide a cli flag to let the user decide what counts as _recent_, like `--recent-time=...`
- `same-month`
- `same-year` (current behavior)
- `day:`
- `month:` (`month:6` would be the coreutils behavior)
- `year:`
- or just adopt the coreutils behavior, no new cli flag.

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Reproduce the shell setup and compare eza with coreutils, then locate the timestamp formatting and recentness logic; implementation is not ready to start until the project chooses between a configurable --recent-time policy and adopting the coreutils interval behavior, including tests for past and future dates.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.