arrow-py / arrow

🏹 Better dates & times for Python
https://arrow.readthedocs.io
Apache License 2.0
8.71k stars 673 forks source link

humanize() rounding problem #848

Closed mattiaverga closed 3 years ago

mattiaverga commented 4 years ago

Issue Description

Not sure if this is wanted or a bug. humanize() returns "a week ago" for deltas < 7 days. For example:

>>> arrow.utcnow().shift(days=-6, hours=-9).humanize()
'6 days ago'
>>> arrow.utcnow().shift(days=-6, hours=-10).humanize()
'a week ago'

I would expect "a week ago" to be returned after 7 days have passed.

System Info

jadchaar commented 4 years ago

It seems that the humanize function was originally designed with impreciseness in mind to give ballpark estimates for humanized date/time formats. That said, I think it would be nice to add an exact or precise keyword argument to allow users to choose which type of functionality they want, and we can adjust the bounds appropriately. What do you think @systemcatch ?