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

Rounding #143

Closed
hugovk opened this issue Jul 16, 2020 · 6 comments
Closed

Rounding #143

hugovk opened this issue Jul 16, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@hugovk
Copy link
Collaborator

hugovk commented Jul 16, 2020

One oddity to me is the rounding. While I can understand that

humanize.naturaltime(2*365*24*60*60 - 1)

is 1 year, 11 months ago and not 2 years ago, because the year is not complete yet and we don't celebrate birthdays early ("how long ago was it?" - "2 years?" - "not yet!"), my intuitive expectation of

humanize.naturaldelta(2*365*24*60*60 - 1)

is actually 2 years - because with deltas ("how long did it take?"), I feel rounding is much more natural.

So for 101_943 / 1_000_000, I'd probably expect 102 milliseconds.

Originally posted by @bersbersbers in #75 (comment)

@ssbarnea
Copy link

I totally agree that current behavior is flawed, I had a duration of ~170 days which counts for 5.7 months, clearly something to be rounded up but it reported "5 months".

@hugovk
Copy link
Collaborator Author

hugovk commented Sep 10, 2020

@bersbersbers @ssbarnea Please could you have a look at #154 and see if it does the right sort of thing? Thanks!

@hugovk hugovk added the enhancement New feature or request label Sep 10, 2020
@bersbersbers
Copy link

bersbersbers commented Sep 10, 2020

I will try it once it published on PyPI, but I don't have the bandwidth right now to check that PR closely. At first sight, it does make sense.

@hugovk
Copy link
Collaborator Author

hugovk commented Sep 10, 2020

No problem, thanks for the quick check!

In case it helps, it's possible to pip install from the Git branch like this:

pip install git+https://github.com/hugovk/humanize.git@naturaldelta-rounding

@bersbersbers
Copy link

bersbersbers commented Sep 11, 2020

That does help, thanks. A few tests that I did revealed these unexpected ones:

>>> humanize.naturaldelta(2*365*24*60*60-1)
'2 years'
>>> humanize.naturaldelta(1*365*24*60*60-1)
'1 year, 364 days'

I did not test further as it seems an error needs to be fixed first.

@hugovk
Copy link
Collaborator Author

hugovk commented May 3, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants