diff options
| author | 2016-11-05 21:32:08 +0100 | |
|---|---|---|
| committer | 2016-11-05 21:32:08 +0100 | |
| commit | 6b85f8cf12f7d83bc7a6a599b48abe779dc263f0 (patch) | |
| tree | bb775ae14d473c42ce4d11a61bd5ec55f1dcf2ac | |
| parent | e66247f01271eb96ac96aad6c0631d9f544ce80c (diff) | |
CLI: IEC prefix (binary) for units
Updated according to https://wiki.ubuntu.com/UnitsPolicy
(I got confused due `ls`, which is still using 1024 but is listed as an
exception)
And use the formatting function already included in FreshRSS
| -rw-r--r-- | cli/user-info.php | 10 | ||||
| -rw-r--r-- | lib/lib_rss.php | 2 |
2 files changed, 3 insertions, 9 deletions
diff --git a/cli/user-info.php b/cli/user-info.php index 5b26ecb15..dd38e6c7f 100644 --- a/cli/user-info.php +++ b/cli/user-info.php @@ -2,14 +2,6 @@ <?php require('_cli.php'); -function formatSize($bytes) -{//http://www.php.net/manual/function.disk-free-space.php#103382 - $si_prefix = array('', 'k', 'M', 'G', 'T', 'P'); - $i = min((int)log($bytes, 1024), count($si_prefix) - 1); - return ($i <= 0) ? $bytes.'B' : - round($bytes / pow(1024, $i), 2).' '.$si_prefix[$i].'B'; -} - $options = getopt('h', array( 'user:', )); @@ -31,7 +23,7 @@ foreach ($users as $username) { echo $username, "\t", date('c', FreshRSS_UserDAO::mtime($username)), "\t", - formatSize($entryDAO->size()), "\t", + format_bytes($entryDAO->size()), "\t", "\n"; } else { echo diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 143b55bee..fc68a96d3 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -127,6 +127,8 @@ function format_bytes($bytes, $precision = 2, $system = 'IEC') { } elseif ($system === 'SI') { $base = 1000; $units = array('B', 'KB', 'MB', 'GB', 'TB'); + } else { + return format_number($bytes, $precision); } $bytes = max(intval($bytes), 0); $pow = $bytes === 0 ? 0 : floor(log($bytes) / log($base)); |
