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

Humanize Count #456

Closed
timothy-shields opened this issue Sep 10, 2015 · 4 comments
Closed

Humanize Count #456

timothy-shields opened this issue Sep 10, 2015 · 4 comments

Comments

@timothy-shields
Copy link

It seems like there isn't any functionality to humanize a count. Some examples:

0 => "0"
14 => "14"
71004 => "71k"
51000492 => "5m" (lower precision)
51000492 => "5.1m" (higher precision)

It seems very similar to ByteSize (maybe Count?) except you'd have Count.Ones, Count.Hundreds, Count.Thousands, Count.Millions, etc. Count.Humanize(precision) would return the count string at that precision.

Example:

51000492.ToCount().Humanize(1) => "51000492"
51000492.ToCount().Humanize(0.999) => "5.1m"

Does this functionality exist in the library? If not, was it excluded by design? Or has it just not been thought of or implemented?

A good example of this kind of humanization of a count is on StackOverflow: http://stackoverflow.com/questions?sort=votes Note how the views ("673k views", "2.4m views", etc.) look.

@MehdiK
Copy link
Member

MehdiK commented Sep 11, 2015

Thanks for the suggestion @timothy-shields. This feature does not exist because it was never requested.

It would make for a good addition. Did you want to submit a PR? :)

@aloisdg
Copy link
Contributor

aloisdg commented Sep 15, 2015

Just saw this post. I create exactly the same issue ( #457 ) two days ago. I used the searchbox without success. I should just read the issue list.

Well, I wrote the code to handle this. I will rewrite it and submit a PR.

@aloisdg
Copy link
Contributor

aloisdg commented Sep 19, 2015

Code rewrote. Test added. PR coming soon. (tomorrow? :)

@clairernovotny
Copy link
Member

This was implemented in #459 and is now in dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants