MCPcopy Create free account
hub / github.com/allocnode/oh-my-sage / formatTime

Function formatTime

src/components/SessionPanel.tsx:32–47  ·  view source on GitHub ↗
(isoString: string)

Source from the content-addressed store, hash-verified

30}
31
32function formatTime(isoString: string): string {
33 const date = new Date(isoString);
34 const now = new Date();
35 const diff = now.getTime() - date.getTime();
36 if (diff < 24 * 60 * 60 * 1000 && date.getDate() === now.getDate()) {
37 return date.toLocaleTimeString('zh-CN', {hour: '2-digit', minute: '2-digit'});
38 }
39 const yesterday = new Date(now);
40 yesterday.setDate(yesterday.getDate() - 1);
41 if (date.getDate() === yesterday.getDate() &&
42 date.getMonth() === yesterday.getMonth() &&
43 date.getFullYear() === yesterday.getFullYear()) {
44 return '昨天';
45 }
46 return date.toLocaleDateString('zh-CN', {month: 'numeric', day: 'numeric'});
47}
48
49export default function SessionPanel({
50 sessions, activeSessionId, loading = false,

Callers 1

SessionPanelFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected