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

Greater precision formats #5

Closed
lancecarlson opened this issue Feb 2, 2018 · 6 comments
Closed

Greater precision formats #5

lancecarlson opened this issue Feb 2, 2018 · 6 comments

Comments

@lancecarlson
Copy link

Currently the format only displays the highest unit of time and chops off the rest. It would be great for it to include hours, minutes, seconds etc if you want and be customizable.

@vi vi mentioned this issue Feb 4, 2018
@vi
Copy link
Owner

vi commented Feb 7, 2018

Please review the proposed API for translation and additional features: https://github.com/vi/timeago/blob/9979380380f876bb0c22cbd68b60516e16743a5f/src/lib.rs

Is it going to the right direction?

@lancecarlson
Copy link
Author

@vi Forgive me if I'm blind, but I can't really tell what is different from the previous API?

@vi
Copy link
Owner

vi commented Feb 7, 2018

Instead of convert function accepting Style enum there is Formatter struct employing builder pattern to configure various conversion options, including num_items to add precision.

Previous API is this: https://docs.rs/timeago/0.0.2/timeago/

@lancecarlson
Copy link
Author

Ah so the basic premise is that you can build your own Style. Got it. Is it possible to easily specify more granular units? An example of how to do so would be awesome.

For example:

Just now
1 second ago
2 seconds ago
1 minute 30 seconds ago
2 minutes 29 seconds ago
etc.

@vi
Copy link
Owner

vi commented Feb 7, 2018

Do you mean "describe it down to seconds, but don't go to milliseconds", so it can be approx. 1 year, 7 months, 13 days, 3 hours, 56 seconds ago or "specify duration with precision up to 3 units", like in approx. 1 year, 7 months, 13 days.

Currently it is aimed at the second one, but I'm not sure which one is better/needed (or both?).

(My own use case which I had in mind while developing timeago is formt_5chars mode for exa).

@vi
Copy link
Owner

vi commented Mar 26, 2018

Released version 0.1.1, with precision controlled by num_items and min_unit

@vi vi closed this as completed Mar 26, 2018
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

No branches or pull requests

2 participants