add format padding so that right align file size strings will line up nicely.

This commit is contained in:
Isaac Connor
2020-12-11 09:33:36 -05:00
parent f89da79c27
commit bfd16db34b

View File

@@ -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() {