iamkun / iamkun/dayjs

dayjs(value, formats, true).isValid() bug

Open
#2,608 1 comment 0 reactions 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**
dayjs(value, formats, true).isValid() always returns false
im using is with a post response to convert date to +1 gmt. if(dayjs(value, formats, true).isValid()) then convert
code:
import * as customParseFormat from 'dayjs/plugin/customParseFormat';
dayjs.extend(customParseFormat)

var formats = [
"DD/MM/YYYY :) HH*mm*ss",
"YYYY/MM/DD :) HH*mm*ss.SSS",
"YYYY-MM-DDTHH:mm:ssZ",
"YYYY-MM-DDTHH:mm:ss.SSSZ",
"YYYY-MM-DDTHH:mm:ss.SSS",
"DD MM YYYY HH:mm:ss Z",
"LLLL",
"LLL",
"llll",
"lll",
];

dayjs('2024-03-25T23:00:00.000Z', formats, true).isValid()

the output will be false and I expect it to return true

**Expected behavior**
A clear and concise description of what you expected to happen.

**Information**
- Day.js Version [^1.11.10]
- OS: [Windows]
- Browser [Chrome]
- Time zone: [+1]

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported dayjs('2024-03-25T23:00:00.000Z', formats, true).isValid() call with the customParseFormat plugin enabled. Trace the plugin's handling of the supplied format array and strict parsing, then verify that the reported ISO value is accepted while preserving the existing format 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
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.