fix(utils): fix dateUtil.formatToDate/formatToDateTime ts type (#2354)

This commit is contained in:
hunshcn 2022-11-11 09:52:30 +08:00 committed by GitHub
parent 384f929443
commit 5539190c39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -6,16 +6,13 @@ import dayjs from 'dayjs';
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
const DATE_FORMAT = 'YYYY-MM-DD';
export function formatToDateTime(
date: dayjs.Dayjs | undefined = undefined,
format = DATE_TIME_FORMAT,
): string {
export function formatToDateTime(date?: dayjs.ConfigType, format = DATE_TIME_FORMAT): string {
return dayjs(date).format(format);
}
export function formatToDate(date?: dayjs.ConfigType, format = DATE_FORMAT): string {
if (typeof date === 'number') date *= 1000;
return dayjs(date).format(format);
}
export const dateUtil = dayjs;