mirror of
https://github.com/Xevion/rdap.git
synced 2025-12-08 10:08:10 -06:00
Use react-timeago for DynamicDate component, improve relative timing display
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { FunctionComponent } from "react";
|
||||
import { useBoolean } from "usehooks-ts";
|
||||
import { format, formatDistanceToNow } from "date-fns";
|
||||
import TimeAgo from "react-timeago";
|
||||
|
||||
type DynamicDateProps = {
|
||||
value: Date | number;
|
||||
@@ -23,11 +24,8 @@ const DynamicDate: FunctionComponent<DynamicDateProps> = ({
|
||||
<button onClick={toggleFormat}>
|
||||
<span title={date.toISOString()}>
|
||||
{showAbsolute
|
||||
? format(date, absoluteFormat ?? "LLL do, y HH:mm:ss")
|
||||
: formatDistanceToNow(date, {
|
||||
includeSeconds: true,
|
||||
addSuffix: true,
|
||||
})}
|
||||
? format(date, absoluteFormat ?? "LLL do, y HH:mm:ss xxx")
|
||||
: <TimeAgo date={date} />}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user