mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-06-29 19:05:58 -04:00
use date-fns for relative time
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
import { h } from "preact";
|
||||
import dayjs from "dayjs";
|
||||
import dayjsRelativeTime from "dayjs/plugin/relativeTime.js";
|
||||
import { intlFormat, formatDistanceToNowStrict } from "date-fns";
|
||||
import parseEmoji from "../utils/parseEmoji.js";
|
||||
|
||||
// react components:
|
||||
import { StarIcon, RepoForkedIcon } from "@primer/octicons-react";
|
||||
|
||||
// dayjs plugins: https://day.js.org/docs/en/plugin/loading-into-nodejs
|
||||
dayjs.extend(dayjsRelativeTime);
|
||||
|
||||
const RepositoryCard = (props) => (
|
||||
<div class="github-card">
|
||||
<a class="repo-name" href={props.url} target="_blank" rel="noopener noreferrer">
|
||||
@@ -61,16 +57,22 @@ const RepositoryCard = (props) => (
|
||||
|
||||
<div
|
||||
class="repo-meta-item"
|
||||
title={new Intl.DateTimeFormat("en-US", {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "numeric",
|
||||
minute: "numeric",
|
||||
timeZoneName: "short",
|
||||
}).format(new Date(props.updatedAt))}
|
||||
title={intlFormat(
|
||||
new Date(props.updatedAt),
|
||||
{
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "numeric",
|
||||
minute: "numeric",
|
||||
timeZoneName: "short",
|
||||
},
|
||||
{
|
||||
locale: "en-US",
|
||||
}
|
||||
)}
|
||||
>
|
||||
<span>Updated {dayjs(props.updatedAt).fromNow()}</span>
|
||||
<span>Updated {formatDistanceToNowStrict(new Date(props.updatedAt), { addSuffix: true })}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user