mirror of
https://github.com/flarum/framework.git
synced 2024-11-26 10:14:16 +08:00
Fix number abbreviation when the number is n-thousand (#2261)
This commit fixes the method `abbreviateNumber` so that it behaves as stated in the JSDoc. Previously, an input of `1234` would have produced `1K`. With this change, the output will be `1.2K`.
This commit is contained in:
parent
37ae209ba6
commit
e0bc3e9ce4
|
@ -10,7 +10,7 @@ export default function abbreviateNumber(number: number): string {
|
|||
if (number >= 1000000) {
|
||||
return Math.floor(number / 1000000) + app.translator.trans('core.lib.number_suffix.mega_text');
|
||||
} else if (number >= 1000) {
|
||||
return Math.floor(number / 1000) + app.translator.trans('core.lib.number_suffix.kilo_text');
|
||||
return (number / 1000).toFixed(1) + app.translator.trans('core.lib.number_suffix.kilo_text');
|
||||
} else {
|
||||
return number.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user