arrow icon indicating copy to clipboard operation
arrow copied to clipboard

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

Open zachriggle opened this issue 4 years ago • 2 comments

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.

zachriggle avatar Mar 09 '21 04:03 zachriggle

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.

kjoyce77 avatar May 05 '21 13:05 kjoyce77

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.

anishnya avatar May 08 '21 02:05 anishnya