The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | import { ansiFg } from "../Util/Terminal.ts"; |
| 2 | import { theme } from "../Util/Theme.ts"; |
| 3 | |
| 4 | /** `450ms` under a second, `1.2s` at or above — shared by every renderer. */ |
| 5 | export const formatElapsed = (ms: number): string => |
| 6 | ms < 1000 ? `${Math.max(0, Math.round(ms))}ms` : `${(ms / 1000).toFixed(1)}s`; |
| 7 | |
| 8 | export const TAIL_COLORS = [ |
| 9 | ansiFg(theme.color.accent), |
| 10 | ansiFg(theme.color.info), |
| 11 | ansiFg(theme.color.danger), |
| 12 | ansiFg(theme.color.warning), |
| 13 | ansiFg(theme.color.accentBright), |
| 14 | ansiFg(theme.color.muted), |
| 15 | ansiFg(theme.color.accentMuted), |
| 16 | ansiFg(theme.color.success), |
| 17 | ]; |
| 18 | |
| 19 | export const formatLocalTimestamp = (date: Date): string => { |
| 20 | const y = date.getFullYear(); |
| 21 | const mo = String(date.getMonth() + 1).padStart(2, "0"); |
| 22 | const d = String(date.getDate()).padStart(2, "0"); |
| 23 | const h = String(date.getHours()).padStart(2, "0"); |
| 24 | const mi = String(date.getMinutes()).padStart(2, "0"); |
| 25 | const s = String(date.getSeconds()).padStart(2, "0"); |
| 26 | const ms = String(date.getMilliseconds()).padStart(3, "0"); |
| 27 | const tz = |
| 28 | new Intl.DateTimeFormat("en-US", { timeZoneName: "short" }) |
| 29 | .formatToParts(date) |
| 30 | .find((part) => part.type === "timeZoneName")?.value ?? ""; |
| 31 | return `${y}-${mo}-${d} ${h}:${mi}:${s}.${ms} ${tz}`; |
| 32 | }; |