diff --git a/src/lib/views/messages/RenderKind1.svelte b/src/lib/views/messages/RenderKind1.svelte
index ad78b14..631dc94 100644
--- a/src/lib/views/messages/RenderKind1.svelte
+++ b/src/lib/views/messages/RenderKind1.svelte
@@ -29,6 +29,38 @@ onMount(() => {
});
$: childrenCount = $store?.replies.get(note.id) ? $store.replies.get(note.id)!.size : 0;
+
+function formatTimeAgo(timestamp: number): string {
+ const currentTime = Date.now();
+ const secondsAgo = Math.floor((currentTime - timestamp) / 1000);
+
+ if (secondsAgo < 60) {
+ return `${secondsAgo} seconds ago`;
+ } else if (secondsAgo < 3600) {
+ const minutesAgo = Math.floor(secondsAgo / 60);
+ return `${minutesAgo} minute${minutesAgo === 1 ? '' : 's'} ago`;
+ } else if (secondsAgo < 86400) {
+ const hoursAgo = Math.floor(secondsAgo / 3600);
+ return `${hoursAgo} hour${hoursAgo === 1 ? '' : 's'} ago`;
+ } else if (secondsAgo < 604800) {
+ const daysAgo = Math.floor(secondsAgo / 86400);
+ return `${daysAgo} day${daysAgo === 1 ? '' : 's'} ago`;
+ } else {
+ const formattedDate = new Date(timestamp).toLocaleString('en-US', {
+ weekday: 'short',
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric',
+ hour: '2-digit',
+ minute: '2-digit',
+ hour12: true
+ });
+ return formattedDate;
+ }
+ }
+
+
+
@@ -73,7 +105,7 @@ onMount(() => {
- {new Date(note.created_at * 1000).toLocaleString()}
+ {formatTimeAgo(note.created_at * 1000)}
{#if $viewed.has(note.id)}✓{/if}
diff --git a/src/lib/views/messages/RenderKind1AsThreadHead.svelte b/src/lib/views/messages/RenderKind1AsThreadHead.svelte
index 5d0f0c1..b38e645 100644
--- a/src/lib/views/messages/RenderKind1AsThreadHead.svelte
+++ b/src/lib/views/messages/RenderKind1AsThreadHead.svelte
@@ -13,6 +13,37 @@
let top: HTMLDivElement;
//$: childrenCount = $store?.replies.get(note.id) ? $store.replies.get(note.id)!.size : 0;
+ function formatTimeAgo(timestamp: number): string {
+ const currentTime = Date.now();
+ const secondsAgo = Math.floor((currentTime - timestamp) / 1000);
+
+ if (secondsAgo < 60) {
+ return `${secondsAgo} seconds ago`;
+ } else if (secondsAgo < 3600) {
+ const minutesAgo = Math.floor(secondsAgo / 60);
+ return `${minutesAgo} minute${minutesAgo === 1 ? '' : 's'} ago`;
+ } else if (secondsAgo < 86400) {
+ const hoursAgo = Math.floor(secondsAgo / 3600);
+ return `${hoursAgo} hour${hoursAgo === 1 ? '' : 's'} ago`;
+ } else if (secondsAgo < 604800) {
+ const daysAgo = Math.floor(secondsAgo / 86400);
+ return `${daysAgo} day${daysAgo === 1 ? '' : 's'} ago`;
+ } else {
+ const formattedDate = new Date(timestamp).toLocaleString('en-US', {
+ weekday: 'short',
+ year: 'numeric',
+ month: 'short',
+ day: 'numeric',
+ hour: '2-digit',
+ minute: '2-digit',
+ hour12: true
+ });
+ return formattedDate;
+ }
+ }
+
+
+
@@ -31,7 +62,9 @@
- {new Date(note.created_at * 1000).toLocaleString()}{#if $viewed.has(note.id)}✓{/if}
+ {formatTimeAgo(note.created_at * 1000)}
+
+ {#if $viewed.has(note.id)}✓{/if}