ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
TimeSpan.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26
27class TimeSpan extends Column implements C\TimeSpan
28{
29 public function __construct(
31 string $title,
32 protected DateFormat $format
33 ) {
35 }
36
37 public function getFormat(): DateFormat
38 {
39 return $this->format;
40 }
41
42 public function format($value): string
43 {
44 $this->checkArgListElements('value', $value, [\DateTimeImmutable::class]);
45 return
46 $value[0]->format($this->getFormat()->toString())
47 . ' - ' .
48 $value[1]->format($this->getFormat()->toString());
49 }
50
54 public function getOrderingLabels(): array
55 {
56 return [
57 $this->asc_label ?? $this->getTitle() . self::SEPERATOR . $this->lng->txt('order_option_chronological_ascending'),
58 $this->desc_label ?? $this->getTitle() . self::SEPERATOR . $this->lng->txt('order_option_chronological_descending')
59 ];
60 }
61}
A Date Format provides a format definition akin to PHP's date formatting options, but stores the sing...
Definition: DateFormat.php:27
__construct(Language $lng, string $title, protected DateFormat $format)
Definition: TimeSpan.php:29
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $lng
Definition: privfeed.php:31