gforge-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gforge-commits] gforge/common/include utils.php,1.34,1.35


From: tom
Subject: [Gforge-commits] gforge/common/include utils.php,1.34,1.35
Date: Fri, 13 Aug 2004 15:12:19 -0500

Update of /cvsroot/gforge/gforge/common/include
In directory db.perdue.net:/tmp/cvs-serv11255/common/include

Modified Files:
        utils.php 
Log Message:
Now MB show up as '1.23 MB' vs '1 MB'

Index: utils.php
===================================================================
RCS file: /cvsroot/gforge/gforge/common/include/utils.php,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- utils.php   13 Aug 2004 20:02:36 -0000      1.34
+++ utils.php   13 Aug 2004 20:12:16 -0000      1.35
@@ -799,10 +799,10 @@
  *                  10^3(base10==true) multiple of base units
  */
 function human_readable_bytes ($bytes, $base10=false, $round=0, 
$labels=array(' bytes',  ' KB', ' MB', ' GB')) {
-       if (($bytes <= 0) || (! is_array($labels)) || (count($labels) <= 0)) {
+       if ($bytes <= 0 || !is_array($labels) || (count($labels) <= 0)) {
                return null;
        }
-       $step = $base10 ? 3 : 10 ;
+       $step = $base10 ? 3 : 10;
        $base = $base10 ? 10 : 2;
        $log = (int)(log10($bytes)/log10($base));
        krsort($labels);
@@ -811,6 +811,9 @@
                if ($log < $pow) {
                        continue;
                }
+               if ($lab == " MB") {
+                       $round = 2;
+               }
                $text = round($bytes/pow($base,$pow),$round).$lab;
                break;
        }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]