mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-25 13:51:13 +00:00
Revert "Added error handling to format-past-date to prevent timeouts on modlog (#2083)"
This reverts commit 02bb1b84e1
.
This commit is contained in:
parent
8977b5353a
commit
01db851785
1 changed files with 4 additions and 19 deletions
|
@ -2,23 +2,8 @@ import formatDistanceStrict from "date-fns/formatDistanceStrict";
|
|||
import parseISO from "date-fns/parseISO";
|
||||
|
||||
export default function (dateString?: string) {
|
||||
if (!dateString) {
|
||||
console.error(err);
|
||||
return "DATE ERROR";
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = parseISO(Date.now().toString() + "Z");
|
||||
const parsed = parseISO((dateString ?? Date.now().toString()) + "Z");
|
||||
return formatDistanceStrict(parsed, new Date(), {
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue