MCPcopy Create free account
hub / github.com/AmazingAng/PolyWorld / formatTime

Function formatTime

src/components/AlertManager.tsx:9–17  ·  view source on GitHub ↗
(ts: number, t?: (key: string, vars?: Record<string, string | number>) => string)

Source from the content-addressed store, hash-verified

7import { useI18n } from "@/i18n";
8
9function formatTime(ts: number, t?: (key: string, vars?: Record<string, string | number>) => string) {
10 const diff = Date.now() - ts;
11 const mins = Math.floor(diff / 60000);
12 if (mins < 1) return t ? t("common.justNow") : "just now";
13 if (mins < 60) return t ? t("trade.minAgo", { m: mins }) : `${mins}m ago`;
14 const hours = Math.floor(mins / 60);
15 if (hours < 24) return t ? t("trade.hAgo", { h: hours }) : `${hours}h ago`;
16 return `${Math.floor(hours / 24)}d`;
17}
18
19const CATEGORIES: Category[] = [
20 "Politics", "Crypto", "Sports",

Callers 1

AlertManagerContentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected