Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves #270: add support for --time-style=relative #1061

Closed
wants to merge 7 commits into from

Conversation

syphar
Copy link

@syphar syphar commented Apr 30, 2022

This adds showing relative timestamps for #270 .

For the first version this uses timeago from the issue.

I didn't find tests covering this part of the codebase, I'm happy to add them with a better idea on what should be covered and how.

Also I'm happy to change the format if that's something we want (the LS++ format also looks neat).

Different colouring for different ages I would add separately.

@syphar
Copy link
Author

syphar commented Apr 30, 2022

How it looks like on my machine:

grafik

src/output/time.rs Outdated Show resolved Hide resolved
@anthraxx
Copy link

How it looks like on my machine:

grafik

I'm wondering if it would be possible to omit the repetitive " ago", this just consumes a lot of space without adding value to the output

@syphar
Copy link
Author

syphar commented Apr 30, 2022

"ago" is gone now:
image

@ariasuni
Copy link
Collaborator

I didn't find tests covering this part of the codebase, I'm happy to add them with a better idea on what should be covered and how.

You can check the Testing with vagrant section of the README, and the README in the xtests folder. You can probably extend these date tests (tip: use e.g. exa -l --time-style=relative --color=always > xtests/outputs/dates_long_timestyle_relative.ansitxt to get the output to test).

src/options/view.rs Outdated Show resolved Hide resolved
@syphar
Copy link
Author

syphar commented Apr 30, 2022

I didn't find tests covering this part of the codebase, I'm happy to add them with a better idea on what should be covered and how.

You can check the Testing with vagrant section of the README, and the README in the xtests folder. You can probably extend these date tests (tip: use e.g. exa -l --time-style=relative --color=always > xtests/outputs/dates_long_timestyle_relative.ansitxt to get the output to test).

Thanks for the hint! Somehow I missed that part.

Will add tests

@planet36
Copy link

planet36 commented Apr 30, 2022

How are relative future dates printed?
lsd prints "in XXXX" for future dates, in contrast to "XXXX ago" for past dates.

(edit: changed underscores to Xs)

@syphar
Copy link
Author

syphar commented Apr 30, 2022

I didn't find tests covering this part of the codebase, I'm happy to add them with a better idea on what should be covered and how.

You can check the Testing with vagrant section of the README, and the README in the xtests folder. You can probably extend these date tests (tip: use e.g. exa -l --time-style=relative --color=always > xtests/outputs/dates_long_timestyle_relative.ansitxt to get the output to test).

@ariasuni I added tests as described. Many other tests were failing on my machine, is that intended?

@syphar
Copy link
Author

syphar commented Apr 30, 2022

How are relative future dates printed?
lsd prints "in " for future dates, in contrast to " ago" for past dates.

Currently it would print just now, also since timeago doesn't support future times yet. From the source, LS++ also only renders past dates correctly.

@anthraxx
Copy link

How are relative future dates printed?
lsd prints "in " for future dates, in contrast to " ago" for past dates.

Currently it would print just now, also since timeago doesn't support future times yet. From the source, LS++ also only renders past dates correctly.

I would personally consider sind more an edge case that shouldn't normally happen. printing just now on future dates sounds reasonable enough

@vi
Copy link

vi commented May 1, 2022

For the first version this uses timeago from the issue.

Note that timeago was developed specifically for #270.

If something is amiss in timeago, more features can be added (especially if it does not require translators to update their translations).

@vi
Copy link

vi commented May 1, 2022

omit the repetitive " ago"

Note that timeago crate has special simplified function format_5chars for compressed time intervals representations of predictable width. This one is English-only and is not supposed to be translated though.

@syphar
Copy link
Author

syphar commented May 1, 2022

omit the repetitive " ago"

Note that timeago crate has special simplified function format_5chars for compressed time intervals representations of predictable width. This one is English-only and is not supposed to be translated though.

This probably boils down to a design decision:

  1. change to 5chars
  2. add language to relative format (I see other date formats are localized, so probably we could use timeago languages too, where supported).

@vi
Copy link

vi commented May 1, 2022

change to 5chars

It may make sense to provide both options depending on listing options. Terse, but less user-friendly look may be poor default mode.

@ariasuni
Copy link
Collaborator

ariasuni commented May 2, 2022

@ariasuni I added tests as described. Many other tests were failing on my machine, is that intended?

Uh yeah since they’re not on the CI, there are some that got broken and I need to merge the fixes and stuff… if your tests work then it’s fine. Also, it would be nice to have a test for future dates, see there:

# distant past and far future dates
[[cmd]]
name = "‘exa -l’ handles dates far past and future dates"
shell = "exa -l /testcases/far-dates"
stdout = { file = "outputs/far_dates_long.ansitxt" }
stderr = { empty = true }
status = 0
tags = [ 'long', 'time' ]

@syphar
Copy link
Author

syphar commented May 2, 2022

@ariasuni I added tests as described. Many other tests were failing on my machine, is that intended?

Uh yeah since they’re not on the CI, there are some that got broken and I need to merge the fixes and stuff… if your tests work then it’s fine. Also, it would be nice to have a test for future dates, see there:

done, added the far future test.

@syphar
Copy link
Author

syphar commented May 8, 2022

@ariasuni is there anything else missing? I'm happy to change where necessary :)

@Hyoihz
Copy link

Hyoihz commented Jul 4, 2022

I'm having troubles displaying files properly with exa.

exa when run as is (without any flags), displays my files one per line as if I'd passed the -1 or --oneline flag.

out

But when I use exa that's from my package manager, it works normally as how ls and lsd was displayed.

@syphar
Copy link
Author

syphar commented Jul 27, 2022

just went through old open PRs and came back to this one :)

@ariasuni I would love to see this in exa, I'm happy to add anything that's needed to get this finished up

@syphar
Copy link
Author

syphar commented Mar 7, 2023

Hello @ariasuni I just remembered that I still had this PR open, and would love to see this feature in exa :)
Is there anything that is missing that I can do to get this to land?

To start, I just rebased on the current master :)

@varon
Copy link

varon commented Mar 23, 2023

This would be great to have.

@ariasuni
Copy link
Collaborator

Closing this, since exa is unmaintained (see #1243), and this has been done in the active fork eza. Thanks!

@ariasuni ariasuni closed this Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants