diff options
author | Mary <148872143+mary-ext@users.noreply.github.com> | 2024-05-30 01:50:13 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-29 19:50:13 +0100 |
commit | 4d39ef2e19632eddc1a31a5b41078f6e40b92fbc (patch) | |
tree | e7e783d29e05a5ed30a552f08e6dba30ad89aa78 /src/view/com/util/numeric | |
parent | 65ad16e394d0525d68e6fc8cd9508de4675c88d5 (diff) | |
download | voidsky-4d39ef2e19632eddc1a31a5b41078f6e40b92fbc.tar.zst |
fix: don't round up count, truncate (#4261)
Diffstat (limited to 'src/view/com/util/numeric')
-rw-r--r-- | src/view/com/util/numeric/format.ts | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/view/com/util/numeric/format.ts b/src/view/com/util/numeric/format.ts index 7aa5a4f4d..71d8d73e0 100644 --- a/src/view/com/util/numeric/format.ts +++ b/src/view/com/util/numeric/format.ts @@ -2,6 +2,10 @@ export const formatCount = (num: number) => Intl.NumberFormat('en-US', { notation: 'compact', maximumFractionDigits: 1, + // `1,953` shouldn't be rounded up to 2k, it should be truncated. + // @ts-expect-error: `roundingMode` doesn't seem to be in the typings yet + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#roundingmode + roundingMode: 'trunc', }).format(num) export function formatCountShortOnly(num: number): string { |