fix: datefns & dayjs parse strict, close #5221

pull/5256/head
tangjinzhou 2022-02-13 11:10:07 +08:00
parent 5d38b3cf8d
commit 8f9875e518
2 changed files with 3 additions and 3 deletions

View File

@ -104,7 +104,7 @@ const generateConfig: GenerateConfig<Date> = {
const date = parseDate(formatText, format, new Date(), { const date = parseDate(formatText, format, new Date(), {
locale: Locale[dealLocal(locale)], locale: Locale[dealLocal(locale)],
}); });
if (isValid(date)) { if (isValid(date) && formatText.length === format.length) {
return date; return date;
} }
} }

View File

@ -101,13 +101,13 @@ const generateConfig: GenerateConfig<Dayjs> = {
parseNoMatchNotice(); parseNoMatchNotice();
return null; return null;
} }
const date = dayjs(formatText, format).locale(localeStr); const date = dayjs(formatText, format, true).locale(localeStr);
if (date.isValid()) { if (date.isValid()) {
return date; return date;
} }
} }
if (text) { if (!text) {
parseNoMatchNotice(); parseNoMatchNotice();
} }
return null; return null;