Skip to content

Commit

Permalink
refactor(util): 完善datetimeFormatter方法ts定义
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen committed Jun 21, 2024
1 parent c63c807 commit 654961b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -50,7 +50,6 @@ export const datetimeFormatter = (
time = dayjs(v).format(format);
}

// 格式化为北京时间
if (time !== 'Invalid Date') {
return time;
}
Expand Down

0 comments on commit 654961b

Please sign in to comment.