annotate vendor/sabre/vobject/lib/DateTimeParser.php @ 7:430dbd5346f7

vendor sabre as distributed
author Charlie Root
date Sat, 13 Jan 2018 09:06:10 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
1 <?php
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
2
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
3 namespace Sabre\VObject;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
4
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
5 use DateTime;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
6 use DateTimeZone;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
7 use DateInterval;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
8 use InvalidArgumentException;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
9 use LogicException;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
10
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
11 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
12 * DateTimeParser
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
13 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
14 * This class is responsible for parsing the several different date and time
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
15 * formats iCalendar and vCards have.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
16 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
17 * @copyright Copyright (C) 2011-2015 fruux GmbH (https://fruux.com/).
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
18 * @author Evert Pot (http://evertpot.com/)
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
19 * @license http://sabre.io/license/ Modified BSD License
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
20 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
21 class DateTimeParser {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
22
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
23 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
24 * Parses an iCalendar (rfc5545) formatted datetime and returns a DateTime object
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
25 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
26 * Specifying a reference timezone is optional. It will only be used
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
27 * if the non-UTC format is used. The argument is used as a reference, the
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
28 * returned DateTime object will still be in the UTC timezone.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
29 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
30 * @param string $dt
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
31 * @param DateTimeZone $tz
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
32 * @return DateTime
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
33 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
34 static public function parseDateTime($dt, DateTimeZone $tz = null) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
35
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
36 // Format is YYYYMMDD + "T" + hhmmss
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
37 $result = preg_match('/^([0-9]{4})([0-1][0-9])([0-3][0-9])T([0-2][0-9])([0-5][0-9])([0-5][0-9])([Z]?)$/',$dt,$matches);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
38
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
39 if (!$result) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
40 throw new LogicException('The supplied iCalendar datetime value is incorrect: ' . $dt);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
41 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
42
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
43 if ($matches[7]==='Z' || is_null($tz)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
44 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
45 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
46 $date = new DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3] . ' ' . $matches[4] . ':' . $matches[5] .':' . $matches[6], $tz);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
47
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
48 // Still resetting the timezone, to normalize everything to UTC
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
49 // $date->setTimeZone(new \DateTimeZone('UTC'));
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
50 return $date;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
51
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
52 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
53
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
54 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
55 * Parses an iCalendar (rfc5545) formatted date and returns a DateTime object.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
56 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
57 * @param string $date
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
58 * @param DateTimeZone $tz
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
59 * @return DateTime
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
60 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
61 static public function parseDate($date, DateTimeZone $tz = null) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
62
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
63 // Format is YYYYMMDD
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
64 $result = preg_match('/^([0-9]{4})([0-1][0-9])([0-3][0-9])$/',$date,$matches);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
65
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
66 if (!$result) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
67 throw new LogicException('The supplied iCalendar date value is incorrect: ' . $date);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
68 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
69
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
70 if (is_null($tz)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
71 $tz = new DateTimeZone('UTC');
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
72 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
73
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
74 $date = new DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3], $tz);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
75 return $date;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
76
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
77 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
78
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
79 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
80 * Parses an iCalendar (RFC5545) formatted duration value.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
81 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
82 * This method will either return a DateTimeInterval object, or a string
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
83 * suitable for strtotime or DateTime::modify.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
84 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
85 * @param string $duration
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
86 * @param bool $asString
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
87 * @return DateInterval|string
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
88 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
89 static public function parseDuration($duration, $asString = false) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
90
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
91 $result = preg_match('/^(?P<plusminus>\+|-)?P((?P<week>\d+)W)?((?P<day>\d+)D)?(T((?P<hour>\d+)H)?((?P<minute>\d+)M)?((?P<second>\d+)S)?)?$/', $duration, $matches);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
92 if (!$result) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
93 throw new LogicException('The supplied iCalendar duration value is incorrect: ' . $duration);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
94 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
95
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
96 if (!$asString) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
97 $invert = false;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
98 if ($matches['plusminus']==='-') {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
99 $invert = true;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
100 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
101
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
102
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
103 $parts = array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
104 'week',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
105 'day',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
106 'hour',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
107 'minute',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
108 'second',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
109 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
110 foreach($parts as $part) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
111 $matches[$part] = isset($matches[$part])&&$matches[$part]?(int)$matches[$part]:0;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
112 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
113
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
114
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
115 // We need to re-construct the $duration string, because weeks and
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
116 // days are not supported by DateInterval in the same string.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
117 $duration = 'P';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
118 $days = $matches['day'];
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
119 if ($matches['week']) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
120 $days+=$matches['week']*7;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
121 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
122 if ($days)
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
123 $duration.=$days . 'D';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
124
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
125 if ($matches['minute'] || $matches['second'] || $matches['hour']) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
126 $duration.='T';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
127
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
128 if ($matches['hour'])
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
129 $duration.=$matches['hour'].'H';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
130
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
131 if ($matches['minute'])
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
132 $duration.=$matches['minute'].'M';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
133
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
134 if ($matches['second'])
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
135 $duration.=$matches['second'].'S';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
136
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
137 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
138
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
139 if ($duration==='P') {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
140 $duration = 'PT0S';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
141 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
142 $iv = new DateInterval($duration);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
143 if ($invert) $iv->invert = true;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
144
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
145 return $iv;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
146
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
147 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
148
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
149
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
150
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
151 $parts = array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
152 'week',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
153 'day',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
154 'hour',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
155 'minute',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
156 'second',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
157 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
158
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
159 $newDur = '';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
160 foreach($parts as $part) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
161 if (isset($matches[$part]) && $matches[$part]) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
162 $newDur.=' '.$matches[$part] . ' ' . $part . 's';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
163 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
164 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
165
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
166 $newDur = ($matches['plusminus']==='-'?'-':'+') . trim($newDur);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
167 if ($newDur === '+') {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
168 $newDur = '+0 seconds';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
169 };
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
170 return $newDur;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
171
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
172 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
173
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
174 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
175 * Parses either a Date or DateTime, or Duration value.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
176 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
177 * @param string $date
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
178 * @param DateTimeZone|string $referenceTz
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
179 * @return DateTime|DateInterval
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
180 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
181 static public function parse($date, $referenceTz = null) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
182
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
183 if ($date[0]==='P' || ($date[0]==='-' && $date[1]==='P')) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
184 return self::parseDuration($date);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
185 } elseif (strlen($date)===8) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
186 return self::parseDate($date, $referenceTz);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
187 } else {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
188 return self::parseDateTime($date, $referenceTz);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
189 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
190
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
191 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
192
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
193 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
194 * This method parses a vCard date and or time value.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
195 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
196 * This can be used for the DATE, DATE-TIME, TIMESTAMP and
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
197 * DATE-AND-OR-TIME value.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
198 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
199 * This method returns an array, not a DateTime value.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
200 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
201 * The elements in the array are in the following order:
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
202 * year, month, date, hour, minute, second, timezone
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
203 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
204 * Almost any part of the string may be omitted. It's for example legal to
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
205 * just specify seconds, leave out the year, etc.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
206 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
207 * Timezone is either returned as 'Z' or as '+08:00'
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
208 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
209 * For any non-specified values null is returned.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
210 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
211 * List of date formats that are supported:
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
212 * YYYY
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
213 * YYYY-MM
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
214 * YYYYMMDD
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
215 * --MMDD
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
216 * ---DD
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
217 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
218 * YYYY-MM-DD
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
219 * --MM-DD
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
220 * ---DD
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
221 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
222 * List of supported time formats:
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
223 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
224 * HH
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
225 * HHMM
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
226 * HHMMSS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
227 * -MMSS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
228 * --SS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
229 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
230 * HH
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
231 * HH:MM
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
232 * HH:MM:SS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
233 * -MM:SS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
234 * --SS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
235 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
236 * A full basic-format date-time string looks like :
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
237 * 20130603T133901
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
238 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
239 * A full extended-format date-time string looks like :
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
240 * 2013-06-03T13:39:01
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
241 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
242 * Times may be postfixed by a timezone offset. This can be either 'Z' for
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
243 * UTC, or a string like -0500 or +1100.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
244 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
245 * @param string $date
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
246 * @return array
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
247 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
248 static public function parseVCardDateTime($date) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
249
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
250 $regex = '/^
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
251 (?: # date part
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
252 (?:
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
253 (?: (?P<year> [0-9]{4}) (?: -)?| --)
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
254 (?P<month> [0-9]{2})?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
255 |---)
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
256 (?P<date> [0-9]{2})?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
257 )?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
258 (?:T # time part
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
259 (?P<hour> [0-9]{2} | -)
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
260 (?P<minute> [0-9]{2} | -)?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
261 (?P<second> [0-9]{2})?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
262
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
263 (?P<timezone> # timezone offset
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
264
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
265 Z | (?: \+|-)(?: [0-9]{4})
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
266
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
267 )?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
268
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
269 )?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
270 $/x';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
271
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
272
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
273 if (!preg_match($regex, $date, $matches)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
274
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
275 // Attempting to parse the extended format.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
276 $regex = '/^
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
277 (?: # date part
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
278 (?: (?P<year> [0-9]{4}) - | -- )
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
279 (?P<month> [0-9]{2}) -
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
280 (?P<date> [0-9]{2})
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
281 )?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
282 (?:T # time part
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
283
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
284 (?: (?P<hour> [0-9]{2}) : | -)
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
285 (?: (?P<minute> [0-9]{2}) : | -)?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
286 (?P<second> [0-9]{2})?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
287
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
288 (?P<timezone> # timezone offset
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
289
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
290 Z | (?: \+|-)(?: [0-9]{2}:[0-9]{2})
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
291
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
292 )?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
293
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
294 )?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
295 $/x';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
296
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
297 if (!preg_match($regex, $date, $matches)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
298 throw new InvalidArgumentException('Invalid vCard date-time string: ' . $date);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
299 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
300
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
301 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
302 $parts = array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
303 'year',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
304 'month',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
305 'date',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
306 'hour',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
307 'minute',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
308 'second',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
309 'timezone'
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
310 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
311
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
312 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
313 foreach($parts as $part) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
314
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
315 if (empty($matches[$part])) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
316 $result[$part] = null;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
317 } elseif ($matches[$part] === '-' || $matches[$part] === '--') {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
318 $result[$part] = null;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
319 } else {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
320 $result[$part] = $matches[$part];
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
321 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
322
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
323 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
324
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
325 return $result;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
326
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
327 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
328
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
329 /**
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
330 * This method parses a vCard TIME value.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
331 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
332 * This method returns an array, not a DateTime value.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
333 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
334 * The elements in the array are in the following order:
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
335 * hour, minute, second, timezone
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
336 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
337 * Almost any part of the string may be omitted. It's for example legal to
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
338 * just specify seconds, leave out the hour etc.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
339 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
340 * Timezone is either returned as 'Z' or as '+08:00'
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
341 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
342 * For any non-specified values null is returned.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
343 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
344 * List of supported time formats:
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
345 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
346 * HH
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
347 * HHMM
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
348 * HHMMSS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
349 * -MMSS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
350 * --SS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
351 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
352 * HH
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
353 * HH:MM
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
354 * HH:MM:SS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
355 * -MM:SS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
356 * --SS
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
357 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
358 * A full basic-format time string looks like :
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
359 * 133901
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
360 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
361 * A full extended-format time string looks like :
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
362 * 13:39:01
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
363 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
364 * Times may be postfixed by a timezone offset. This can be either 'Z' for
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
365 * UTC, or a string like -0500 or +11:00.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
366 *
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
367 * @param string $date
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
368 * @return array
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
369 */
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
370 static public function parseVCardTime($date) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
371
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
372 $regex = '/^
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
373 (?P<hour> [0-9]{2} | -)
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
374 (?P<minute> [0-9]{2} | -)?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
375 (?P<second> [0-9]{2})?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
376
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
377 (?P<timezone> # timezone offset
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
378
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
379 Z | (?: \+|-)(?: [0-9]{4})
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
380
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
381 )?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
382 $/x';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
383
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
384
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
385 if (!preg_match($regex, $date, $matches)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
386
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
387 // Attempting to parse the extended format.
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
388 $regex = '/^
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
389 (?: (?P<hour> [0-9]{2}) : | -)
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
390 (?: (?P<minute> [0-9]{2}) : | -)?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
391 (?P<second> [0-9]{2})?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
392
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
393 (?P<timezone> # timezone offset
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
394
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
395 Z | (?: \+|-)(?: [0-9]{2}:[0-9]{2})
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
396
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
397 )?
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
398 $/x';
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
399
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
400 if (!preg_match($regex, $date, $matches)) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
401 throw new InvalidArgumentException('Invalid vCard time string: ' . $date);
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
402 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
403
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
404 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
405 $parts = array(
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
406 'hour',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
407 'minute',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
408 'second',
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
409 'timezone'
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
410 );
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
411
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
412 $result = array();
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
413 foreach($parts as $part) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
414
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
415 if (empty($matches[$part])) {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
416 $result[$part] = null;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
417 } elseif ($matches[$part] === '-') {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
418 $result[$part] = null;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
419 } else {
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
420 $result[$part] = $matches[$part];
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
421 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
422
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
423 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
424
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
425 return $result;
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
426
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
427 }
430dbd5346f7 vendor sabre as distributed
Charlie Root
parents:
diff changeset
428 }