Unable to parse date using CustomParseFormat
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.8k
- PR merge metrics
- No merged PRs in 30d
Description
Strict parsing is not working as expected in the below scenario:
dayjs.extend(dayjs_plugin_customParseFormat);
dayjs.extend(dayjs_plugin_utc);
dayjs.extend(dayjs_plugin_advancedFormat);
dayjs.extend(dayjs_plugin_timezone);
const format = [
"YYYY-MM-DD",
"YYYY/MM/DD",
"YYYY/MM/DD HH:mm:ss",
"YYYY-MM-DD HH:mm:ss",
"MM/DD/YYYY hh:mm:ss [A]",
"MM-DD-YYYY hh:mm:ss [A]",
"YYYY/MM/DD hh:mm:ss A",
"YYYY-MM-DD hh:mm:ss A",
"YYYY-MM-DDTHH:mm:ss",
"YYYY/MM/DDTHH:mm:ss",
"YYYY-MM-DDTHH:mm:ss[Z]",
"YYYY/MM/DDTHH:mm:ss[Z]",
"YYYY-MM-DDTHH:mm:ss.SSS",
"YYYY/MM/DDTHH:mm:ss.SSS"
];
console.log(dayjs('03-02-2001 10:00:00 AM', format, true).isValid());
Current Output
False
Expected Output
True
Sample Code/Jsfiddle - https://jsfiddle.net/ubcazw7g/6/
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied JSFiddle and inspect the CustomParseFormat plugin's strict parsing entry point, especially handling of an array of formats with the shown date. Reproduce the false result, then trace how the matching format is selected. Done means the example returns true without breaking strict parsing for the other listed formats, with a regression test covering this case.
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
- Mostly clear
- Newbie friendliness
- 45/100