diff --git a/src/mocks/jobs.json b/src/mocks/jobs.json deleted file mode 100644 index ec61624..0000000 --- a/src/mocks/jobs.json +++ /dev/null @@ -1,5 +0,0 @@ -[ - { "title": "Monitor Real-Time Stock Market Data", "runningTime": "2m 34s", "progress": 65, "startTime": "2026-06-30T20:48:00Z", "eta": "2026-06-30T20:52:00Z" }, - { "title": "Image Generation", "runningTime": "5m 12s", "progress": 30, "startTime": "2026-06-30T20:36:00Z", "eta": "2026-06-30T21:00:00Z" }, - { "title": "Process & Categorize Inbox Emails", "runningTime": "12m 47s", "progress": 88, "startTime": "2026-06-30T20:25:00Z", "eta": "2026-06-30T20:40:00Z" } -] diff --git a/src/mocks/jobs.ts b/src/mocks/jobs.ts new file mode 100644 index 0000000..7a467c8 --- /dev/null +++ b/src/mocks/jobs.ts @@ -0,0 +1,22 @@ +const now = new Date() + +export default [ + { + title: 'Monitor Real-Time Stock Market Data', + progress: 65, + startTime: new Date(now.getTime() - 100000).toISOString(), + eta: new Date(now.getTime() + 100000).toISOString(), + }, + { + title: 'Image Generation', + progress: 30, + startTime: new Date(now.getTime() - 55000).toISOString(), + eta: new Date(now.getTime() + 300000).toISOString(), + }, + { + title: 'Process & Categorize Inbox Emails', + progress: 88, + startTime: new Date(now.getTime() - 30000).toISOString(), + eta: new Date(now.getTime() + 30000).toISOString(), + }, +] diff --git a/src/utils/datetime.ts b/src/utils/datetime.ts index 23a31c6..f8ab4b0 100644 --- a/src/utils/datetime.ts +++ b/src/utils/datetime.ts @@ -1,7 +1,23 @@ export function formatTime(iso: string, options?: Intl.DateTimeFormatOptions): string { return new Date(iso).toLocaleTimeString([], { - hour: "2-digit", - minute: "2-digit", + hour: '2-digit', + minute: '2-digit', ...options, }) } + +export function formatElapsed(startTime: string): string { + const elapsed = Math.max(0, Math.floor((Date.now() - new Date(startTime).getTime()) / 1000)) + const days = Math.floor(elapsed / 86400) + const hours = Math.floor((elapsed % 86400) / 3600) + const minutes = Math.floor((elapsed % 3600) / 60) + const seconds = elapsed % 60 + + const parts: string[] = [] + if (days > 0) parts.push(`${days}d`) + if (hours > 0) parts.push(`${hours}h`) + if (minutes > 0) parts.push(`${minutes}m`) + parts.push(`${seconds}s`) + + return parts.join(' ') +}