Shortened the table's "Values" with k, m and bn suffixes

This commit is contained in:
bwilliams committed 2026-10-21 15:14:57 +01:00
1 parent 3bb2711276
commit 7543d85de4
3 files changed
+40 -2

No files matched your search

+16
View File
@@ -22,6 +22,14 @@ const moneyFormat = new Intl.NumberFormat('en-GB', {
maximumFractionDigits: 0,
});
// en-GB's compact suffixes are k, m and bn; amounts under £1,000 are left
// whole.
const shortMoneyFormat = new Intl.NumberFormat('en-GB', {
style: 'currency',
currency: 'GBP',
notation: 'compact',
});
const countFormat = new Intl.NumberFormat('en-GB');
/** Treats null and Go's zero time.Time as "no date". */
@@ -48,6 +56,14 @@ export function formatMoney(value: number): string {
return value > 0 ? moneyFormat.format(value) : '—';
}
/**
* An amount in pounds shortened with a suffix, e.g. "£250k", "£1.5m" or
* "£36bn", or a dash for none. Amounts under £1,000 are shown whole.
*/
export function formatMoneyShort(value: number): string {
return value > 0 ? shortMoneyFormat.format(value) : '—';
}
/** A count for display, e.g. "4,854". */
export function formatCount(value: number): string {
return countFormat.format(value);