Beastwick18 / nyaa

A tui tool for browsing and downloading torrents
https://crates.io/crates/nyaa
GNU General Public License v3.0
385 stars 8 forks source link

Display relative date #31

Open Rodrigodd opened 4 days ago

Rodrigodd commented 4 days ago

Most of the time when I intend to download something, I need to check if the file was uploaded this week. It would be much easier if the Date column showed the relative date, like "today", "yesterday," or "3 days ago," instead of me needing to check today's date and compare it to the file's date.

I would prefer if it showed the day in relative format and kept the time in absolute format, but ideally, the format should be customizable.

Beastwick18 commented 2 days ago

Definitely a good idea. For TorrentGalaxy, this is already what it does since that is how the data is in the HTML, so it might have to be handled differently. For others like Nyaa & Sukebei, I can convert those fairly easily since they are already parsed for custom date formats.

Might make this an extension of the date_format string defined under each source/globally. Maybe using %r if that's not already used by something. Or it could just be a single boolean option like relative_date = true

Defining it through date_format would also be nice since it would allow showing the time alongside the relative date, like 3 days ago, 5:36pm.

Will for sure look into getting this added, though I haven't been putting much work into the project as of late.

Beastwick18 commented 2 days ago

image

I've got something working, at least for Nyaa right now. Will work on getting the other sources to implement this.

Instead of saying something like Today or Yesterday, it will just take the two most "general" descriptions of time. So if something happened 0 years, 1 month, 0 weeks, 3 days, 2 hours, 6 minutes, and 55 seconds ago, it will pick the top two non zero which are the month and days. So it would become 1 month, 3 days ago. Saying Today would become redundant since 8 hours, 5 minutes ago implies it happened today. Though Yesterday might stay since it would replace the 1 day case.

It'll likely use %q since almost every other letter is used. Further customization as to how this is formatted will have to be looked into.