blob: f16731a6923d42ee373663ee9bf1ecde859f0099 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<?php
namespace ipl\Web\Widget;
use Icinga\Date\DateFormatter;
use ipl\Html\BaseHtmlElement;
class TimeUntil extends BaseHtmlElement
{
/** @var int */
protected $until;
protected $tag = 'time';
protected $defaultAttributes = ['class' => 'time-until'];
public function __construct($until)
{
$this->until = (int) $until;
}
protected function assemble()
{
$dateTime = DateFormatter::formatDateTime($this->until);
$this->addAttributes([
'datetime' => $dateTime,
'title' => $dateTime,
'data-ago-label' => DateFormatter::timeAgo(time())
]);
$this->add(DateFormatter::timeUntil($this->until));
}
}
|