Move function to the right place (pull-request) and improve board task icons

This commit is contained in:
Frederic Guillot
2015-02-14 18:55:55 -05:00
parent 8c8692cd4d
commit 23346d5e76
19 changed files with 173 additions and 164 deletions

View File

@@ -49,6 +49,33 @@ class Helper
return $this->container[$name];
}
/**
* Get the age of an item in quasi human readable format.
* It's in this format: <1h , NNh, NNd
*
* @access public
* @param integer $timestamp Unix timestamp of the artifact for which age will be calculated
* @param integer $now Compare with this timestamp (Default value is the current unix timestamp)
* @return string
*/
public function getTaskAge($timestamp, $now = null)
{
if ($now === null) {
$now = time();
}
$diff = $now - $timestamp;
if ($diff < 3600) {
return t('<1h');
}
else if ($diff < 86400) {
return t('%dh', $diff / 3600);
}
return t('%dd', ($now - $timestamp) / 86400);
}
/**
* Proxy cache helper for acl::isManagerActionAllowed()
*