diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-02-14 18:55:55 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-02-14 18:55:55 -0500 |
commit | 23346d5e76a171efb407612dc54a92740863dfbc (patch) | |
tree | 650a2d8063b79d20a71ce4ef2fb3aca1e31c2409 /app/Core | |
parent | 8c8692cd4d7a7f6872f79805da7ef89075cbcc4b (diff) |
Move function to the right place (pull-request) and improve board task icons
Diffstat (limited to 'app/Core')
-rw-r--r-- | app/Core/Helper.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/app/Core/Helper.php b/app/Core/Helper.php index d60e29d4..57d1b98a 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 |