From 243b22e4f882a3c784c8c4103d75cd62598bdaaf Mon Sep 17 00:00:00 2001 From: blu Date: Sun, 27 Sep 2026 03:32:48 +0200 Subject: [PATCH] Use timeAgo from @vrcnext/plugin-api Co-Authored-By: Claude Fable 5.1 --- src/history.ts | 13 ------------- src/notify.ts | 4 +++- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/history.ts b/src/history.ts index 2a48834..8eb672d 100644 --- a/src/history.ts +++ b/src/history.ts @@ -67,16 +67,3 @@ export function rejoinIn( const last = earlier[0]; return { seenHere: last !== undefined, lastAt: last?.timestamp }; } - -/** `3 minutes ago`, `2 hours ago`, `5 days ago`. */ -export function timeAgo(iso: string, now = Date.now()): string { - const ms = now - Date.parse(iso); - if (!Number.isFinite(ms) || ms < 0) return 'just now'; - const minutes = Math.floor(ms / 60_000); - if (minutes < 1) return 'just now'; - if (minutes < 60) return `${String(minutes)} minute${minutes === 1 ? '' : 's'} ago`; - const hours = Math.floor(minutes / 60); - if (hours < 48) return `${String(hours)} hour${hours === 1 ? '' : 's'} ago`; - const days = Math.floor(hours / 24); - return `${String(days)} day${days === 1 ? '' : 's'} ago`; -} diff --git a/src/notify.ts b/src/notify.ts index d7a30d2..1b67f56 100644 --- a/src/notify.ts +++ b/src/notify.ts @@ -13,7 +13,9 @@ import type { PluginContext, SettingsValues } from '@vrcnext/plugin-api'; import type { Facts, Joiner } from './collector.js'; -import { timeAgo, type Rejoin } from './history.js'; +import { timeAgo } from '@vrcnext/plugin-api'; + +import type { Rejoin } from './history.js'; import type { Settings } from './settings.js'; import type { CurrentInstance } from './vrcnext-data.js';