Format duration, leave out / escape months and add it to days amount
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Formatting a duration does not have the ability to escape months.
Instead it just ignores them
For example we want to display PT11856H8M34S as years, days, hours, minutes & seconds. Leaving out the months.
dayjs.duration('PT11856H8M34S').add(0,'s').format('Y[y] D[d] H[h] m[m]')
Output: 1y 9d 0h 8m
dayjs.duration('PT11856H8M34S').add(0,'s').format('Y[y] M[m] D[d] H[h] m[m]')
Output: 1y 4m 9d 0h 8m
You can clearly see that we lose 4 months of days... How can we prevent this? It should output something like 1y 129d 0h 8m
**Expected behavior**
Adding months to days value
**Information**
- Day.js Version 1.11.2
Contributor guide
Research direction
Start by reproducing the two dayjs.duration(...).format examples from the issue and inspect the duration formatting entry point and related tests. Done means omitted months are accounted for in the displayed day amount, while explicit month formatting continues to report months correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100