about summary refs log tree commit diff
path: root/bskyembed/src/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'bskyembed/src/utils.ts')
-rw-r--r--bskyembed/src/utils.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/bskyembed/src/utils.ts b/bskyembed/src/utils.ts
new file mode 100644
index 000000000..3408fcd97
--- /dev/null
+++ b/bskyembed/src/utils.ts
@@ -0,0 +1,15 @@
+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',
+  })}`
+}
+
+export function getRkey({uri}: {uri: string}): string {
+  return uri.split('/').pop() as string
+}