Efficient algorithm for extracting the most relevant information from the date
Author: baruchelCreated Dec 4, 2024Updated Aug 1, 2026
Most of the time, the arrival date of listed messages is the current day or the previous one; displaying the whole date is not very useful.
Another terminal client like Alpine follows a very interesting policy:
- when the message is less than one day old, the time is displayed in a very clear format like 11:35
- when the message is from yesterday, the date is "yesterday"
- when the message is from the last 7 days, the name of the day is displayed "tuesday"
I don't remember the full behaviour in all cases, but I have found it very efficient for years. Maybe some similar algorithm could be useful.
Source: pimalaya/himalaya