Skip to content

Commit 8f9875e

Browse files
committed
fix: datefns & dayjs parse strict, close #5221
1 parent 5d38b3c commit 8f9875e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

components/vc-picker/generate/dateFns.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const generateConfig: GenerateConfig<Date> = {
104104
const date = parseDate(formatText, format, new Date(), {
105105
locale: Locale[dealLocal(locale)],
106106
});
107-
if (isValid(date)) {
107+
if (isValid(date) && formatText.length === format.length) {
108108
return date;
109109
}
110110
}

components/vc-picker/generate/dayjs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ const generateConfig: GenerateConfig<Dayjs> = {
101101
parseNoMatchNotice();
102102
return null;
103103
}
104-
const date = dayjs(formatText, format).locale(localeStr);
104+
const date = dayjs(formatText, format, true).locale(localeStr);
105105
if (date.isValid()) {
106106
return date;
107107
}
108108
}
109109

110-
if (text) {
110+
if (!text) {
111111
parseNoMatchNotice();
112112
}
113113
return null;

0 commit comments

Comments
 (0)