Template
1
0
mirror of https://github.com/un-pany/v3-admin-vite.git synced 2025-04-20 19:09:21 +08:00

refactor: 重写 formatDateTime 工具函数

This commit is contained in:
pany 2024-11-11 19:06:19 +08:00
parent 6f2fbf4a90
commit 6680e72645
2 changed files with 9 additions and 6 deletions

9
src/utils/datetime.ts Normal file
View File

@ -0,0 +1,9 @@
import dayjs from "dayjs"
const INVALID_DATE = "N/A"
/** 格式化日期时间 */
export const formatDateTime = (datetime: string | number | Date = "", template: string = "YYYY-MM-DD HH:mm:ss") => {
const day = dayjs(datetime)
return day.isValid() ? day.format(template) : INVALID_DATE
}

View File

@ -1,11 +1,5 @@
import dayjs from "dayjs"
import { removeConfigLayout } from "@/utils/cache/local-storage"
/** 格式化时间 */
export const formatDateTime = (time: string | number | Date) => {
return time ? dayjs(new Date(time)).format("YYYY-MM-DD HH:mm:ss") : "N/A"
}
/** 用 JS 获取全局 css 变量 */
export const getCssVariableValue = (cssVariableName: string) => {
let cssVariableValue = ""