Calling `toISOString` on a Duration object does not return weeks
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
There's a weird behavior when it comes to getting an ISO duration string from the dayjs's duration object. For example:
```ts
dayjs.duration({ year:1, week: 2 }).toISOString(); // 'P1Y14D'
dayjs.duration('P2Y3W5D').toISOString(); // 'P2Y26D'
```
**Expected behavior**
It'd be really great if weeks weren't converted to days. So we'd get these in the output:
```ts
dayjs.duration({ year:1, week: 2 }).toISOString(); // 'P1Y2W'
dayjs.duration('P2Y3W5D').toISOString(); // 'P2Y3W5D'
```
**Information**
- Day.js Version: v1.11.8
- OS: Linux
- Browser: Brave v 1.77.97
- Time zone: GMT+3:30
Contributor guide
Research direction
Start by locating the duration object's toISOString implementation and the existing duration parsing or formatting tests. Reproduce both examples from the issue, then update the behavior so weeks remain represented as weeks in output while preserving the year and day components. Done means both object construction and ISO-string parsing produce the expected strings, with regression coverage.
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
- Clearly specified
- Newbie friendliness
- 45/100