mirror of
https://github.com/Steffo99/festa.git
synced 2024-12-22 22:54:22 +00:00
20 lines
No EOL
439 B
TypeScript
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`)
|
|
}
|
|
} |