From bfd16db34bc462b2abb06f10c723ef5ef77fa5fe Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 11 Dec 2020 09:33:36 -0500 Subject: [PATCH] add format padding so that right align file size strings will line up nicely. --- web/includes/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/includes/functions.php b/web/includes/functions.php index c2072a706..fe7d2ae77 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -2149,14 +2149,15 @@ function folder_size($dir) { } // end function folder_size function human_filesize($size, $precision = 2) { - $units = array('B','kB','MB','GB','TB','PB','EB','ZB','YB'); + $units = array('B ','kB','MB','GB','TB','PB','EB','ZB','YB'); $step = 1024; $i = 0; while (($size / $step) > 0.9) { $size = $size / $step; $i++; } - return round($size, $precision).$units[$i]; + # The idea is that we can right align this and have the digits columns line up nicely. + return sprintf('%.'.$precision.'f', round($size, $precision)).$units[$i]; } function csrf_startup() {