Use timeAgo from @vrcnext/plugin-api

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
bluandClaude Fable 5.1 committed 2026-09-27 03:32:48 +02:00
1 parent 49da02af90
commit 243b22e4f8
2 files changed
+3 -14

No files matched your search

-13
View File
@@ -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`;
}
+3 -1
View File
@@ -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';