ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilIndividualAssessmentDateFormatter.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
25 {
27 
28  public function __construct(DataFactory $data_factory)
29  {
30  $this->data_factory = $data_factory;
31  }
32 
33  public function getUserDateFormat(ilObjUser $user, bool $with_time = false): DateFormat
34  {
35  $df = $this->data_factory->dateFormat();
36  $date_format = $user->getDateFormat();
37  if ($with_time) {
38  switch ($user->getTimeFormat()) {
40  $date_format = $df->withTime12($date_format);
41  break;
43  default:
44  $date_format = $df->withTime24($date_format);
45  }
46  }
47  return $date_format;
48  }
49 
50  public function format(
51  ilObjUser $user,
53  bool $with_time = false
54  ): string {
55  return $this->getUserDateFormat($user, $with_time)->applyTo($datetime);
56  }
57 }
getUserDateFormat(ilObjUser $user, bool $with_time=false)
$datetime
A Date Format provides a format definition akin to PHP&#39;s date formatting options, but stores the sing...
Definition: DateFormat.php:26
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
format(ilObjUser $user, DateTimeImmutable $datetime, bool $with_time=false)