iamkun / iamkun/dayjs

dayjs("02-29") return “2001-03-01”

Open
#2,594 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
In chrome and nodejs, dayjs("02-29") return “2001-03-01”.

**Expected behavior**
I think "02-29" should be a invalid input.
In firefox, this cause a error "Invalid Date". It's OK.
In chrome, the dafault year "2001" makes it even worse.
There is no "2001-02-29", but chrome/v8 makes it to be "2001-03-01".
It's certainly wrong. (Maybe also a bug to v8.)

**Information**
- Day.js Version 1.11.10
- OS: windows 7 - 10
- Browser chrome 109.0.5414.120 - 122.0.6261.95
- Time zone: GMT+0800 Asia/Shanghai

Contributor guide

Open the contributing guide

Research direction

Start by reproducing dayjs("02-29") in Chrome and Node.js, then trace the date-parsing entry point responsible for the result. The issue is done when this input is rejected as invalid consistently rather than normalized to 2001-03-01, with coverage for the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.