arrow-py / arrow

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

Humanize Format Relative Error For Multiple Granularities #996

Closed anishnya closed 2 years ago

anishnya commented 3 years ago

Issue Description

System Info

    import arrow
    arw = arrow.Arrow(2013, 1, 1, 0, 0, 0)
    later = arw.shift(seconds=3600)
    humanize_string = arw.humanize(later, granularity=["second", "hour", "day", "month", "year"],)
    print(humanize_string)
    >>> "in 0 years 0 months 0 days an hour and 0 seconds"

"in 0 years 0 months 0 days an hour and 0 seconds" should be "0 years 0 months 0 days an hour and 0 seconds ago". I suspect this is dude to the fact in describe-mutli we take timeframes[-1], which in this case would be 0. This results in format relative defaulting to it's positive version. We might need a linear search through all the timeframe units to better determine the correct relative phrase to use.