mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
refactor(util): 完善datetimeFormatter方法ts定义
This commit is contained in:
parent
c63c807232
commit
654961b349
@ -39,7 +39,7 @@ export const datetimeFormatter = (
|
|||||||
format = 'YYYY-MM-DD HH:mm:ss',
|
format = 'YYYY-MM-DD HH:mm:ss',
|
||||||
): string | number => {
|
): string | number => {
|
||||||
if (v) {
|
if (v) {
|
||||||
let time = null;
|
let time: string | number;
|
||||||
if (['x', 'timestamp'].includes(format)) {
|
if (['x', 'timestamp'].includes(format)) {
|
||||||
time = dayjs(v).valueOf();
|
time = dayjs(v).valueOf();
|
||||||
} else if ((typeof v === 'string' && v.includes('Z')) || v.constructor === Date) {
|
} else if ((typeof v === 'string' && v.includes('Z')) || v.constructor === Date) {
|
||||||
@ -50,7 +50,6 @@ export const datetimeFormatter = (
|
|||||||
time = dayjs(v).format(format);
|
time = dayjs(v).format(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化为北京时间
|
|
||||||
if (time !== 'Invalid Date') {
|
if (time !== 'Invalid Date') {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user