From 355e22b669aeac331398b8fbd19dca196586823c Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:18:43 +0330 Subject: [PATCH] Import source: vault/lib/expiry-format Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- vault/lib/expiry-format.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 vault/lib/expiry-format.ts diff --git a/vault/lib/expiry-format.ts b/vault/lib/expiry-format.ts new file mode 100644 index 0000000..ee5f290 --- /dev/null +++ b/vault/lib/expiry-format.ts @@ -0,0 +1,13 @@ +export function formatExpiry(expiresAt: string | null | undefined): string | null { + if (!expiresAt) return null; + const ms = new Date(expiresAt).getTime() - Date.now(); + if (ms <= 0) return "Expired"; + const totalMins = Math.floor(ms / 60000); + if (totalMins < 60) return `Expires in ${totalMins}m`; + const hrs = Math.floor(totalMins / 60); + const mins = totalMins % 60; + if (hrs < 24) return mins > 0 ? `Expires in ${hrs}h ${mins}m` : `Expires in ${hrs}h`; + const days = Math.floor(hrs / 24); + const remHrs = hrs % 24; + return remHrs > 0 ? `Expires in ${days}d ${remHrs}h` : `Expires in ${days}d`; +}