Support Absolute and Relative Date Formats Together
Currently, lsd only allows setting the date format to either an absolute format (e.g., +%Y/%m/%d %H:%M:%S) or a relative format (relative), but not both at the same time. It would be useful to display both formats together.
Expected Behavior
A way to configure lsd to show both absolute and relative dates, such as:
2025/01/31 22:10:23 (5 minutes ago)
Suggested Implementation
- Allow specifying both formats, for example:
date: ['+%Y/%m/%d %H:%M:%S', 'relative'] - Or introduce a new option, like:
date: '+%Y/%m/%d %H:%M:%S' show_relative: true
Use Case
This would provide both precise timestamps and an easy-to-read relative time, improving usability.
Would this be possible to implement? Thanks for considering it 🙏
I'm not on the dev team, but I also see this is a useful feature in my own use case, I like to see files I have touched recently as relative dates, and files that are not touched by me as full datestamp.
However having the option to display both relative and full dates means that you also need some way to specify the changeover time (i.e. when it should STOP displaying relative times and use the full datetime instead, and that should still be able to use UTC date or locale or a custom +%format )
We also need to consider not breaking the existing behavior. It's a poor user experience when a software update breaks a user's configuration, so a change here that is backwards compatible with existing behavior is much better than introducing breaking changes.
In keeping with that, I suggest to perhaps leave the existing --date '+%Y/%m/%d %H:%M:%S' or --date relative, etc. as it is for backwards compatibility, and introduce a new option to the relative date for setting a limit and the off-limit format as follows: --date relative,<limit>,<format>. This means use "relative, with a specific time limit, at which point it will display using the date format which can be the original date or locale or +<format> style
Examples:
--date relative,30d,+%Y/%m/%dwould display relative dates up to 30d backwards, after which it will use the %Y/%m/%d format for all dates older than 30d--date relative,1w,localewould display relative dates for up to 1 week back, and then switch to displaying local time for anything older than 1 week.--date relative,1y,datewould display relative dates for up to 1 year back, and then switch to displaying standard UTC time for anything older than 1 year
If the devs like this solution or have a different view on this and want to offer up a different approach, I'd like to hear about it, and I am willing to implement the pull request for the team.
alternative approach
An alternative could be to leave --date options as they are, i.e. relative , date, locale and +format and introduce a new option --reldate to accept the parts after the first comma in my example. This is because the arg parser used in rust might make it more difficult to parse for the two formats of --date relative and -date relative,30d,+%Y/%m/%d
So instead, we could use --date relative and add --reldate 30d,+%Y/%m/%d as a separate option to get the relative date behaviors. The default for --reldate is empty, so --date relative behaves as it currently does.
I think I like the alternative better.