isoWeekday(x) doesn't get next day of week, but previous
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
isoWeekday(x) doesn't get next day of week, but previous, **at least when that day already passed**
**Expected behavior**
Similar to https://day.js.org/docs/en/get-set/weekday
```
dayjs().weekday(5) // next Friday (5th day after Sunday)
```
Today, Sunday, it behaves like this:
```
dayjs().format('YYYY-MM-DD')
'2022-08-21'
dayjs().isoWeekday(7).format('YYYY-MM-DD')
'2022-08-21' // correct, first possible Sunday is today.
dayjs().isoWeekday(5).format('YYYY-MM-DD')
'2022-08-19' // bug. Next or first possible Friday is on 08-26. If I wanted the previous Friday, I would have used dayjs().isoWeekday(-5)
```
**Information**
- Day.js Version "version": "1.11.4",
- OS: linux
- Browser chrome 102
- Time zone: GMT+2
Contributor guide
Research direction
Start at the public isoWeekday API and compare its behavior with the weekday example in the issue, especially when the requested day has already passed in the current week. Reproduce the Sunday case from the report, then add or update regression coverage so isoWeekday(5) selects the upcoming Friday while isoWeekday(7) remains the current Sunday.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100