This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/helpers/parseDateOrNull.ts
kolaente e82a83c8cf
All checks were successful
continuous-integration/drone/push Build is passing
fix: properly parse dates or null
Resolves #2214
2022-08-02 15:19:58 +02:00

15 lines
264 B
TypeScript

/**
* Make date objects from timestamps
*/
export function parseDateOrNull(date) {
if (date instanceof Date) {
return date
}
if ((typeof date === 'string' || date instanceof String) && !date.startsWith('0001')) {
return new Date(date)
}
return null
}