ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilIndividualAssessmentDateFormatter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Data\Factory as DataFactory;
23
25{
26 protected DataFactory $data_factory;
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,
52 DateTimeImmutable $datetime,
53 bool $with_time = false
54 ): string {
55 return $this->getUserDateFormat($user, $with_time)->applyTo($datetime);
56 }
57}
$datetime
A Date Format provides a format definition akin to PHP's date formatting options, but stores the sing...
Definition: DateFormat.php:27
Builds data types.
Definition: Factory.php:36
getUserDateFormat(ilObjUser $user, bool $with_time=false)
format(ilObjUser $user, DateTimeImmutable $datetime, bool $with_time=false)
User class.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
applyTo(Result $result)
@inheritDoc