mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 07:38:01 +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
5e5a5294c3
commit
a9eb14889e
|
@ -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