From 4699734950b4eac5f140fe205e89f50a15098d4b Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Tue, 21 Jun 2011 14:21:19 +0200 Subject: [PATCH] bacula-web: Optimized TimeUtils::Get_Elapsed_Time() function --- gui/bacula-web/includes/utils/utils.class.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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; -- 2.39.5