diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index ab3b52461f..fef5179493 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2009-10-06 Miguel de Dios + + * include/functions.php: add "exactly" param to "human_time_description_raw" + for return the time in time fractions as example "1 day 23:23:2". + 2009-10-06 Miguel de Dios * include/functions_html.php: add new function for add extend widget diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index da942fe4c9..80e2c20338 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -417,10 +417,11 @@ function get_system_time () { * strings of minutes, hours or days. * * @param int $seconds Seconds elapsed time + * @param int $exactly If it's true, return the exactly human time * * @return string A human readable translation of minutes. */ -function human_time_description_raw ($seconds) { +function human_time_description_raw ($seconds, $exactly = false) { if (empty ($seconds)) { return __('Now'); @@ -429,6 +430,25 @@ function human_time_description_raw ($seconds) { // Put here "uknown" or N/A or something similar is not a good idea } + if ($exactly) { + $secs = $seconds % 60; + $mins = ($seconds /60) % 60; + $hours = ($seconds / 3600) % 24; + $days = ($seconds / 86400) % 30; + $months = format_numeric ($seconds / 2592000, 0); + + if (($mins == 0) && ($hours == 0) && ($days == 0) && ($months == 0)) + return format_numeric ($secs, 0).' '.__('seconds'); + else if (($hours == 0) && ($days == 0) && ($months == 0)) + return sprintf("%02d",$mins).':'.sprintf("%02d",$secs); + else if (($days == 0) && ($months == 0)) + return sprintf("%02d",$hours).':'.sprintf("%02d",$mins).':'.sprintf("%02d",$secs); + else if (($months == 0)) + return $days.' '.__('days').' '.sprintf("%02d",$hours).':'.sprintf("%02d",$mins).':'.sprintf("%02d",$secs); + else + return $months.' '.__('moths').' '.$days.' '.__('days').' '.sprintf("%02d",$hours).':'.sprintf("%02d",$mins).':'.sprintf("%02d",$secs); + } + if ($seconds < 60) return format_numeric ($seconds, 0)." ".__('seconds');