1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-27 11:38:28 -04:00

remove unnecessary dayjs plugins (prefer native Intl.DateTimeFormat)

This commit is contained in:
Jake Jarvis 2021-11-30 13:56:41 -05:00
parent 5f3b9b7a04
commit a3c2bbcab0
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39

View File

@ -3,9 +3,6 @@ import { useState, useEffect } from "preact/hooks";
import fetch from "unfetch"; import fetch from "unfetch";
import { parse as parseEmoji } from "imagemoji"; import { parse as parseEmoji } from "imagemoji";
import dayjs from "dayjs"; import dayjs from "dayjs";
import dayjsAdvancedFormat from "dayjs/plugin/advancedFormat.js";
import dayjsLocalizedFormat from "dayjs/plugin/localizedFormat.js";
import dayjsTimezone from "dayjs/plugin/timezone.js";
import dayjsRelativeTime from "dayjs/plugin/relativeTime.js"; import dayjsRelativeTime from "dayjs/plugin/relativeTime.js";
// shared react components: // shared react components:
@ -91,7 +88,17 @@ const RepositoryCard = (repo) => (
</div> </div>
)} )}
<div class="repo-meta-item" title={dayjs(repo.updatedAt).format("lll z")}> <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(repo.updatedAt))}
>
<span>Updated {dayjs(repo.updatedAt).fromNow()}</span> <span>Updated {dayjs(repo.updatedAt).fromNow()}</span>
</div> </div>
</div> </div>
@ -101,13 +108,7 @@ const RepositoryCard = (repo) => (
// detect if these cards are wanted on this page (only /projects) // detect if these cards are wanted on this page (only /projects)
if (typeof window !== "undefined" && document.querySelector("div#github-cards")) { if (typeof window !== "undefined" && document.querySelector("div#github-cards")) {
// dayjs plugins: https://day.js.org/docs/en/plugin/loading-into-nodejs // dayjs plugins: https://day.js.org/docs/en/plugin/loading-into-nodejs
dayjs.extend(dayjsAdvancedFormat);
dayjs.extend(dayjsLocalizedFormat);
dayjs.extend(dayjsTimezone);
dayjs.extend(dayjsRelativeTime); dayjs.extend(dayjsRelativeTime);
// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
dayjs.tz.setDefault("America/New_York");
render(<RepositoryGrid />, document.querySelector("div#github-cards")); render(<RepositoryGrid />, document.querySelector("div#github-cards"));
} }