ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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  protected DateFormat $format;
29 
30  public function __construct(
32  string $title,
33  DateFormat $format
34  )
35  {
36  parent::__construct($lng, $title);
37  $this->format = $format;
38  }
39 
40  public function getFormat(): DateFormat
41  {
42  return $this->format;
43  }
44 
45  public function format($value): string
46  {
47  $this->checkArgListElements('value', $value, [\DateTimeImmutable::class]);
48  return
49  $value[0]->format($this->getFormat()->toString())
50  . ' - ' .
51  $value[1]->format($this->getFormat()->toString());
52  }
53 
57  public function getOrderingLabels(): array
58  {
59  return [
60  $this->asc_label ?? $this->getTitle() . self::SEPERATOR . $this->lng->txt('order_option_chronological_ascending'),
61  $this->desc_label ?? $this->getTitle() . self::SEPERATOR . $this->lng->txt('order_option_chronological_descending')
62  ];
63  }
64 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(\ilLanguage $lng, string $title, DateFormat $format)
Definition: TimeSpan.php:30
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)