caelum0x d56639a594
Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

41 lines
1.6 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Formatting helpers for the creator dashboard. Reuses the shared Me-tab
* formatters (count / USD / duration) so metrics read identically across the
* app, and adds a couple of analytics-only helpers. Dependency-free.
*/
export { formatCount, formatDuration, formatUsd } from "@/components/me/format";
/**
* Format an ISO `YYYY-MM-DD` day as a compact axis label, e.g. "Aug 10".
* Falls back to the raw string when it can't be parsed.
*/
export function formatDay(iso: string): string {
if (!iso) return "";
// Parse as a local date from the Y-M-D parts to avoid UTC off-by-one drift.
const match = /^(\d{4})-(\d{2})-(\d{2})/.exec(iso);
if (!match) return iso;
const [, year, month, day] = match;
const date = new Date(Number(year), Number(month) - 1, Number(day));
if (Number.isNaN(date.getTime())) return iso;
return date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
}
/**
* Percentage of `part` out of `total`, clamped to 0–100. Returns 0 when the
* total is zero or non-finite (used to size proportional bars safely).
*/
export function toPercent(part: number, total: number): number {
if (!Number.isFinite(part) || !Number.isFinite(total) || total <= 0) return 0;
const pct = (part / total) * 100;
if (pct < 0) return 0;
if (pct > 100) return 100;
return pct;
}
/** Compact count label for breakdown rows, e.g. `1` -> "1 job", `3` -> "3 jobs". */
export function formatJobs(count: number): string {
const n = Number.isFinite(count) ? Math.round(count) : 0;
return `${n.toLocaleString("en-US")} ${n === 1 ? "job" : "jobs"}`;
}