fix(utils): The date function gets a non-date when the parameter is null (#954)

Co-authored-by: “weilin <“784742294@qq.com>
This commit is contained in:
wl19 2021-07-23 07:29:39 +08:00 committed by GitHub
parent 202aa42b8d
commit 350c85accf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,13 +7,13 @@ const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm';
const DATE_FORMAT = 'YYYY-MM-DD '; const DATE_FORMAT = 'YYYY-MM-DD ';
export function formatToDateTime( export function formatToDateTime(
date: moment.MomentInput = null, date: moment.MomentInput = undefined,
format = DATE_TIME_FORMAT format = DATE_TIME_FORMAT
): string { ): string {
return moment(date).format(format); return moment(date).format(format);
} }
export function formatToDate(date: moment.MomentInput = null, format = DATE_FORMAT): string { export function formatToDate(date: moment.MomentInput = undefined, format = DATE_FORMAT): string {
return moment(date).format(format); return moment(date).format(format);
} }