refactor(util): 完善datetimeFormatter方法ts定义

This commit is contained in:
roymondchen 2024-06-21 16:26:23 +08:00
parent c63c807232
commit 654961b349

View File

@ -39,7 +39,7 @@ export const datetimeFormatter = (
format = 'YYYY-MM-DD HH:mm:ss',
): string | number => {
if (v) {
let time = null;
let time: string | number;
if (['x', 'timestamp'].includes(format)) {
time = dayjs(v).valueOf();
} else if ((typeof v === 'string' && v.includes('Z')) || v.constructor === Date) {
@ -50,7 +50,6 @@ export const datetimeFormatter = (
time = dayjs(v).format(format);
}
// 格式化为北京时间
if (time !== 'Invalid Date') {
return time;
}