-import { capitalizeFirstLetter } from "@utils/helpers";
+import { capitalizeFirstLetter, formatPastDate } from "@utils/helpers";
import format from "date-fns/format";
-import formatDistanceToNow from "date-fns/formatDistanceToNow";
import parseISO from "date-fns/parseISO";
import { Component } from "inferno";
import { I18NextService } from "../../services";
className="moment-time font-italics pointer unselectable"
>
<Icon icon="edit-2" classes="icon-inline me-1" />
- {formatDistanceToNow(parseISO(this.props.updated))}
+ {formatPastDate(this.props.updated)}
</span>
);
} else {
className="moment-time pointer unselectable"
data-tippy-content={momentFormat(published)}
>
- {formatDistanceToNow(parseISO(published))}
+ {formatPastDate(published)}
</span>
);
}
} from "@utils/app";
import {
debounce,
+ formatPastDate,
getIdFromString,
getPageFromString,
getQueryParams,
import { amAdmin, amMod } from "@utils/roles";
import type { QueryParams } from "@utils/types";
import { Choice, RouteDataResponse } from "@utils/types";
-import formatDistanceToNowStrict from "date-fns/formatDistanceToNowStrict";
-import parseISO from "date-fns/parseISO";
import { NoOptionI18nKeys } from "i18next";
import { Component, linkEvent } from "inferno";
import { T } from "inferno-i18next-dess";
return action !== undefined ? (action as ModlogActionType) : "All";
}
-function getExpires(expires: string) {
- return formatDistanceToNowStrict(parseISO(expires));
-}
-
const getModlogActionMapper =
(
actionType: ModlogActionType,
)}
{expires && (
<span>
- <div>expires: {getExpires(expires)}</div>
+ <div>expires: {formatPastDate(expires)}</div>
</span>
)}
</>
)}
{expires && (
<span>
- <div>expires: {getExpires(expires)}</div>
+ <div>expires: {formatPastDate(expires)}</div>
</span>
)}
</>
)}
{expires && (
<span>
- <div>expires: {getExpires(expires)}</div>
+ <div>expires: {formatPastDate(expires)}</div>
</span>
)}
</>
--- /dev/null
+import formatDistanceStrict from "date-fns/formatDistanceStrict";
+import parseISO from "date-fns/parseISO";
+
+export default function (dateString?: string) {
+ return formatDistanceStrict(
+ parseISO(dateString ?? Date.now().toString()),
+ new Date(),
+ {
+ addSuffix: true,
+ }
+ );
+}
import capitalizeFirstLetter from "./capitalize-first-letter";
import debounce from "./debounce";
import editListImmutable from "./edit-list-immutable";
+import formatPastDate from "./format-past-date";
import futureDaysToUnixTime from "./future-days-to-unix-time";
import getIdFromString from "./get-id-from-string";
import getPageFromString from "./get-page-from-string";
capitalizeFirstLetter,
debounce,
editListImmutable,
+ formatPastDate,
futureDaysToUnixTime,
getIdFromString,
getPageFromString,