duration({ days: 30 }) and duration(30, "days") return different values when converted to ISO8601
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
|input|result of calling `toISOString`|
|------|-------------------|
| dayjs.duration({ days: 30 }) | P30D|
| dayjs.duration(30, "d") | P1M |
| dayjs.duration(30, "day") | P1M |
| dayjs.duration(30, "days") | P1M |
| dayjs.duration("P30D") | P30D |
**Expected behavior**
I expected all of the above calls to return "P30D" as "P30D" has a different meaning than the more ambiguous "P1M" (which has different meaning depending on a given date as an anchor point).
I know P1M can be contentious but shouldn't these be consistent across the board? The docs mention this:
```
For example, a year can be defined as 366 days, 365 days, 365.25 days, 12 months, or 52 weeks. Trying to convert years to days makes no sense without context. It is much better to use dayjs#diff for calculating days or years between two date times than to use Durations.
```
Which I agree with - but I also think converting days to years / months also makes no sense without context. What do you think?
Thanks in advance!
**Information**
- Day.js Version [e.g. v1.0.0] 1.10.7
Contributor guide
Assessment
This issue has not been assessed yet.