Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #58 from fbergkemper/master
Browse files Browse the repository at this point in the history
Bugfix Issue #57
  • Loading branch information
frabdev committed Oct 31, 2014
2 parents 6de1348 + bbaf9fd commit 0f30787
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
8 changes: 4 additions & 4 deletions module/Application/src/Application/View/Helper/Expiration.php
Expand Up @@ -28,16 +28,16 @@
use Zend\View\Helper\AbstractHelper;

/**
*
*
*/
class Expiration extends AbstractHelper
{

protected $result;

/**
* @method
* @return string
* @method
* @return string
* @param
* @param
*/
Expand All @@ -59,7 +59,7 @@ public function __invoke($retention, $lastwritten, $volstatus)
$d2 = mktime(0, 0, 0, (int)$t2[1],(int)$t2[2],(int)$t2[0]);
$interval = ($d2 - $d1) / (3600 * 24);
$retention = round(($retention / 60 / 60 / 24 ), 2, PHP_ROUND_HALF_EVEN);
$this->result = ($retention - $interval);
$this->result = round(($retention - $interval), 2, PHP_ROUND_HALF_EVEN);

if($this->result <= 0) {
return $this->result = "<span class='label label-danger'>expired</span>";
Expand Down
Expand Up @@ -3,7 +3,7 @@
/**
*
* bareos-webui - Bareos Web-Frontend
*
*
* @link https://github.com/bareos/bareos-webui for the canonical source repository
* @copyright Copyright (c) 2013-2014 dass-IT GmbH (http://www.dass-it.de/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
Expand All @@ -28,7 +28,7 @@
use Zend\View\Helper\AbstractHelper;

/**
*
*
*/
class HumanReadableTimeperiod extends AbstractHelper
{
Expand All @@ -37,8 +37,8 @@ class HumanReadableTimeperiod extends AbstractHelper

/**
* A function for making timeperiods human readable
* @method
* @return string
* @method
* @return string
* @param
* @param
*/
Expand All @@ -51,32 +51,32 @@ public function __invoke($time, $format="short")
else {

$this->result = "-";
$dateTime = date_create($time);
$dateTime = date_create($time);
$timestamp = date_format($dateTime, 'U');
$seconds = time() - $timestamp;

if($format == "short") {

$units = array(
'y' => $seconds / 31556926 % 12,
'w' => $seconds / 604800 % 52,
'y' => $seconds / 31556926 % 12,
'w' => $seconds / 604800 % 52,
'd' => $seconds / 86400 % 7,
'h' => $seconds / 3600 % 24,
'm' => $seconds / 60 % 60,
'h' => $seconds / 3600 % 24,
'm' => $seconds / 60 % 60,
's' => $seconds % 60
);
);

foreach($units as $key => $value) {
if($value > 0) {
$res[] = $value . $key;
}
}
}
}

$this->result = join(' ', $res) . " ago";

}
}
elseif($format == "long") {

$units = array(
'Year(s)' => $seconds / 31556926 % 12,
'Week(s)' => $seconds / 604800 % 52,
Expand All @@ -90,8 +90,8 @@ public function __invoke($time, $format="short")
if($value > 0) {
$res[] = $value . $key;
}
}
}

$this->result = join(' ', $res) . " ago";

}
Expand All @@ -109,6 +109,7 @@ public function __invoke($time, $format="short")
return $this->result = "today";
}
elseif($interval <= 31 && $interval >= 1) {
$interval = round($interval, 0, PHP_ROUND_HALF_UP);
$this->result = "about " . $interval . " day(s) ago";
}
elseif($interval >= 31 && $interval <= 365) {
Expand All @@ -121,7 +122,7 @@ public function __invoke($time, $format="short")
}

}

return $this->result;

}
Expand Down

0 comments on commit 0f30787

Please sign in to comment.