MCPcopy Create free account
hub / github.com/astercloud/aster / formatRelativeTime

Function formatRelativeTime

studio/src/lib/utils.ts:64–79  ·  view source on GitHub ↗
(dateStr: string)

Source from the content-addressed store, hash-verified

62
63// Format relative time
64export function formatRelativeTime(dateStr: string): string {
65 const date = new Date(dateStr);
66 const now = new Date();
67 const diffMs = now.getTime() - date.getTime();
68
69 if (diffMs < 60000) {
70 return '刚刚';
71 }
72 if (diffMs < 3600000) {
73 return `${Math.floor(diffMs / 60000)} 分钟前`;
74 }
75 if (diffMs < 86400000) {
76 return `${Math.floor(diffMs / 3600000)} 小时前`;
77 }
78 return `${Math.floor(diffMs / 86400000)} 天前`;
79}
80
81// Get status color class
82export function getStatusColor(status: string): string {

Callers 11

SessionsFunction · 0.90
SessionDetailFunction · 0.90
MessageBubbleFunction · 0.90
EvalCardFunction · 0.90
TracesFunction · 0.90
AgentCardFunction · 0.90
BenchmarkCardFunction · 0.90
OverviewFunction · 0.90
ConnectionStatusBarFunction · 0.90
EventRowFunction · 0.90
AgentDetailFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected