21 lines
960 B
TypeScript
21 lines
960 B
TypeScript
// Pure display formatters for the client panes (v0.9.0) — no game logic, unit-testable in node.
|
|
|
|
const CURRENCY = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'EUR' });
|
|
|
|
export function formatCash(value: number): string {
|
|
return CURRENCY.format(value);
|
|
}
|
|
|
|
// "6300 / 6300 L" — current value rounded (live fuel is fractional mid-flight).
|
|
export function formatFuel(fuel: number, maxFuel: number): string {
|
|
return `${Math.round(fuel)} / ${maxFuel} L`;
|
|
}
|
|
|
|
// The sim clock is epoch ms (seeded from real time) — shown as a UTC wall-clock with
|
|
// seconds so the display is deterministic regardless of the viewer's timezone.
|
|
export function formatSimClock(clockMs: number): string {
|
|
const d = new Date(clockMs);
|
|
const pad = (n: number) => String(n).padStart(2, '0');
|
|
return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())} UTC`;
|
|
}
|