From ac88c6b637e3d4f2b1022abd06f1a052d644deca Mon Sep 17 00:00:00 2001 From: Alex Yaroshuk <34632190+alexyaroshuk@users.noreply.github.com> Date: Fri, 6 Feb 2026 20:19:25 +0800 Subject: feat(app): session last updated time display in command pallete's search (#12376) --- packages/app/src/utils/time.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 packages/app/src/utils/time.ts (limited to 'packages/app/src/utils') diff --git a/packages/app/src/utils/time.ts b/packages/app/src/utils/time.ts new file mode 100644 index 000000000..ac709d86d --- /dev/null +++ b/packages/app/src/utils/time.ts @@ -0,0 +1,14 @@ +export function getRelativeTime(dateString: string): string { + const date = new Date(dateString) + const now = new Date() + const diffMs = now.getTime() - date.getTime() + const diffSeconds = Math.floor(diffMs / 1000) + const diffMinutes = Math.floor(diffSeconds / 60) + const diffHours = Math.floor(diffMinutes / 60) + const diffDays = Math.floor(diffHours / 24) + + if (diffSeconds < 60) return "Just now" + if (diffMinutes < 60) return `${diffMinutes}m ago` + if (diffHours < 24) return `${diffHours}h ago` + return `${diffDays}d ago` +} -- cgit v1.2.3