From: Anon Date: Sun, 13 Aug 2023 02:46:26 +0000 (-0500) Subject: Temp fix to modlog failing to render future dates (#2058) X-Git-Url: http://these/git/%7B%60/feeds/u/%24%7Bthis.state.username%7D.xml?a=commitdiff_plain;h=f27cbb3224e4092dc011624da7c822e940cd20f1;p=lemmy-ui.git Temp fix to modlog failing to render future dates (#2058) --- diff --git a/src/shared/utils/helpers/format-past-date.ts b/src/shared/utils/helpers/format-past-date.ts index 5bef4e8..02944a8 100644 --- a/src/shared/utils/helpers/format-past-date.ts +++ b/src/shared/utils/helpers/format-past-date.ts @@ -3,7 +3,11 @@ import parseISO from "date-fns/parseISO"; export default function (dateString?: string) { const parsed = parseISO((dateString ?? Date.now().toString()) + "Z"); - return formatDistanceStrict(parsed, new Date(), { - addSuffix: true, - }); + try { + return formatDistanceStrict(parsed, new Date(), { + addSuffix: true, + }); + } catch (e) { + return "indeterminate"; + } }