mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-05-19 15:08:48 +02:00
All checks were successful
Deploy to VPS / deploy (push) Successful in 17s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
19 lines
812 B
TypeScript
19 lines
812 B
TypeScript
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 })}`;
|
|
}
|
|
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 new Date(dateStr).toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
|
|
}
|