feat(app): session last updated time display in command pallete's search (#12376)

This commit is contained in:
Alex Yaroshuk
2026-02-06 20:19:25 +08:00
committed by GitHub
parent d4fcc1b863
commit ac88c6b637
2 changed files with 24 additions and 0 deletions

View File

@@ -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`
}