ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
TimeSpan.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 
26 class TimeSpan extends Column implements C\TimeSpan
27 {
28  public function __construct(
30  string $title,
31  protected DateFormat $format
32  ) {
33  parent::__construct($lng, $title);
34  }
35 
36  public function getFormat(): DateFormat
37  {
38  return $this->format;
39  }
40 
41  public function format($value): string
42  {
43  $this->checkArgListElements('value', $value, [\DateTimeImmutable::class]);
44  return
45  $value[0]->format($this->getFormat()->toString())
46  . ' - ' .
47  $value[1]->format($this->getFormat()->toString());
48  }
49 
53  public function getOrderingLabels(): array
54  {
55  return [
56  $this->asc_label ?? $this->getTitle() . self::SEPERATOR . $this->lng->txt('order_option_chronological_ascending'),
57  $this->desc_label ?? $this->getTitle() . self::SEPERATOR . $this->lng->txt('order_option_chronological_descending')
58  ];
59  }
60 }
__construct(\ilLanguage $lng, string $title, protected DateFormat $format)
Definition: TimeSpan.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(VocabulariesInterface $vocabularies)
A Date Format provides a format definition akin to PHP&#39;s date formatting options, but stores the sing...
Definition: DateFormat.php:26
$lng