]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Optimized TimeUtils::Get_Elapsed_Time() function
authorDavide Franco <bacula-dev@dflc.ch>
Tue, 21 Jun 2011 12:21:19 +0000 (14:21 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:13 +0000 (14:49 +0200)
gui/bacula-web/includes/utils/utils.class.php

index 584e8d0f0d98a9fa72404945cc3f35b3c3b56580..e2f02209da25b5591abe70aa141662f7f7af6f18 100644 (file)
@@ -50,7 +50,20 @@ class Utils {
 class TimeUtils {
        static public function Get_Elapsed_Time( $start_time, $end_time)
        {
-               $diff = $end_time - $start_time;
+               $start = '';
+               $end   = '';
+               
+               if( $start_time == '0000-00-00 00:00:00' )
+                       return 'N/A';
+               else
+                       $start = strtotime( $start_time );                                      
+        
+               if( $end_time == '0000-00-00 00:00:00' )
+                       $end = mktime();
+               else
+                       $end   = strtotime( $end_time );
+               
+               $diff = $end - $start;
 
         $daysDiff = sprintf("%02d", floor($diff/60/60/24) );
         $diff -= $daysDiff*60*60*24;