summaryrefslogtreecommitdiff
path: root/app/Helper
diff options
context:
space:
mode:
Diffstat (limited to 'app/Helper')
-rw-r--r--app/Helper/Datetime.php33
-rw-r--r--app/Helper/Task.php27
2 files changed, 33 insertions, 27 deletions
diff --git a/app/Helper/Datetime.php b/app/Helper/Datetime.php
index 3a9c4c48..74ea9bdd 100644
--- a/app/Helper/Datetime.php
+++ b/app/Helper/Datetime.php
@@ -11,6 +11,39 @@ namespace Helper;
class Datetime extends \Core\Base
{
/**
+ * 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 age($timestamp, $now = null)
+ {
+ if ($now === null) {
+ $now = time();
+ }
+
+ $diff = $now - $timestamp;
+
+ if ($diff < 900) {
+ return t('<15m');
+ }
+ if ($diff < 1200) {
+ return t('<30m');
+ }
+ else if ($diff < 3600) {
+ return t('<1h');
+ }
+ else if ($diff < 86400) {
+ return '~'.t('%dh', $diff / 3600);
+ }
+
+ return t('%dd', ($now - $timestamp) / 86400);
+ }
+
+ /**
* Get all hours for day
*
* @access public
diff --git a/app/Helper/Task.php b/app/Helper/Task.php
index 13bdb07a..79c412e1 100644
--- a/app/Helper/Task.php
+++ b/app/Helper/Task.php
@@ -10,33 +10,6 @@ namespace Helper;
*/
class Task extends \Core\Base
{
- /**
- * 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 age($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);
- }
-
public function getColors()
{
return $this->color->getList();