1
Fork 0
mirror of https://github.com/Steffo99/festa.git synced 2024-12-23 07:04:22 +00:00
festa/utils/dateFields.ts

20 lines
No EOL
439 B
TypeScript

export function toDatetimeLocal(date: Date | null | undefined): string | undefined {
if (date === undefined) {
return undefined
}
else if (date === null) {
return ""
}
else {
return date.toISOString().match(/(.+)[Z]$/)![1]
}
}
export function fromDatetimeLocal(str: string): Date | null {
if (str === "") {
return null
}
else {
return new Date(`${str}Z`)
}
}