| 120 | export const formatCurrency = formatPrice; |
| 121 | |
| 122 | export function formatNumber(num: number): string { |
| 123 | // If number is small (likely already in millions from Finnhub), multiply by 1M to get actual value |
| 124 | // Typical mega-cap is > 100B. 100B in millions is 100,000. |
| 125 | // If we assume typical market cap input IS millions: |
| 126 | const value = num * 1000000; |
| 127 | |
| 128 | if (value >= 1e12) return (value / 1e12).toFixed(2) + 'T'; |
| 129 | if (value >= 1e9) return (value / 1e9).toFixed(2) + 'B'; |
| 130 | if (value >= 1e6) return (value / 1e6).toFixed(2) + 'M'; |
| 131 | if (value >= 1e3) return (value / 1e3).toFixed(2) + 'K'; |
| 132 | return value.toString(); |
| 133 | } |
| 134 | |
| 135 | export const formatDateToday = new Date().toLocaleDateString('en-US', { |
| 136 | weekday: 'long', |