diff options
author | Simon Rettberg | 2022-11-15 17:20:20 +0100 |
---|---|---|
committer | Simon Rettberg | 2022-11-15 17:20:20 +0100 |
commit | 74f1db5c2670f7247abc8ea8bbb9b171c9e88f6a (patch) | |
tree | d17382ebfcebaa38df34adac61d37eff45913d10 /inc/util.inc.php | |
parent | [statistics] Fix potential invalid array access (diff) | |
download | slx-admin-74f1db5c2670f7247abc8ea8bbb9b171c9e88f6a.tar.gz slx-admin-74f1db5c2670f7247abc8ea8bbb9b171c9e88f6a.tar.xz slx-admin-74f1db5c2670f7247abc8ea8bbb9b171c9e88f6a.zip |
[inc/Dictionary] Add locale-aware number formatting method
Diffstat (limited to 'inc/util.inc.php')
-rw-r--r-- | inc/util.inc.php | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/inc/util.inc.php b/inc/util.inc.php index 06f60007..8bd48dd3 100644 --- a/inc/util.inc.php +++ b/inc/util.inc.php @@ -87,13 +87,13 @@ class Util } /** - * Convert given number to human readable file size string. + * Convert given number to human-readable file size string. * Will append Bytes, KiB, etc. depending on magnitude of number. * * @param float|int $bytes numeric value of the filesize to make readable * @param int $decimals number of decimals to show, -1 for automatic * @param int $shift how many units to skip, i.e. if you pass in KiB or MiB - * @return string human readable string representing the given file size + * @return string human-readable string representing the given file size */ public static function readableFileSize(float $bytes, int $decimals = -1, int $shift = 0): string { @@ -113,7 +113,7 @@ class Util $decimals = 2 - floor(strlen((int)$bytes) - 1); } } - return sprintf("%.{$decimals}f", $bytes) . "\xe2\x80\x89" . ($sz[$factor + $shift] ?? '#>PiB#'); + return Dictionary::number($bytes, $decimals) . "\xe2\x80\x89" . ($sz[$factor + $shift] ?? '#>PiB#'); } public static function sanitizeFilename(string $name) |