2009-10-06 Miguel de Dios <miguel.dedios@artica.es>
* 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". git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2003 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
cf9e84d329
commit
dc82c7d858
|
@ -1,3 +1,8 @@
|
|||
2009-10-06 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* 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 <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_html.php: add new function for add extend widget
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
Loading…
Reference in New Issue