humanize a duration returns month instead of days with updated locale
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When updating the locale to change the 'a month' format to '1 month':
```javascript
dayjs.updateLocale('en', {
relativeTime: {
future: 'in %s', past: '%s ago', s: '%d seconds',
m: '%d minute', mm: '%d minutes',
h: '%d hour', hh: '%d hours',
d: '%d day', dd: '%d days',
M: '%d month', MM: '%d months',
y: '%d year', yy: '%d years'
}
});
```
The humanize function does not work as expected.
`dayjs.duration(1, "month").humanize()` returns `'30 month'`
same for `dayjs.duration(30, "days").humanize()` and `dayjs.duration("P1M").humanize()`
I have tested the limits:
```javascript
dayjs.duration(25, 'days').humanize()
'25 days'
dayjs.duration(26, 'days').humanize()
'26 month'
dayjs.duration(45, 'days').humanize()
'45 month'
dayjs.duration(46, 'days').humanize()
'1 month'
```
**Expected behavior**
It should return `'1 month'`
**Information**
- Day.js Version 1.11.12
- OS: windows
- Browser Chrome 126
- Time zone: CET
Contributor guide
Research direction
Start by reproducing the reported cases through duration().humanize() after updateLocale(), including 25–46 days, 1 month, and P1M. Trace how humanize selects relative-time units and applies the locale tokens; done means month inputs return the expected singular month wording while day thresholds retain their documented behavior, with regression coverage for these examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100