From: Davide Franco Date: Wed, 22 Jun 2011 15:43:33 +0000 (+0200) Subject: bacula-web: Split TimeUtils php class into new file timeutils.class.php X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=acaf5cd4c4798bb1e917cb6fb5a355a4896a0736;p=bacula%2Fbacula bacula-web: Split TimeUtils php class into new file timeutils.class.php --- diff --git a/gui/bacula-web/config.inc.php b/gui/bacula-web/config.inc.php index 236533f909..2dcc796fb6 100644 --- a/gui/bacula-web/config.inc.php +++ b/gui/bacula-web/config.inc.php @@ -33,6 +33,7 @@ require_once BW_OBJ . "graph/bgraph.class.php"; require_once BW_OBJ . "bweb.inc.php"; require_once BW_OBJ . "utils/utils.class.php"; + require_once BW_OBJ . "utils/timeutils.class.php"; // Global constants define('CONFIG_DIR', BW_ROOT . "/config/"); diff --git a/gui/bacula-web/includes/utils/timeutils.class.php b/gui/bacula-web/includes/utils/timeutils.class.php new file mode 100644 index 0000000000..cd3b13a4df --- /dev/null +++ b/gui/bacula-web/includes/utils/timeutils.class.php @@ -0,0 +1,53 @@ + 0 ) + return $daysDiff . 'day(s) ' . $hrsDiff.':' . $minsDiff . ':' . $secsDiff; + else + return $hrsDiff . ':' . $minsDiff . ':' . $secsDiff; + } +} + +?> diff --git a/gui/bacula-web/includes/utils/utils.class.php b/gui/bacula-web/includes/utils/utils.class.php index e2f02209da..b9eddfb315 100644 --- a/gui/bacula-web/includes/utils/utils.class.php +++ b/gui/bacula-web/includes/utils/utils.class.php @@ -47,39 +47,4 @@ class Utils { } } -class TimeUtils { - static public function Get_Elapsed_Time( $start_time, $end_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; - - $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; - } -} - ?>