ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
TimeSpan.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
27 class TimeSpan extends Column implements C\TimeSpan
28 {
29  public function __construct(
30  Language $lng,
31  string $title,
32  protected DateFormat $format
33  ) {
34  parent::__construct($lng, $title);
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 }
__construct(Language $lng, string $title, protected DateFormat $format)
Definition: TimeSpan.php:29
A Date Format provides a format definition akin to PHP&#39;s date formatting options, but stores the sing...
Definition: DateFormat.php:26
__construct(Container $dic, ilPlugin $plugin)
global $lng
Definition: privfeed.php:31