From e82a83c8cf5e8721f80bb426c3dfdd9549e09a88 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 2 Aug 2022 15:19:51 +0200 Subject: [PATCH] fix: properly parse dates or null Resolves https://kolaente.dev/vikunja/frontend/issues/2214 --- src/helpers/parseDateOrNull.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/helpers/parseDateOrNull.ts b/src/helpers/parseDateOrNull.ts index 656e36df..836b3040 100644 --- a/src/helpers/parseDateOrNull.ts +++ b/src/helpers/parseDateOrNull.ts @@ -1,13 +1,14 @@ /** * Make date objects from timestamps -*/ + */ export function parseDateOrNull(date) { if (date instanceof Date) { return date } - if (date && !date.startsWith('0001')) { + if ((typeof date === 'string' || date instanceof String) && !date.startsWith('0001')) { return new Date(date) } + return null }