diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx b/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx
index f94fce28..ce5a589e 100644
--- a/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx
+++ b/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx
@@ -17,6 +17,7 @@ import { BlueskyLogin } from "app/login/LoginForm";
import { usePathname } from "next/navigation";
import { QuoteContent } from "../Quotes";
import { timeAgo } from "src/utils/timeAgo";
+import { useLocalizedDate } from "src/hooks/useLocalizedDate";
export type Comment = {
record: Json;
@@ -250,25 +251,22 @@ const Replies = (props: {
};
const DatePopover = (props: { date: string }) => {
- let [t, full] = useMemo(() => {
- return [
- timeAgo(props.date),
- new Date(props.date).toLocaleTimeString(undefined, {
- year: "numeric",
- month: "2-digit",
- day: "2-digit",
- hour: "2-digit",
- minute: "2-digit",
- }),
- ];
- }, [props.date]);
+ const timeAgoText = useMemo(() => timeAgo(props.date), [props.date]);
+ const fullDate = useLocalizedDate(props.date, {
+ year: "numeric",
+ month: "2-digit",
+ day: "2-digit",
+ hour: "2-digit",
+ minute: "2-digit",
+ });
+
return (
{t}
+ {timeAgoText}
}
>
- {full}
+ {fullDate}
);
};
diff --git a/app/lish/[did]/[publication]/[rkey]/PublishBskyPostBlock.tsx b/app/lish/[did]/[publication]/[rkey]/PublishBskyPostBlock.tsx
index 807e902d..75855d56 100644
--- a/app/lish/[did]/[publication]/[rkey]/PublishBskyPostBlock.tsx
+++ b/app/lish/[did]/[publication]/[rkey]/PublishBskyPostBlock.tsx
@@ -10,6 +10,7 @@ import { Separator } from "components/Layout";
import { useInitialPageLoad } from "components/InitialPageLoadProvider";
import { BlueskyTiny } from "components/Icons/BlueskyTiny";
import { CommentTiny } from "components/Icons/CommentTiny";
+import { useLocalizedDate } from "src/hooks/useLocalizedDate";
import {
BlueskyEmbed,
PostNotAvailable,
@@ -121,19 +122,16 @@ export const PubBlueskyPostBlock = (props: {
const ClientDate = (props: { date?: string }) => {
let pageLoaded = useInitialPageLoad();
- if (!pageLoaded) return null;
+ const formattedDate = useLocalizedDate(props.date || new Date().toISOString(), {
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ hour: "numeric",
+ minute: "numeric",
+ hour12: true,
+ });
- let datetimeFormatted = new Date(props.date ? props.date : "").toLocaleString(
- "en-US",
- {
- month: "short",
- day: "numeric",
- year: "numeric",
- hour: "numeric",
- minute: "numeric",
- hour12: true,
- },
- );
+ if (!pageLoaded) return null;
- return
{datetimeFormatted}
;
+ return {formattedDate}
;
};
diff --git a/app/lish/[did]/[publication]/dashboard/PublicationSubscribers.tsx b/app/lish/[did]/[publication]/dashboard/PublicationSubscribers.tsx
index 024e67e1..b3053fa6 100644
--- a/app/lish/[did]/[publication]/dashboard/PublicationSubscribers.tsx
+++ b/app/lish/[did]/[publication]/dashboard/PublicationSubscribers.tsx
@@ -8,6 +8,7 @@ import { Menu, MenuItem, Separator } from "components/Layout";
import { MoreOptionsVerticalTiny } from "components/Icons/MoreOptionsVerticalTiny";
import { Checkbox } from "components/Checkbox";
import { useEffect, useState } from "react";
+import { useLocalizedDate } from "src/hooks/useLocalizedDate";
type subscriber = { email: string | undefined; did: string | undefined };
@@ -198,13 +199,7 @@ const SubscriberListItem = (props: {
@{props.handle}
)}
-
- {new Date(props.createdAt).toLocaleString(undefined, {
- year: "2-digit",
- month: "2-digit",
- day: "2-digit",
- })}
-
+
>
//
@@ -235,3 +230,16 @@ const SubscriberOptions = (props: {
);
};
+
+function SubscriberDate(props: { createdAt: string }) {
+ const formattedDate = useLocalizedDate(props.createdAt, {
+ year: "2-digit",
+ month: "2-digit",
+ day: "2-digit",
+ });
+ return (
+
+ {formattedDate}
+
+ );
+}
diff --git a/components/Blocks/BlueskyPostBlock/index.tsx b/components/Blocks/BlueskyPostBlock/index.tsx
index baeb04e9..d9169daa 100644
--- a/components/Blocks/BlueskyPostBlock/index.tsx
+++ b/components/Blocks/BlueskyPostBlock/index.tsx
@@ -13,6 +13,7 @@ import { Separator } from "components/Layout";
import { useInitialPageLoad } from "components/InitialPageLoadProvider";
import { BlueskyTiny } from "components/Icons/BlueskyTiny";
import { CommentTiny } from "components/Icons/CommentTiny";
+import { useLocalizedDate } from "src/hooks/useLocalizedDate";
export const BlueskyPostBlock = (props: BlockProps & { preview?: boolean }) => {
let { permissions } = useEntitySetContext();
@@ -29,8 +30,6 @@ export const BlueskyPostBlock = (props: BlockProps & { preview?: boolean }) => {
} else input?.blur();
}, [isSelected, props.entityID, props.preview]);
- let initialPageLoad = useInitialPageLoad();
-
switch (true) {
case !post:
if (!permissions.write) return null;
@@ -82,17 +81,6 @@ export const BlueskyPostBlock = (props: BlockProps & { preview?: boolean }) => {
let postId = post.post.uri.split("/")[4];
let url = `https://bsky.app/profile/${post.post.author.handle}/post/${postId}`;
- let datetimeFormatted = initialPageLoad
- ? new Date(timestamp ? timestamp : "").toLocaleString("en-US", {
- month: "short",
- day: "numeric",
- year: "numeric",
- hour: "numeric",
- minute: "numeric",
- hour12: true,
- })
- : "";
-
return (
{
>
)}
-
{datetimeFormatted}
+ {timestamp &&
}
{post.post.replyCount && post.post.replyCount > 0 && (
<>
@@ -166,3 +154,15 @@ export const BlueskyPostBlock = (props: BlockProps & { preview?: boolean }) => {
);
}
};
+
+function PostDate(props: { timestamp: string }) {
+ const formattedDate = useLocalizedDate(props.timestamp, {
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ hour: "numeric",
+ minute: "numeric",
+ hour12: true,
+ });
+ return
{formattedDate}
;
+}