ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
Date.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 
26 class Date extends Column implements C\Date
27 {
28  protected DateFormat $format;
29 
30  public function __construct(
32  string $title,
33  DateFormat $format
34  ) {
35  parent::__construct($lng, $title);
36  $this->format = $format;
37  }
38 
39  public function getFormat(): DateFormat
40  {
41  return $this->format;
42  }
43 
44  public function format($value): string
45  {
46  $this->checkArgInstanceOf('value', $value, \DateTimeImmutable::class);
47  return $value->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 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
__construct(\ilLanguage $lng, string $title, DateFormat $format)
Definition: Date.php:30