Bug #21601 ยป 0012650.diff
t3lib/class.t3lib_befunc.php (Arbeitskopie) | ||
---|---|---|
* 1449: function date($tstamp)
|
||
* 1460: function datetime($value)
|
||
* 1472: function time($value)
|
||
* 1488: function calcAge($seconds,$labels = 'min|hrs|days|yrs')
|
||
* 1488: function calcAge($seconds,$labels = 'min;mins|hr;hrs|day;days|yr;yrs')
|
||
* 1514: function dateTimeAge($tstamp,$prefix=1,$date='')
|
||
* 1532: function titleAttrib($content='',$hsc=0)
|
||
* 1545: function titleAltAttrib($content)
|
||
... | ... | |
* @param string $labels should be something like ' min| hrs| days| yrs'. This value is typically delivered by this function call: $GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears")
|
||
* @return string Formatted time
|
||
*/
|
||
public static function calcAge($seconds, $labels = 'min|hrs|days|yrs') {
|
||
public static function calcAge($seconds, $labels = 'min;mins|hr;hrs|day;days|yr;yrs') {
|
||
$labelArr = explode('|', $labels);
|
||
$prefix = '';
|
||
if ($seconds<0) {$prefix = '-'; $seconds = abs($seconds);}
|
||
$label = '';
|
||
if ($seconds<0) {
|
||
$prefix = '-';
|
||
$seconds = abs($seconds);
|
||
}
|
||
if ($seconds<3600) {
|
||
$seconds = round ($seconds/60).' '.trim($labelArr[0]);
|
||
$seconds = round ($seconds/60);
|
||
$label = $labelArr[0];
|
||
} elseif ($seconds<24*3600) {
|
||
$seconds = round ($seconds/3600).' '.trim($labelArr[1]);
|
||
$label = $labelArr[1];
|
||
$seconds = round ($seconds/3600);
|
||
} elseif ($seconds<365*24*3600) {
|
||
$seconds = round ($seconds/(24*3600)).' '.trim($labelArr[2]);
|
||
$label = $labelArr[2];
|
||
$seconds = round ($seconds/(24*3600));
|
||
} else {
|
||
$seconds = round ($seconds/(365*24*3600)).' '.trim($labelArr[3]);
|
||
$label = $labelArr[3];
|
||
$seconds = round ($seconds/(365*24*3600));
|
||
}
|
||
return $prefix.$seconds;
|
||
list($labelSingular, $labelPlural) = explode(';', $label);
|
||
$label = $labelSingular;
|
||
if (($seconds != 1) && $labelPlural) {
|
||
$label = $labelPlural;
|
||
}
|
||
$label = trim($label);
|
||
$label = ($label?' ':'').$label;
|
||
return $prefix.$seconds.$label;
|
||
}
|
||
/**
|
typo3/sysext/lang/locallang_core.xml (Arbeitskopie) | ||
---|---|---|
<label index="labels.hidden">Hidden</label>
|
||
<label index="labels.starttime">Start</label>
|
||
<label index="labels.endtime">End</label>
|
||
<label index="labels.minutesHoursDaysYears">min| hrs| days| yrs</label>
|
||
<label index="labels.minutesHoursDaysYears">min; mins| hr; hrs| day; days| yr; yrs</label>
|
||
<label index="labels.menu">Menu:</label>
|
||
<label index="labels.showPage">View webpage</label>
|
||
<label index="labels.showList">Show record list</label>
|
typo3/sysext/cms/tslib/class.tslib_content.php (Arbeitskopie) | ||
---|---|---|
*/
|
||
function calcAge($seconds,$labels) {
|
||
if (t3lib_div::testInt($labels)) {
|
||
$labels = ' min| hrs| days| yrs';
|
||
$labels = ' min; mins| hr; hrs| day; days| yr; yrs';
|
||
} else {
|
||
$labels=str_replace('"','',$labels);
|
||
}
|
||
... | ... | |
$labelArr = explode('|',$labels);
|
||
$absSeconds = abs($seconds);
|
||
if ($absSeconds<3600) {
|
||
$seconds = round ($seconds/60).$labelArr[0];
|
||
$label = $labelArr[0];
|
||
$seconds = round ($seconds/60);
|
||
} elseif ($absSeconds<24*3600) {
|
||
$seconds = round ($seconds/3600).$labelArr[1];
|
||
$label = $labelArr[1];
|
||
$seconds = round ($seconds/3600);
|
||
} elseif ($absSeconds<365*24*3600) {
|
||
$seconds = round ($seconds/(24*3600)).$labelArr[2];
|
||
$label = $labelArr[2];
|
||
$seconds = round ($seconds/(24*3600));
|
||
} else {
|
||
$seconds = round ($seconds/(365*24*3600)).$labelArr[3];
|
||
$label = $labelArr[3];
|
||
$seconds = round ($seconds/(365*24*3600));
|
||
}
|
||
return $seconds;
|
||
list($labelSingular, $labelPlural) = explode(';', $label);
|
||
$label = $labelSingular;
|
||
if (($seconds != 1) && $labelPlural) {
|
||
$label = $labelPlural;
|
||
}
|
||
return $seconds.$label;
|
||
}
|
||
/**
|