perf: formApi added validateAndSubmitForm & filedMapToTime renamed fieldMappingTime (#4842)

* perf: formApi added validateAndSubmitForm & filedMapToTime renamed fieldMappingTime
This commit is contained in:
Vben
2024-11-09 15:00:59 +08:00
committed by GitHub
parent 632081e828
commit 8617d3dd1e
13 changed files with 60 additions and 56 deletions

View File

@@ -84,6 +84,7 @@
"@types/lodash.get": "catalog:",
"@vue/shared": "catalog:",
"clsx": "catalog:",
"dayjs": "^1.11.13",
"defu": "catalog:",
"lodash.clonedeep": "catalog:",
"lodash.get": "catalog:",

View File

@@ -0,0 +1,18 @@
import dayjs from 'dayjs';
export function formatDate(time: number | string, format = 'YYYY-MM-DD') {
try {
const date = dayjs(time);
if (!date.isValid()) {
throw new Error('Invalid date');
}
return date.format(format);
} catch (error) {
console.error(`Error formatting date: ${error}`);
return time;
}
}
export function formatDateTime(time: number | string) {
return formatDate(time, 'YYYY-MM-DD HH:mm:ss');
}

View File

@@ -1,4 +1,5 @@
export * from './cn';
export * from './date';
export * from './diff';
export * from './dom';
export * from './inference';