ILIAS  release_8 Revision v8.24
ilIndividualAssessmentDateFormatter.php
Go to the documentation of this file.
1<?php
18declare(strict_types=1);
19
20use ILIAS\Data\Factory as DataFactory;
22
24{
25 protected DataFactory $data_factory;
26
27 public function __construct(DataFactory $data_factory)
28 {
29 $this->data_factory = $data_factory;
30 }
31
32 public function getUserDateFormat(ilObjUser $user, bool $with_time = false): DateFormat
33 {
34 $df = $this->data_factory->dateFormat();
35 switch ($user->getDateFormat()) {
37 $date_format = $df->germanShort();
38 break;
40 //americanShort
41 $date_format = $df->custom()->month()->slash()->day()->slash()->year()->get();
42 break;
44 default:
45 $date_format = $df->standard();
46 }
47 if ($with_time) {
48 switch ($user->getTimeFormat()) {
50 $date_format = $df->withTime12($date_format);
51 break;
53 default:
54 $date_format = $df->withTime24($date_format);
55 }
56 }
57 return $date_format;
58 }
59
60 public function format(
61 ilObjUser $user,
62 DateTimeImmutable $datetime,
63 bool $with_time = false
64 ): string {
65 return $this->getUserDateFormat($user, $with_time)->applyTo($datetime);
66 }
67}
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:21
getUserDateFormat(ilObjUser $user, bool $with_time=false)
format(ilObjUser $user, DateTimeImmutable $datetime, bool $with_time=false)
User class.
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
applyTo(Result $result)
@inheritDoc