Revert "Added error handling to format-past-date to prevent timeouts on modlog (#2083)"

This reverts commit 02bb1b84e1.
This commit is contained in:
Dessalines 2023-09-29 07:43:30 -04:00
parent 8977b5353a
commit 01db851785

View file

@ -2,23 +2,8 @@ import formatDistanceStrict from "date-fns/formatDistanceStrict";
import parseISO from "date-fns/parseISO"; import parseISO from "date-fns/parseISO";
export default function (dateString?: string) { export default function (dateString?: string) {
if (!dateString) { const parsed = parseISO((dateString ?? Date.now().toString()) + "Z");
console.error(err);
return "DATE ERROR";
}
try {
const parsed = parseISO(Date.now().toString() + "Z");
return formatDistanceStrict(parsed, new Date(), { return formatDistanceStrict(parsed, new Date(), {
addSuffix: true, addSuffix: true,
}); });
} catch (err) {
console.error(err);
if (err instanceof RangeError) {
console.error(
`Got the invalid value of ${dateString} when attempting to parse to ISO date`,
);
return "DATE ERROR";
}
}
} }