Spaces:
Running
Running
Claude Opus 5.5 (1M context)
Stop paying twice, measure every run, and make the picture, voice and props hold up
13354e2 Download frontend/src/lib/format.ts from userIdc2024/creative-brain-os: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/spaces/userIdc2024/creative-brain-os/resolve/main/frontend/src/lib/format.ts
- Command line
-
hf download hf://spaces/userIdc2024/creative-brain-os/frontend/src/lib/format.ts
-
curl -L -o format.ts https://huggingface.co/spaces/userIdc2024/creative-brain-os/resolve/main/frontend/src/lib/format.ts
1.28 kB
| export function formatStage(stage: string): string { | |
| return stage | |
| .split("_") | |
| .map((w) => w.charAt(0).toUpperCase() + w.slice(1)) | |
| .join(" "); | |
| } | |
| export function timeAgo(iso: string): string { | |
| const diffMs = Date.now() - new Date(iso).getTime(); | |
| const sec = Math.round(diffMs / 1000); | |
| if (sec < 5) return "just now"; | |
| if (sec < 60) return `${sec}s ago`; | |
| const min = Math.round(sec / 60); | |
| if (min < 60) return `${min}m ago`; | |
| const hr = Math.round(min / 60); | |
| if (hr < 24) return `${hr}h ago`; | |
| const day = Math.round(hr / 24); | |
| return `${day}d ago`; | |
| } | |
| /** The calendar date a row belongs to — "12 Aug", or "12 Aug 2025" once it is | |
| * not this year. `timeAgo` answers "how long", which is not the same question as | |
| * "which day", and a list filtered by date needs the second one. */ | |
| export function formatDate(iso: string): string { | |
| const d = new Date(iso); | |
| if (Number.isNaN(d.getTime())) return ""; | |
| const sameYear = d.getFullYear() === new Date().getFullYear(); | |
| return d.toLocaleDateString(undefined, { | |
| day: "numeric", | |
| month: "short", | |
| ...(sameYear ? {} : { year: "numeric" }), | |
| }); | |
| } | |
| /** "≈$1.23 est." — a recorded media estimate, never an invoice. */ | |
| export const formatUsd = (usd: number) => `≈$${usd.toFixed(2)}`; | |