diff options
Diffstat (limited to 'app/Core')
-rw-r--r-- | app/Core/Helper.php | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/app/Core/Helper.php b/app/Core/Helper.php index d60e29d4..187fcfbb 100644 --- a/app/Core/Helper.php +++ b/app/Core/Helper.php @@ -50,6 +50,33 @@ class Helper } /** + * 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() * * @access public @@ -639,7 +666,7 @@ class Helper 'subtaskRestriction', array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'redirect' => $redirect), false, - 'popover-subtask-restriction' + 'popover' ); } |