Skip to content

Commit

Permalink
Apply kormoc's nice_length patch to close #2700
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.mythtv.org/svn/trunk@12303 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
ex-nerd committed Dec 20, 2006
1 parent c635c6c commit 1867d2c
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,24 +191,27 @@ function nice_filesize($size) {
* @return string Translated hour/minute string.
/**/
function nice_length($length) {
$days = intVal($length / (24 * 3600));
$hours = intVal(($length % (24 * 3600)) / 3600);
$mins = intVal(($length % 3600) / 60);
$years = intVal( $length / 31556926 );
$length = $length - ( $years * 31556926 );
$months = intVal( $length / 2629743 );
$length = $length - ( $months * 2629743 );
$days = intVal( $length / 86400);
$length = $length - ( $days * 86400 );
$hours = intVal( $length / 3600 );
$length = $length - ( $hours * 3600 );
$mins = intVal( $length / 60 );
$ret = '';
if ($years > 0)
$ret = tn('$1 year', '$1 years', $years);
if ($months > 0)
$ret .= ' '.tn('$1 month', '$1 months', $months);
if ($days > 0)
$ret = tn('$1 day', '$1 days', $days);
else
$ret = '';
if ($hours > 0) {
if ($ret)
$ret .= ' ';
$ret .= tn('$1 hr', '$1 hrs', $hours);
}
if ($mins > 0) {
if ($ret)
$ret .= ' ';
$ret .= tn('$1 min', '$1 mins', $mins);
}
return $ret;
$ret .= ' '.tn('$1 day', '$1 days', $days);
if ($hours > 0)
$ret .= ' '.tn('$1 hr', '$1 hrs', $hours);
if ($mins > 0)
$ret .= ' '.tn('$1 min', '$1 mins', $mins);
return trim($ret);
}


Expand Down

0 comments on commit 1867d2c

Please sign in to comment.