fix: dateFns parse strict mode

pull/5256/head
tangjinzhou 3 years ago
parent 91c6a28205
commit 2d0e2b6899

@ -23,6 +23,7 @@ import {
format as formatDate, format as formatDate,
parse as parseDate, parse as parseDate,
isDate, isDate,
isMatch,
} from 'date-fns'; } from 'date-fns';
import * as Locale from 'date-fns/locale'; import * as Locale from 'date-fns/locale';
import type { GenerateConfig } from '.'; import type { GenerateConfig } from '.';
@ -104,7 +105,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) && formatText.length === format.length) { if (isValid(date) && isMatch(formatText, format)) {
return date; return date;
} }
} }

Loading…
Cancel
Save