more otel
Build and Publish / Metadata (push) Successful in 2s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 58s

This commit is contained in:
mats committed 2026-09-18 20:51:37 +00:00
1 parent 9620e3bfa6
commit 21f04d696b
88 files changed
+23419 -192

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
export function formatDuration(nano: number): string {
if (nano >= 3600000000000) { // 1 hour in nanoseconds
return `${(nano / 3600000000000).toFixed(1)}h`;
} else if (nano >= 60000000000) { // 1 minute
return `${(nano / 60000000000).toFixed(1)}m`;
} else if (nano >= 1000000000) { // 1 second
return `${(nano / 1000000000).toFixed(1)}s`;
} else if (nano >= 1000000) { // 1 millisecond
return `${(nano / 1000000).toFixed(1)}ms`;
} else if (nano >= 1000) { // 1 microsecond
return `${(nano / 1000).toFixed(1)}μs`;
} else {
return `${nano.toFixed(1)}ns`;
}
}
/** "just now", "2m ago", "3h ago", "5d ago" */
export function formatRelativeTime(msEpoch: number): string {
const seconds = Math.max(0, (Date.now() - msEpoch) / 1000);
if (seconds < 60) return "just now";
if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`;
if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`;
return `${Math.floor(seconds / 86400)}d ago`;
}