arrow-py / arrow

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

"humanize" should return "end of tomorrow" instead of "two days" #941

Open zachriggle opened 3 years ago

zachriggle commented 3 years ago

Feature Request

import arrow
import datetime

now = arrow.get()
print(now.humanize())

day = datetime.timedelta(days=1)
tomorrow = now + day
print(tomorrow.humanize())

end_of_tomorrow = tomorrow.replace(hour=23, minute=59, second=59)
print(end_of_tomorrow.humanize())

This prints

just now
in a day
in a day

It would be nice to be able to configure arrow.get(...).humanize to print something like:

just now
tomorrow at XPM
end of tomorrow

Similarly, it might be nice to get "Wednesday" instead of "in two days" (if today is e.g. Monday) via some fiddly knob.

kjoyce77 commented 3 years ago

The default behavior is very confusing at the day level... If an object is 47 hours in the future it shows up as 'in a day' instead of 'in about 2 days' or 'in a day and 23 hours'. The simplest change would be to add an option for levels of granularity. So if I say 2 levels it will do in 0 minutes 47 seconds, in a day and 3 hours, in a week and six days, and so on.

But +1 for day of week logic as an option -- "Friday at 6am" is more readily understood than "In a day and 46 hours," for example.

These are just thoughts I wanted to write down. When I have time I might be able to do some PRs on this.

anishnya commented 3 years ago

I think this is a nice feature to be added to humanize. However, I think it is worth noting that we have to be able to make it work with the 60+ locales we support. Something like returning "Wednesday" instead of "in 2 days" I think can work across locales. However, some of the other suggested features/behaviours will need contributions and updates on all the locales.