Files
rustfs-console/lib/safe-date.ts
T

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()
}