]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: New class TimeUtils in utils.class.php module
authorDavide Franco <bacula-dev@dflc.ch>
Mon, 20 Jun 2011 17:00:51 +0000 (19:00 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:13 +0000 (14:49 +0200)
 - A class member function <Get_Elapsed_Time> has been created

gui/bacula-web/includes/utils/utils.class.php

index f4ca1776dac91004eeb257ddb58a39f9e44e35df..203dfdb578793a0dab768d56701550e56cb339af 100644 (file)
@@ -46,4 +46,27 @@ class Utils {
                return $hsize;
        }
 }
+
+class TimeUtils {
+       static public function Get_Elapsed_Time( $start, $end)
+       {
+               $diff = $end_time - $start_time;
+
+        $daysDiff = sprintf("%02d", floor($diff/60/60/24) );
+        $diff -= $daysDiff*60*60*24;
+
+        $hrsDiff = sprintf("%02d", floor($diff/60/60) );
+        $diff -= $hrsDiff*60*60;
+
+        $minsDiff = sprintf("%02d", floor($diff/60) );
+        $diff -= $minsDiff*60;
+        $secsDiff = sprintf("%02d", $diff );
+
+        if( $daysDiff > 0 )
+                       return $daysDiff . 'day(s) ' . $hrsDiff.':' . $minsDiff . ':' . $secsDiff;
+        else
+                       return $hrsDiff . ':' . $minsDiff . ':' . $secsDiff;
+       }
+}
+
 ?>