PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / sabre / vobject / lib / Property / Time.php
ameliabooking / vendor / sabre / vobject / lib / Property Last commit date
ICalendar 6 months ago VCard 6 months ago Binary.php 6 months ago Boolean.php 6 months ago FlatText.php 6 months ago FloatValue.php 6 months ago IntegerValue.php 6 months ago Text.php 6 months ago Time.php 6 months ago Unknown.php 6 months ago Uri.php 6 months ago UtcOffset.php 6 months ago
Time.php
132 lines
1 <?php
2
3 namespace AmeliaVendor\Sabre\VObject\Property;
4
5 use AmeliaVendor\Sabre\VObject\DateTimeParser;
6
7 /**
8 * Time property.
9 *
10 * This object encodes TIME values.
11 *
12 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
13 * @author Evert Pot (http://evertpot.com/)
14 * @license http://sabre.io/license/ Modified BSD License
15 */
16 class Time extends Text
17 {
18 /**
19 * In case this is a multi-value property. This string will be used as a
20 * delimiter.
21 *
22 * @var string
23 */
24 public $delimiter = '';
25
26 /**
27 * Returns the type of value.
28 *
29 * This corresponds to the VALUE= parameter. Every property also has a
30 * 'default' valueType.
31 *
32 * @return string
33 */
34 public function getValueType()
35 {
36 return 'TIME';
37 }
38
39 /**
40 * Sets the JSON value, as it would appear in a jCard or jCal object.
41 *
42 * The value must always be an array.
43 */
44 public function setJsonValue(array $value)
45 {
46 // Removing colons from value.
47 $value = str_replace(
48 ':',
49 '',
50 $value
51 );
52
53 if (1 === count($value)) {
54 $this->setValue(reset($value));
55 } else {
56 $this->setValue($value);
57 }
58 }
59
60 /**
61 * Returns the value, in the format it should be encoded for json.
62 *
63 * This method must always return an array.
64 *
65 * @return array
66 */
67 public function getJsonValue()
68 {
69 $parts = DateTimeParser::parseVCardTime($this->getValue());
70 $timeStr = '';
71
72 // Hour
73 if (!is_null($parts['hour'])) {
74 $timeStr .= $parts['hour'];
75
76 if (!is_null($parts['minute'])) {
77 $timeStr .= ':';
78 }
79 } else {
80 // We know either minute or second _must_ be set, so we insert a
81 // dash for an empty value.
82 $timeStr .= '-';
83 }
84
85 // Minute
86 if (!is_null($parts['minute'])) {
87 $timeStr .= $parts['minute'];
88
89 if (!is_null($parts['second'])) {
90 $timeStr .= ':';
91 }
92 } else {
93 if (isset($parts['second'])) {
94 // Dash for empty minute
95 $timeStr .= '-';
96 }
97 }
98
99 // Second
100 if (!is_null($parts['second'])) {
101 $timeStr .= $parts['second'];
102 }
103
104 // Timezone
105 if (!is_null($parts['timezone'])) {
106 if ('Z' === $parts['timezone']) {
107 $timeStr .= 'Z';
108 } else {
109 $timeStr .=
110 preg_replace('/([0-9]{2})([0-9]{2})$/', '$1:$2', $parts['timezone']);
111 }
112 }
113
114 return [$timeStr];
115 }
116
117 /**
118 * Hydrate data from a XML subtree, as it would appear in a xCard or xCal
119 * object.
120 */
121 public function setXmlValue(array $value)
122 {
123 $value = array_map(
124 function ($value) {
125 return str_replace(':', '', $value);
126 },
127 $value
128 );
129 parent::setXmlValue($value);
130 }
131 }
132