ILIAS  release_8 Revision v8.24
class.ilAdvancedMDFieldDefinitionDateTime.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
29{
30 //
31 // generic types
32 //
33
34 public function getType(): int
35 {
37 }
38
39
40 //
41 // ADT
42 //
43
44 protected function initADTDefinition(): ilADTDefinition
45 {
46 return ilADTFactory::getInstance()->getDefinitionInstanceByType("DateTime");
47 }
48
49
50 //
51 // import/export
52 //
53
54 public function getValueForXML(ilADT $element): string
55 {
56 return $element->getDate()->get(IL_CAL_DATETIME);
57 }
58
59 public function importValueFromXML(string $a_cdata): void
60 {
61 $this->getADT()->setDate(new ilDate($a_cdata, IL_CAL_DATETIME));
62 }
63
64 public function importFromECS(string $a_ecs_type, $a_value, string $a_sub_id): bool
65 {
66 $value = '';
67 switch ($a_ecs_type) {
69 if ($a_value instanceof ilECSTimePlace) {
70 $value = new ilDateTime($a_value->{'getUT' . ucfirst($a_sub_id)}(), IL_CAL_UNIX);
71 }
72 break;
73 }
74
75 if ($value instanceof ilDateTime) {
76 $this->getADT()->setDate($value);
77 return true;
78 }
79 return false;
80 }
81
85 public function getLuceneSearchString($a_value): string
86 {
87 $start = new ilDateTime('1970-01-01 00:00:01', IL_CAL_DATETIME, ilTimeZone::UTC);
88 $end = new ilDateTime('2038-01-19 00:00:01', IL_CAL_DATETIME, ilTimeZone::UTC);
89
90 if (!($a_value['lower'] ?? false) || !($a_value['upper'])) {
91 return '';
92 }
93 if ($a_value['lower'] ?? false) {
94 $start = ilCalendarUtil::parseIncomingDate($a_value['lower'], true);
95 }
96 if ($a_value['upper'] ?? false) {
97 $end = ilCalendarUtil::parseIncomingDate($a_value['upper'], true);
98 }
99 return '[' . $start->get(IL_CAL_FKT_DATE, 'Y-m-d\Th:m') . ' TO ' . $end->get(IL_CAL_FKT_DATE, 'Y-m-d\Th:m') . ']';
100 }
101}
const IL_CAL_UNIX
const IL_CAL_DATETIME
const IL_CAL_FKT_DATE
ADT definition base class.
ADT base class.
Definition: class.ilADT.php:12
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getLuceneSearchString($a_value)
Get search string in lucene syntax.with php 8 support change parameter to union type
importFromECS(string $a_ecs_type, $a_value, string $a_sub_id)
Import meta data from ECS.
importValueFromXML(string $a_cdata)
Import value from xml.
getValueForXML(ilADT $element)
Parse ADT value for xml (export)
static parseIncomingDate($a_value, bool $a_add_time=false)
Try to parse incoming value to date object.
@classDescription Date and time handling
Class for single dates.
Representation of ECS EContent Time Place.
const TYPE_TIMEPLACE