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, 04:45 UTC
| 1 | import { toServerClock } from "@t3tools/client-runtime/clock"; |
| 2 | import type { EnvironmentId } from "@t3tools/contracts"; |
| 3 | import { formatDuration } from "@t3tools/shared/orchestrationTimingCopy"; |
| 4 | import { msg } from "gt-react"; |
| 5 | import { m } from "~/i18n/messages"; |
| 6 | |
| 7 | export function formatWorkingTimerNow(startIso: string, environmentId: EnvironmentId): string { |
| 8 | const startedAtMs = Date.parse(startIso); |
| 9 | if (!Number.isFinite(startedAtMs)) { |
| 10 | return m(msg("{seconds}s", { seconds: 0 })); |
| 11 | } |
| 12 | |
| 13 | const elapsedSeconds = Math.max( |
| 14 | 0, |
| 15 | Math.floor((toServerClock(environmentId, Date.now()) - startedAtMs) / 1000), |
| 16 | ); |
| 17 | if (elapsedSeconds < 60) { |
| 18 | return m(msg("{seconds}s", { seconds: elapsedSeconds })); |
| 19 | } |
| 20 | |
| 21 | return formatDuration(elapsedSeconds * 1_000, m); |
| 22 | } |