From: Anon <makotech222@users.noreply.github.com> 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/%22https:/join-lemmy.org/%24%7Bsite?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"; + } }