From: Davide Franco Date: Tue, 21 Jun 2011 12:21:19 +0000 (+0200) Subject: bacula-web: Optimized TimeUtils::Get_Elapsed_Time() function X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4699734950b4eac5f140fe205e89f50a15098d4b;p=bacula%2Fbacula bacula-web: Optimized TimeUtils::Get_Elapsed_Time() function --- diff --git a/gui/bacula-web/includes/utils/utils.class.php b/gui/bacula-web/includes/utils/utils.class.php index 584e8d0f0d..e2f02209da 100644 --- a/gui/bacula-web/includes/utils/utils.class.php +++ b/gui/bacula-web/includes/utils/utils.class.php @@ -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;