ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Time.php
Go to the documentation of this file.
1<?php
2
4
6
16class Time extends Text {
17
24 public $delimiter = null;
25
34 function getValueType() {
35
36 return 'TIME';
37
38 }
39
49 function setJsonValue(array $value) {
50
51 // Removing colons from value.
52 $value = str_replace(
53 ':',
54 '',
55 $value
56 );
57
58 if (count($value) === 1) {
59 $this->setValue(reset($value));
60 } else {
61 $this->setValue($value);
62 }
63
64 }
65
73 function getJsonValue() {
74
76 $timeStr = '';
77
78 // Hour
79 if (!is_null($parts['hour'])) {
80 $timeStr .= $parts['hour'];
81
82 if (!is_null($parts['minute'])) {
83 $timeStr .= ':';
84 }
85 } else {
86 // We know either minute or second _must_ be set, so we insert a
87 // dash for an empty value.
88 $timeStr .= '-';
89 }
90
91 // Minute
92 if (!is_null($parts['minute'])) {
93 $timeStr .= $parts['minute'];
94
95 if (!is_null($parts['second'])) {
96 $timeStr .= ':';
97 }
98 } else {
99 if (isset($parts['second'])) {
100 // Dash for empty minute
101 $timeStr .= '-';
102 }
103 }
104
105 // Second
106 if (!is_null($parts['second'])) {
107 $timeStr .= $parts['second'];
108 }
109
110 // Timezone
111 if (!is_null($parts['timezone'])) {
112 if ($parts['timezone'] === 'Z') {
113 $timeStr .= 'Z';
114 } else {
115 $timeStr .=
116 preg_replace('/([0-9]{2})([0-9]{2})$/', '$1:$2', $parts['timezone']);
117 }
118 }
119
120 return [$timeStr];
121
122 }
123
132 function setXmlValue(array $value) {
133
134 $value = array_map(
135 function($value) {
136 return str_replace(':', '', $value);
137 },
138 $value
139 );
140 parent::setXmlValue($value);
141
142 }
143
144}
An exception for terminatinating execution or to throw for unit testing.
static parseVCardTime($date)
This method parses a vCard TIME value.
count()
Returns the number of elements.
Definition: Node.php:177
Text property.
Definition: Text.php:20
Time property.
Definition: Time.php:16
setJsonValue(array $value)
Sets the JSON value, as it would appear in a jCard or jCal object.
Definition: Time.php:49
getJsonValue()
Returns the value, in the format it should be encoded for json.
Definition: Time.php:73
setXmlValue(array $value)
Hydrate data from a XML subtree, as it would appear in a xCard or xCal object.
Definition: Time.php:132
getValueType()
Returns the type of value.
Definition: Time.php:34
getValue()
Returns the current value.
Definition: Property.php:115
setValue($value)
Updates the current value.
Definition: Property.php:98