Skip to content

Commit

Permalink
Revert " SOLVED: Datestamp is hard for humans to reason about (#7)" (#8)
Browse files Browse the repository at this point in the history
This reverts commit 314d056.
  • Loading branch information
gsovereignty authored May 20, 2024
1 parent 314d056 commit e07ee11
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 81 deletions.
28 changes: 14 additions & 14 deletions src/lib/components/ChatLayout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,20 @@
</div>
</div>

<div class="flex flex-col h-full">
<!-- CONTENT -->
<div class="flex-1 relative overflow-hidden">
<div class="h-full bg-white dark:bg-slate-900 overflow-x-hidden overflow-y-scroll no-scrollbar z-10">
<slot />
</div>
</div>
<!-- MESSAGE BOX -->
<div class="flex flex-row">
<div class="relative w-full bg-white dark:bg-slate-900 z-20">
<slot name="input" />
</div>
</div>
</div>
<div class="flex-1">
<div class="flex-col h-full">
<!-- CONTENT-->
<div
class="h-full relative z-10 bg-white dark:bg-slate-900 overflow-x-hidden overflow-y-scroll no-scrollbar"
>
<slot />
</div>
<!-- MESSAGE BOX-->
<div class="relative w-full">
<div class="z-20 flex absolute inset-x-0 bottom-0 h-36"><slot name="input" /></div>
</div>
</div>
</div>
<div class="hidden flex-1 lg:block">
<div class="h-full flex-col">
<div class="h-full flex-1 bg-slate-100 dark:bg-cyan-800 overflow-y-scroll">
Expand Down
34 changes: 1 addition & 33 deletions src/lib/views/messages/RenderKind1.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,6 @@ 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;
}
}
</script>

<div bind:this={top} class="w-full pt-2 pl-2 pr-2">
Expand Down Expand Up @@ -105,7 +73,7 @@ function formatTimeAgo(timestamp: number): string {
<h6 class="text-gray-500 text-xs font-normal leading-4 py-1"></h6>
<div class="justify-end items-center inline-flex">
<h6 class="text-gray-500 text-xs font-normal leading-4 py-1">
{formatTimeAgo(note.created_at * 1000)}
{new Date(note.created_at * 1000).toLocaleString()}
{#if $viewed.has(note.id)}✓{/if}
</h6>
</div>
Expand Down
35 changes: 1 addition & 34 deletions src/lib/views/messages/RenderKind1AsThreadHead.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,6 @@
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;
}
}
</script>

<div class="w-full pt-2 pl-2 pr-2">
Expand All @@ -62,9 +31,7 @@
</div>
<div bind:this={top} class="justify-end items-center inline-flex">
<h6 class="text-gray-500 text-xs font-normal leading-4 py-1">
{formatTimeAgo(note.created_at * 1000)}

{#if $viewed.has(note.id)}✓{/if}
{new Date(note.created_at * 1000).toLocaleString()}{#if $viewed.has(note.id)}✓{/if}
</h6>
</div>
</div>
Expand Down

0 comments on commit e07ee11

Please sign in to comment.