ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAdvancedMDFieldDefinitionDateTime.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 //
30 // generic types
31 //
32
33 public function getType(): int
34 {
36 }
37
38
39 //
40 // ADT
41 //
42
43 protected function initADTDefinition(): ilADTDefinition
44 {
45 return ilADTFactory::getInstance()->getDefinitionInstanceByType("DateTime");
46 }
47
48
49 //
50 // import/export
51 //
52
53 public function getValueForXML(ilADT $element): string
54 {
55 return $element->getDate()->get(IL_CAL_DATETIME);
56 }
57
58 public function importValueFromXML(string $a_cdata): void
59 {
60 $this->getADT()->setDate(new ilDate($a_cdata, IL_CAL_DATETIME));
61 }
62
63 public function importFromECS(string $a_ecs_type, $a_value, string $a_sub_id): bool
64 {
65 $value = '';
66 switch ($a_ecs_type) {
68 if ($a_value instanceof ilECSTimePlace) {
69 $value = new ilDateTime($a_value->{'getUT' . ucfirst($a_sub_id)}(), IL_CAL_UNIX);
70 }
71 break;
72 }
73
74 if ($value instanceof ilDateTime) {
75 $this->getADT()->setDate($value);
76 return true;
77 }
78 return false;
79 }
80
84 public function getLuceneSearchString($a_value): string
85 {
86 $start = new ilDateTime('1970-01-01 00:00:01', IL_CAL_DATETIME, ilTimeZone::UTC);
87 $end = new ilDateTime('2038-01-19 00:00:01', IL_CAL_DATETIME, ilTimeZone::UTC);
88
89 if (!($a_value['lower'] ?? false) || !($a_value['upper'])) {
90 return '';
91 }
92 if ($a_value['lower'] ?? false) {
93 $start = ilCalendarUtil::parseIncomingDate($a_value['lower'], true);
94 }
95 if ($a_value['upper'] ?? false) {
96 $end = ilCalendarUtil::parseIncomingDate($a_value['upper'], true);
97 }
98 return '[' . $start->get(IL_CAL_FKT_DATE, 'Y-m-d\Th:m') . ' TO ' . $end->get(IL_CAL_FKT_DATE, 'Y-m-d\Th:m') . ']';
99 }
100}
const IL_CAL_UNIX
const IL_CAL_DATETIME
const IL_CAL_FKT_DATE
ADT definition base class.
ADT base class.
Definition: class.ilADT.php:26
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($value, bool $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