about summary refs log tree commit diff
path: root/src/lib/strings/time.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-05-02 23:29:16 -0500
committerGitHub <noreply@github.com>2023-05-02 23:29:16 -0500
commit2eb0d8c095b70b7ec39b7a1acbd126457dea9322 (patch)
tree0716126d7b599b6093708f70f1a47b9eb5c9e0c6 /src/lib/strings/time.ts
parent6f1c4ec9a9b5b7d0b4b67f3bc7c3af6810da5001 (diff)
downloadvoidsky-2eb0d8c095b70b7ec39b7a1acbd126457dea9322.tar.zst
[APP-611] Add nice date to expanded post view (#567)
* Add nice date to expanded post view

* Fix styles
Diffstat (limited to 'src/lib/strings/time.ts')
-rw-r--r--src/lib/strings/time.ts12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/strings/time.ts b/src/lib/strings/time.ts
index 8357d3c31..6cd70498e 100644
--- a/src/lib/strings/time.ts
+++ b/src/lib/strings/time.ts
@@ -27,3 +27,15 @@ export function ago(date: number | string | Date): string {
     return new Date(ts).toLocaleDateString()
   }
 }
+
+export function niceDate(date: number | string | Date) {
+  const d = new Date(date)
+  return `${d.toLocaleDateString('en-us', {
+    year: 'numeric',
+    month: 'short',
+    day: 'numeric',
+  })} at ${d.toLocaleTimeString(undefined, {
+    hour: 'numeric',
+    minute: '2-digit',
+  })}`
+}