customParseFormat plugin set random values when parsing invalid date
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
When trying to parse some invalid date like `"54/42/0000 00:00", "MM/DD/YYYY HH:mm"`, dayjs doesn't set the date as invalid and set a "random" value instead.
You can test here with a comparaison with moment [https://codesandbox.io/s/eager-frost-x1ng0](https://codesandbox.io/s/eager-frost-x1ng0).
```js
import moment from "moment";
import dayjs from "dayjs";
import customParseFormat from "dayjs/plugin/customParseFormat";
dayjs.extend(customParseFormat);
const momentDate = moment("00/00/0000 00:00", "MM/DD/YYYY HH:mm");
const dayjsDate = dayjs("00/00/0000 00:00", "MM/DD/YYYY HH:mm");
console.log("moment", momentDate, momentDate.isValid());
console.log("dayjs", dayjsDate, dayjsDate.isValid());
const otherMomentDate = moment("54/42/0000 00:00", "MM/DD/YYYY HH:mm");
const otherDayjsDate = dayjs("54/42/0000 00:00", "MM/DD/YYYY HH:mm");
console.log("other moment", otherMomentDate, otherMomentDate.isValid());
console.log("other dayjs", otherDayjsDate, otherDayjsDate.isValid());
```
Thank you :)
Contributor guide
Assessment
This issue has not been assessed yet.