]> Untitled Git - lemmy-ui.git/commitdiff
Temp fix to modlog failing to render future dates (#2058)
authorAnon <makotech222@users.noreply.github.com>
Sun, 13 Aug 2023 02:46:26 +0000 (21:46 -0500)
committerGitHub <noreply@github.com>
Sun, 13 Aug 2023 02:46:26 +0000 (22:46 -0400)
src/shared/utils/helpers/format-past-date.ts

index 5bef4e83d1d0f678ed06958d3aafd95bc82465e0..02944a8864b220145260c8ed1642adf362d8a272 100644 (file)
@@ -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";
+  }
 }