iamkun / iamkun/dayjs

isValid bug

Open
#2,607 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
48.7k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

Executed below code.

```js
const dayjs = require('dayjs');

console.log(dayjs('2024-00-02T04:57:02Z').isValid());
console.log(dayjs('2024-02-31T22:03:08Z').isValid());
console.log(dayjs('2024-02-31T22:03:08Z', 'YYYY-MM-DDTHH:mm:ssZ', true).isValid());
```

result
```
false
true
true
```

February 2024 has only 29 days, not 31.
`dayjs('2024-02-31T22:03:08Z').isValid()` should return `false`.

**Expected behavior**
```
false
false
false
```

**Information**
- Day.js Version [e.g. v1.0.0]: v1.11.10
- OS: [e.g. iOS]: Ubuntu 20.04, Windows 10
- Browser [e.g. chrome 62]: Nope. Node.js 18
- Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)]: GMT +00:00

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the three Node.js examples from the issue and compare their isValid results with the expected values. Trace the date-parsing and validation entry points involved; done means invalid calendar dates such as February 31 are rejected consistently in both non-strict and strict parsing.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.