3 +-------------------------------------------------------------------------+
4 | Copyright 2010-2011, Davide Franco |
6 | This program is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU General Public License |
8 | as published by the Free Software Foundation; either version 2 |
9 | of the License, or (at your option) any later version. |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. |
15 +-------------------------------------------------------------------------+
18 static public function Get_Human_Size( $size, $decimal = 2, $unit = 'auto' )
22 $units = array('B','KB','MB','GB','TB');
29 if ( $hsize >= 1024 ) {
30 $hsize = $hsize / 1024;
39 $p = array_search( $unit, $units);
40 $hsize = $hsize / pow(1024,$p);
44 $hsize = sprintf("%." . $decimal . "f", $hsize);
45 $hsize = $hsize . ' ' . $units[$unit_id];
51 static public function Get_Elapsed_Time( $start, $end)
53 $diff = $end_time - $start_time;
55 $daysDiff = sprintf("%02d", floor($diff/60/60/24) );
56 $diff -= $daysDiff*60*60*24;
58 $hrsDiff = sprintf("%02d", floor($diff/60/60) );
59 $diff -= $hrsDiff*60*60;
61 $minsDiff = sprintf("%02d", floor($diff/60) );
62 $diff -= $minsDiff*60;
63 $secsDiff = sprintf("%02d", $diff );
66 return $daysDiff . 'day(s) ' . $hrsDiff.':' . $minsDiff . ':' . $secsDiff;
68 return $hrsDiff . ':' . $minsDiff . ':' . $secsDiff;