This repository has been archived on 2025-10-28. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
vikunja-frontend/src/helpers/parseDateOrNull.ts

14 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
}