Humanize Bug when using multiple Granularities
- Dominant language
- Python
- Stars
- 9.1k
- Forks
- 784
- PR merge metrics
- No merged PRs in 30d
Description
## Issue Description
Humanize appears to have a bug when dealing with multiple granularities.
```
arw = arrow.Arrow(2017, 1, 1, 0, 0, 0)
time_future = arw.shift(years=1, months=4, days=2, hours=6, seconds=2)
time_future_string = time_future.humanize(arw, locale="en", granularity=["year", "month", "day", "hour", "second"])
print("Starting time")
print(arw)
print("Actual new time after shift")
print(time_future)
print("Humanize shift")
print(time_future_string)
```
The shift function returns the expected time of May 3rd 2018, however running humanize on this object says "in a year 4 months 0 days 6 hours and 2 seconds." We would expect to see "in a year 4 months 2 days 6 hours and 2 seconds." Initially, I ran into this issue while attempting to shift across time spans of 10 years, so I thought the two-day discrepancy may be related to how leap years/leap days were handled. However, it appears to be a more generalized issue since there is no leap day between 2017 and 2018 May 3rd.
## System Info
- 🖥 **OS name and version**: macOS 10.15.7
- 🐍 **Python version**: 3.8.5
- 🏹 **Arrow version**: 1.0.3
Contributor guide
No contributing guide indexed for this repository
Research direction
Run the supplied Python example with Arrow 1.0.3 and compare the reported humanize output with the expected two-day component. Trace the humanize path for multiple granularities, then add a regression test showing that shifting from 2017-01-01 by one year, four months, two days, six hours, and two seconds reports all requested components correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100