|
3 | 3 | import React, { Fragment, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'; |
4 | 4 | import type { ThemeTokens } from './theme'; |
5 | 5 | import type { Container, Image, Severity, Stack, Tab, TrivyFinding, TrivyResult, Update, DoctorCheck, DoctorFix, HistoryPoint, VulnHistory, Runtime, DiskUsage, DiskUsageRow } from './types'; |
6 | | -import { Icon, Bar, Sparkline, iconBtn, pillBtn } from './components'; |
| 6 | +import { Icon, Bar, Sparkline, iconBtn, pillBtn, fmtCreated } from './components'; |
7 | 7 | import { api } from './api'; |
8 | 8 | import { withToast } from './toast'; |
9 | 9 |
|
@@ -1243,23 +1243,6 @@ function prettyCmd(s: string): string { |
1243 | 1243 |
|
1244 | 1244 | // Best-effort relative "n ago" without pulling a date library. Returns |
1245 | 1245 | // "—" for missing / un-parseable timestamps so the column degrades. |
1246 | | -function ago(iso: string): string { |
1247 | | - if (!iso) return '—'; |
1248 | | - const ms = Date.parse(iso); |
1249 | | - if (Number.isNaN(ms)) return '—'; |
1250 | | - const sec = Math.max(0, Math.floor((Date.now() - ms) / 1000)); |
1251 | | - if (sec < 60) return `${sec}s ago`; |
1252 | | - const min = Math.floor(sec / 60); |
1253 | | - if (min < 60) return `${min}m ago`; |
1254 | | - const hr = Math.floor(min / 60); |
1255 | | - if (hr < 48) return `${hr}h ago`; |
1256 | | - const day = Math.floor(hr / 24); |
1257 | | - if (day < 30) return `${day}d ago`; |
1258 | | - const mo = Math.floor(day / 30); |
1259 | | - if (mo < 24) return `${mo}mo ago`; |
1260 | | - return `${Math.floor(day / 365)}y ago`; |
1261 | | -} |
1262 | | - |
1263 | 1246 | export function ImageInspectModal({ t, reference, onClose }: { |
1264 | 1247 | t: ThemeTokens; reference: string; onClose: () => void; |
1265 | 1248 | }) { |
@@ -1354,7 +1337,7 @@ export function ImageInspectModal({ t, reference, onClose }: { |
1354 | 1337 | )} |
1355 | 1338 | </div> |
1356 | 1339 | <div style={{ textAlign: 'right' }}> |
1357 | | - <div style={{ fontFamily: t.mono, fontSize: 10, color: t.fg3, whiteSpace: 'nowrap' }}>{ago(l.created)}</div> |
| 1340 | + <div style={{ fontFamily: t.mono, fontSize: 10, color: t.fg3, whiteSpace: 'nowrap' }}>{fmtCreated(l.created)}</div> |
1358 | 1341 | {l.emptyLayer && ( |
1359 | 1342 | <div style={{ fontFamily: t.mono, fontSize: 9, color: t.fg3, marginTop: 2, letterSpacing: '0.04em', textTransform: 'uppercase' }}>empty</div> |
1360 | 1343 | )} |
|
0 commit comments