Project

General

Profile

Feature #14894 » class.tslib_content.php-calcAge.patch

Administrator Admin, 2005-08-02 13:39

View differences:

class.tslib_content.php 2005-08-02 13:33:23.549686834 +0200
*/
function calcAge($seconds,$labels) {
if (t3lib_div::testInt($labels)) {
$labels = ' min| hrs| days| yrs';
$labels = ' min| hrs| days| yrs| min| hour| day| year';
} else {
$labels=str_replace('"','',$labels);
}
$labelArr = explode('|',$labels);
if (count($labelArr) == 4) {
$labelArr = array_merge($labelArr, $labelArr);
}
if ($seconds<3600) {
$seconds = round ($seconds/60).$labelArr[0];
$val = round ($seconds/60);
$seconds = $val.($val==1?$labelArr[4]:$labelArr[0]);
} elseif ($seconds<24*3600) {
$seconds = round ($seconds/3600).$labelArr[1];
$val = round ($seconds/3600);
$seconds = $val.($val==1?$labelArr[5]:$labelArr[1]);
} elseif ($seconds<365*24*3600) {
$seconds = round ($seconds/(24*3600)).$labelArr[2];
$val = round ($seconds/(24*3600));
$seconds = $val.($val==1?$labelArr[6]:$labelArr[2]);
} else {
$seconds = round ($seconds/(365*24*3600)).$labelArr[3];
$val = round ($seconds/(365*24*3600));
$seconds = $val.($val==1?$labelArr[7]:$labelArr[3]);
}
return $seconds;
}
(1-1/2)