mirror of
https://github.com/rustfs/console.git
synced 2026-08-31 01:37:52 +08:00
13 lines
282 B
TypeScript
13 lines
282 B
TypeScript
export function normalizeDateToIso(value: Date | string | undefined | null): string {
|
|
if (!value) return ""
|
|
|
|
const date = value instanceof Date ? value : new Date(value)
|
|
const time = date.getTime()
|
|
|
|
if (Number.isNaN(time)) {
|
|
return ""
|
|
}
|
|
|
|
return date.toISOString()
|
|
}
|