isSame() returns true when comparing a certain date to undefined
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
When comparing 2024-01-31 to undefined the result is true. I've checked it on all dates from 2010 to 2030 and only this particular date triggers the problem.
`dayjs('2024-01-31').isSame(undefined,'day'); // returns true`
`dayjs('2024-01-30').isSame(undefined,'day'); // returns false`
Code used to check multiple dates:
```
let cd=dayjs('2010-01-01');
for (let i=1; i<=365*20; i++) {
if (cd.isSame(undefined,'day')) {
console.log(cd.format('YYYY-MM-DD'));
}
cd=cd.add(1,'day');
}
```
**Information**
- Day.js Version: 1.11.10
- OS: Windows
- Browser: Firefox 122, Chrome 121
- Time zone: Eastern European Standard Time [GMT+2]
Contributor guide
Research direction
Start by reproducing the issue's `dayjs('2024-01-31').isSame(undefined, 'day')` example and compare it with the adjacent date case. Trace the `isSame()` entry point and add a regression test covering the undefined comparison. Done means the reported date no longer returns true unexpectedly, while the surrounding date behavior remains correct.
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
- 45/100