mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-07-17 10:28:47 +02:00
src/lib/dates.ts is the single source for month names and date formatting; the three per-page month arrays are gone (with an off-by-one guard — the shared array is 1-indexed). formatDate and the Analytics chart tooltips now speak es-CR, Analytics headings are Spanish, and the cycle selector says 'Todo el período' (UX-19, FE-17, UX-07). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
24 lines
935 B
TypeScript
24 lines
935 B
TypeScript
import { formatShortDate } from './dates';
|
|
|
|
export function formatAmount(amount: number, currency: string) {
|
|
const abs = Math.abs(amount);
|
|
if (currency === 'BTC') return abs.toFixed(8);
|
|
if (currency === 'XMR') return abs.toFixed(4);
|
|
if (currency === 'USD') {
|
|
return `$${abs.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
}
|
|
if (currency === 'EUR') {
|
|
return `€${abs.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
}
|
|
return `₡${abs.toLocaleString('es-CR', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
}
|
|
|
|
export function formatLocalDatetime(d: Date): string {
|
|
const pad = (n: number) => n.toString().padStart(2, '0');
|
|
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
}
|
|
|
|
export function formatDate(dateStr: string) {
|
|
return formatShortDate(dateStr);
|
|
}
|