aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat')
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php46
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfWeekTransformer.php59
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php46
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayTransformer.php46
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php356
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php62
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php62
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php61
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php64
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php30
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MinuteTransformer.php48
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php143
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php64
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/SecondTransformer.php48
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php99
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php64
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/YearTransformer.php50
17 files changed, 0 insertions, 1348 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php
deleted file mode 100644
index 1a9601d8..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/AmPmTransformer.php
+++ /dev/null
@@ -1,46 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for AM/PM markers format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class AmPmTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 return $dateTime->format('A');
27 }
28
29 /**
30 * {@inheritDoc}
31 */
32 public function getReverseMatchingRegExp($length)
33 {
34 return 'AM|PM';
35 }
36
37 /**
38 * {@inheritDoc}
39 */
40 public function extractDateOptions($matched, $length)
41 {
42 return array(
43 'marker' => $matched
44 );
45 }
46}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfWeekTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfWeekTransformer.php
deleted file mode 100644
index ee53a4e6..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfWeekTransformer.php
+++ /dev/null
@@ -1,59 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for day of week format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class DayOfWeekTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $dayOfWeek = $dateTime->format('l');
27 switch ($length) {
28 case 4:
29 return $dayOfWeek;
30 case 5:
31 return $dayOfWeek[0];
32 default:
33 return substr($dayOfWeek, 0, 3);
34 }
35 }
36
37 /**
38 * {@inheritDoc}
39 */
40 public function getReverseMatchingRegExp($length)
41 {
42 switch ($length) {
43 case 4:
44 return 'Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday';
45 case 5:
46 return '[MTWFS]';
47 default:
48 return 'Mon|Tue|Wed|Thu|Fri|Sat|Sun';
49 }
50 }
51
52 /**
53 * {@inheritDoc}
54 */
55 public function extractDateOptions($matched, $length)
56 {
57 return array();
58 }
59}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php
deleted file mode 100644
index 2c33888c..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayOfYearTransformer.php
+++ /dev/null
@@ -1,46 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for day of year format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class DayOfYearTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $dayOfYear = $dateTime->format('z') + 1;
27
28 return $this->padLeft($dayOfYear, $length);
29 }
30
31 /**
32 * {@inheritDoc}
33 */
34 public function getReverseMatchingRegExp($length)
35 {
36 return '\d{'.$length.'}';
37 }
38
39 /**
40 * {@inheritDoc}
41 */
42 public function extractDateOptions($matched, $length)
43 {
44 return array();
45 }
46}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayTransformer.php
deleted file mode 100644
index 19d30e74..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/DayTransformer.php
+++ /dev/null
@@ -1,46 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for day format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class DayTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 return $this->padLeft($dateTime->format('j'), $length);
27 }
28
29 /**
30 * {@inheritDoc}
31 */
32 public function getReverseMatchingRegExp($length)
33 {
34 return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
35 }
36
37 /**
38 * {@inheritDoc}
39 */
40 public function extractDateOptions($matched, $length)
41 {
42 return array(
43 'day' => (int) $matched,
44 );
45 }
46}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php
deleted file mode 100644
index b89db363..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php
+++ /dev/null
@@ -1,356 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14use Symfony\Component\Intl\Exception\NotImplementedException;
15use Symfony\Component\Intl\Globals\IntlGlobals;
16use Symfony\Component\Intl\DateFormatter\DateFormat\MonthTransformer;
17
18/**
19 * Parser and formatter for date formats
20 *
21 * @author Igor Wiedler <igor@wiedler.ch>
22 */
23class FullTransformer
24{
25 private $quoteMatch = "'(?:[^']+|'')*'";
26 private $implementedChars = 'MLydQqhDEaHkKmsz';
27 private $notImplementedChars = 'GYuwWFgecSAZvVW';
28 private $regExp;
29
30 /**
31 * @var Transformer[]
32 */
33 private $transformers;
34
35 private $pattern;
36 private $timezone;
37
38 /**
39 * Constructor
40 *
41 * @param string $pattern The pattern to be used to format and/or parse values
42 * @param string $timezone The timezone to perform the date/time calculations
43 */
44 public function __construct($pattern, $timezone)
45 {
46 $this->pattern = $pattern;
47 $this->timezone = $timezone;
48
49 $implementedCharsMatch = $this->buildCharsMatch($this->implementedChars);
50 $notImplementedCharsMatch = $this->buildCharsMatch($this->notImplementedChars);
51 $this->regExp = "/($this->quoteMatch|$implementedCharsMatch|$notImplementedCharsMatch)/";
52
53 $this->transformers = array(
54 'M' => new MonthTransformer(),
55 'L' => new MonthTransformer(),
56 'y' => new YearTransformer(),
57 'd' => new DayTransformer(),
58 'q' => new QuarterTransformer(),
59 'Q' => new QuarterTransformer(),
60 'h' => new Hour1201Transformer(),
61 'D' => new DayOfYearTransformer(),
62 'E' => new DayOfWeekTransformer(),
63 'a' => new AmPmTransformer(),
64 'H' => new Hour2400Transformer(),
65 'K' => new Hour1200Transformer(),
66 'k' => new Hour2401Transformer(),
67 'm' => new MinuteTransformer(),
68 's' => new SecondTransformer(),
69 'z' => new TimeZoneTransformer(),
70 );
71 }
72
73 /**
74 * Return the array of Transformer objects
75 *
76 * @return Transformer[] Associative array of Transformer objects (format char => Transformer)
77 */
78 public function getTransformers()
79 {
80 return $this->transformers;
81 }
82
83 /**
84 * Format a DateTime using ICU dateformat pattern
85 *
86 * @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
87 *
88 * @return string The formatted value
89 */
90 public function format(\DateTime $dateTime)
91 {
92 $that = $this;
93
94 $formatted = preg_replace_callback($this->regExp, function($matches) use ($that, $dateTime) {
95 return $that->formatReplace($matches[0], $dateTime);
96 }, $this->pattern);
97
98 return $formatted;
99 }
100
101 /**
102 * Return the formatted ICU value for the matched date characters
103 *
104 * @param string $dateChars The date characters to be replaced with a formatted ICU value
105 * @param DateTime $dateTime A DateTime object to be used to generate the formatted value
106 *
107 * @return string The formatted value
108 *
109 * @throws NotImplementedException When it encounters a not implemented date character
110 */
111 public function formatReplace($dateChars, $dateTime)
112 {
113 $length = strlen($dateChars);
114
115 if ($this->isQuoteMatch($dateChars)) {
116 return $this->replaceQuoteMatch($dateChars);
117 }
118
119 if (isset($this->transformers[$dateChars[0]])) {
120 $transformer = $this->transformers[$dateChars[0]];
121
122 return $transformer->format($dateTime, $length);
123 }
124
125 // handle unimplemented characters
126 if (false !== strpos($this->notImplementedChars, $dateChars[0])) {
127 throw new NotImplementedException(sprintf("Unimplemented date character '%s' in format '%s'", $dateChars[0], $this->pattern));
128 }
129 }
130
131 /**
132 * Parse a pattern based string to a timestamp value
133 *
134 * @param \DateTime $dateTime A configured DateTime object to use to perform the date calculation
135 * @param string $value String to convert to a time value
136 *
137 * @return int The corresponding Unix timestamp
138 *
139 * @throws \InvalidArgumentException When the value can not be matched with pattern
140 */
141 public function parse(\DateTime $dateTime, $value)
142 {
143 $reverseMatchingRegExp = $this->getReverseMatchingRegExp($this->pattern);
144 $reverseMatchingRegExp = '/^'.$reverseMatchingRegExp.'$/';
145
146 $options = array();
147
148 if (preg_match($reverseMatchingRegExp, $value, $matches)) {
149 $matches = $this->normalizeArray($matches);
150
151 foreach ($this->transformers as $char => $transformer) {
152 if (isset($matches[$char])) {
153 $length = strlen($matches[$char]['pattern']);
154 $options = array_merge($options, $transformer->extractDateOptions($matches[$char]['value'], $length));
155 }
156 }
157
158 // reset error code and message
159 IntlGlobals::setError(IntlGlobals::U_ZERO_ERROR);
160
161 return $this->calculateUnixTimestamp($dateTime, $options);
162 }
163
164 // behave like the intl extension
165 IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
166
167 return false;
168 }
169
170 /**
171 * Retrieve a regular expression to match with a formatted value.
172 *
173 * @param string $pattern The pattern to create the reverse matching regular expression
174 *
175 * @return string The reverse matching regular expression with named captures being formed by the
176 * transformer index in the $transformer array
177 */
178 public function getReverseMatchingRegExp($pattern)
179 {
180 $that = $this;
181
182 $escapedPattern = preg_quote($pattern, '/');
183
184 // ICU 4.8 recognizes slash ("/") in a value to be parsed as a dash ("-") and vice-versa
185 // when parsing a date/time value
186 $escapedPattern = preg_replace('/\\\[\-|\/]/', '[\/\-]', $escapedPattern);
187
188 $reverseMatchingRegExp = preg_replace_callback($this->regExp, function($matches) use ($that) {
189 $length = strlen($matches[0]);
190 $transformerIndex = $matches[0][0];
191
192 $dateChars = $matches[0];
193 if ($that->isQuoteMatch($dateChars)) {
194 return $that->replaceQuoteMatch($dateChars);
195 }
196
197 $transformers = $that->getTransformers();
198 if (isset($transformers[$transformerIndex])) {
199 $transformer = $transformers[$transformerIndex];
200 $captureName = str_repeat($transformerIndex, $length);
201
202 return "(?P<$captureName>".$transformer->getReverseMatchingRegExp($length).')';
203 }
204 }, $escapedPattern);
205
206 return $reverseMatchingRegExp;
207 }
208
209 /**
210 * Check if the first char of a string is a single quote
211 *
212 * @param string $quoteMatch The string to check
213 *
214 * @return Boolean true if matches, false otherwise
215 */
216 public function isQuoteMatch($quoteMatch)
217 {
218 return ("'" === $quoteMatch[0]);
219 }
220
221 /**
222 * Replaces single quotes at the start or end of a string with two single quotes
223 *
224 * @param string $quoteMatch The string to replace the quotes
225 *
226 * @return string A string with the single quotes replaced
227 */
228 public function replaceQuoteMatch($quoteMatch)
229 {
230 if (preg_match("/^'+$/", $quoteMatch)) {
231 return str_replace("''", "'", $quoteMatch);
232 }
233
234 return str_replace("''", "'", substr($quoteMatch, 1, -1));
235 }
236
237 /**
238 * Builds a chars match regular expression
239 *
240 * @param string $specialChars A string of chars to build the regular expression
241 *
242 * @return string The chars match regular expression
243 */
244 protected function buildCharsMatch($specialChars)
245 {
246 $specialCharsArray = str_split($specialChars);
247
248 $specialCharsMatch = implode('|', array_map(function($char) {
249 return $char.'+';
250 }, $specialCharsArray));
251
252 return $specialCharsMatch;
253 }
254
255 /**
256 * Normalize a preg_replace match array, removing the numeric keys and returning an associative array
257 * with the value and pattern values for the matched Transformer
258 *
259 * @param array $data
260 *
261 * @return array
262 */
263 protected function normalizeArray(array $data)
264 {
265 $ret = array();
266
267 foreach ($data as $key => $value) {
268 if (!is_string($key)) {
269 continue;
270 }
271
272 $ret[$key[0]] = array(
273 'value' => $value,
274 'pattern' => $key
275 );
276 }
277
278 return $ret;
279 }
280
281 /**
282 * Calculates the Unix timestamp based on the matched values by the reverse matching regular
283 * expression of parse()
284 *
285 * @param \DateTime $dateTime The DateTime object to be used to calculate the timestamp
286 * @param array $options An array with the matched values to be used to calculate the timestamp
287 *
288 * @return Boolean|int The calculated timestamp or false if matched date is invalid
289 */
290 protected function calculateUnixTimestamp(\DateTime $dateTime, array $options)
291 {
292 $options = $this->getDefaultValueForOptions($options);
293
294 $year = $options['year'];
295 $month = $options['month'];
296 $day = $options['day'];
297 $hour = $options['hour'];
298 $hourInstance = $options['hourInstance'];
299 $minute = $options['minute'];
300 $second = $options['second'];
301 $marker = $options['marker'];
302 $timezone = $options['timezone'];
303
304 // If month is false, return immediately (intl behavior)
305 if (false === $month) {
306 IntlGlobals::setError(IntlGlobals::U_PARSE_ERROR, 'Date parsing failed');
307
308 return false;
309 }
310
311 // Normalize hour
312 if ($hourInstance instanceof HourTransformer) {
313 $hour = $hourInstance->normalizeHour($hour, $marker);
314 }
315
316 // Set the timezone if different from the default one
317 if (null !== $timezone && $timezone !== $this->timezone) {
318 $dateTime->setTimezone(new \DateTimeZone($timezone));
319 }
320
321 // Normalize yy year
322 preg_match_all($this->regExp, $this->pattern, $matches);
323 if (in_array('yy', $matches[0])) {
324 $dateTime->setTimestamp(time());
325 $year = $year > $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year;
326 }
327
328 $dateTime->setDate($year, $month, $day);
329 $dateTime->setTime($hour, $minute, $second);
330
331 return $dateTime->getTimestamp();
332 }
333
334 /**
335 * Add sensible default values for missing items in the extracted date/time options array. The values
336 * are base in the beginning of the Unix era
337 *
338 * @param array $options
339 *
340 * @return array
341 */
342 private function getDefaultValueForOptions(array $options)
343 {
344 return array(
345 'year' => isset($options['year']) ? $options['year'] : 1970,
346 'month' => isset($options['month']) ? $options['month'] : 1,
347 'day' => isset($options['day']) ? $options['day'] : 1,
348 'hour' => isset($options['hour']) ? $options['hour'] : 0,
349 'hourInstance' => isset($options['hourInstance']) ? $options['hourInstance'] : null,
350 'minute' => isset($options['minute']) ? $options['minute'] : 0,
351 'second' => isset($options['second']) ? $options['second'] : 0,
352 'marker' => isset($options['marker']) ? $options['marker'] : null,
353 'timezone' => isset($options['timezone']) ? $options['timezone'] : null,
354 );
355 }
356}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php
deleted file mode 100644
index 8c8f5ef4..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1200Transformer.php
+++ /dev/null
@@ -1,62 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for 12 hour format (0-11)
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class Hour1200Transformer extends HourTransformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $hourOfDay = $dateTime->format('g');
27 $hourOfDay = '12' == $hourOfDay ? '0' : $hourOfDay;
28
29 return $this->padLeft($hourOfDay, $length);
30 }
31
32 /**
33 * {@inheritDoc}
34 */
35 public function normalizeHour($hour, $marker = null)
36 {
37 if ('PM' === $marker) {
38 $hour += 12;
39 }
40
41 return $hour;
42 }
43
44 /**
45 * {@inheritDoc}
46 */
47 public function getReverseMatchingRegExp($length)
48 {
49 return '\d{1,2}';
50 }
51
52 /**
53 * {@inheritDoc}
54 */
55 public function extractDateOptions($matched, $length)
56 {
57 return array(
58 'hour' => (int) $matched,
59 'hourInstance' => $this
60 );
61 }
62}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php
deleted file mode 100644
index a8c43702..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour1201Transformer.php
+++ /dev/null
@@ -1,62 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for 12 hour format (1-12)
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class Hour1201Transformer extends HourTransformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 return $this->padLeft($dateTime->format('g'), $length);
27 }
28
29 /**
30 * {@inheritDoc}
31 */
32 public function normalizeHour($hour, $marker = null)
33 {
34 if ('PM' !== $marker && 12 === $hour) {
35 $hour = 0;
36 } elseif ('PM' === $marker && 12 !== $hour) {
37 // If PM and hour is not 12 (1-12), sum 12 hour
38 $hour += 12;
39 }
40
41 return $hour;
42 }
43
44 /**
45 * {@inheritDoc}
46 */
47 public function getReverseMatchingRegExp($length)
48 {
49 return '\d{1,2}';
50 }
51
52 /**
53 * {@inheritDoc}
54 */
55 public function extractDateOptions($matched, $length)
56 {
57 return array(
58 'hour' => (int) $matched,
59 'hourInstance' => $this
60 );
61 }
62}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php
deleted file mode 100644
index 8f22da13..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php
+++ /dev/null
@@ -1,61 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for 24 hour format (0-23)
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class Hour2400Transformer extends HourTransformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 return $this->padLeft($dateTime->format('G'), $length);
27 }
28
29 /**
30 * {@inheritDoc}
31 */
32 public function normalizeHour($hour, $marker = null)
33 {
34 if ('AM' == $marker) {
35 $hour = 0;
36 } elseif ('PM' == $marker) {
37 $hour = 12;
38 }
39
40 return $hour;
41 }
42
43 /**
44 * {@inheritDoc}
45 */
46 public function getReverseMatchingRegExp($length)
47 {
48 return '\d{1,2}';
49 }
50
51 /**
52 * {@inheritDoc}
53 */
54 public function extractDateOptions($matched, $length)
55 {
56 return array(
57 'hour' => (int) $matched,
58 'hourInstance' => $this
59 );
60 }
61}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php
deleted file mode 100644
index b0f486b9..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2401Transformer.php
+++ /dev/null
@@ -1,64 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for 24 hour format (1-24)
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class Hour2401Transformer extends HourTransformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $hourOfDay = $dateTime->format('G');
27 $hourOfDay = ('0' == $hourOfDay) ? '24' : $hourOfDay;
28
29 return $this->padLeft($hourOfDay, $length);
30 }
31
32 /**
33 * {@inheritDoc}
34 */
35 public function normalizeHour($hour, $marker = null)
36 {
37 if ((null === $marker && 24 === $hour) || 'AM' == $marker) {
38 $hour = 0;
39 } elseif ('PM' == $marker) {
40 $hour = 12;
41 }
42
43 return $hour;
44 }
45
46 /**
47 * {@inheritDoc}
48 */
49 public function getReverseMatchingRegExp($length)
50 {
51 return '\d{1,2}';
52 }
53
54 /**
55 * {@inheritDoc}
56 */
57 public function extractDateOptions($matched, $length)
58 {
59 return array(
60 'hour' => (int) $matched,
61 'hourInstance' => $this
62 );
63 }
64}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php
deleted file mode 100644
index 51097d92..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/HourTransformer.php
+++ /dev/null
@@ -1,30 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Base class for hour transformers
16 *
17 * @author Eriksen Costa <eriksen.costa@infranology.com.br>
18 */
19abstract class HourTransformer extends Transformer
20{
21 /**
22 * Returns a normalized hour value suitable for the hour transformer type
23 *
24 * @param int $hour The hour value
25 * @param string $marker An optional AM/PM marker
26 *
27 * @return int The normalized hour value
28 */
29 abstract public function normalizeHour($hour, $marker = null);
30}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MinuteTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MinuteTransformer.php
deleted file mode 100644
index b48de292..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MinuteTransformer.php
+++ /dev/null
@@ -1,48 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for minute format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class MinuteTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $minuteOfHour = (int) $dateTime->format('i');
27
28 return $this->padLeft($minuteOfHour, $length);
29 }
30
31 /**
32 * {@inheritDoc}
33 */
34 public function getReverseMatchingRegExp($length)
35 {
36 return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
37 }
38
39 /**
40 * {@inheritDoc}
41 */
42 public function extractDateOptions($matched, $length)
43 {
44 return array(
45 'minute' => (int) $matched,
46 );
47 }
48}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php
deleted file mode 100644
index 30c15af7..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/MonthTransformer.php
+++ /dev/null
@@ -1,143 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for month format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class MonthTransformer extends Transformer
20{
21 /**
22 * @var array
23 */
24 protected static $months = array(
25 'January',
26 'February',
27 'March',
28 'April',
29 'May',
30 'June',
31 'July',
32 'August',
33 'September',
34 'October',
35 'November',
36 'December'
37 );
38
39 /**
40 * Short months names (first 3 letters)
41 * @var array
42 */
43 protected static $shortMonths = array();
44
45 /**
46 * Flipped $months array, $name => $index
47 * @var array
48 */
49 protected static $flippedMonths = array();
50
51 /**
52 * Flipped $shortMonths array, $name => $index
53 * @var array
54 */
55 protected static $flippedShortMonths = array();
56
57 /**
58 * Constructor
59 */
60 public function __construct()
61 {
62 if (0 === count(self::$shortMonths)) {
63 self::$shortMonths = array_map(function($month) {
64 return substr($month, 0, 3);
65 }, self::$months);
66
67 self::$flippedMonths = array_flip(self::$months);
68 self::$flippedShortMonths = array_flip(self::$shortMonths);
69 }
70 }
71
72 /**
73 * {@inheritDoc}
74 */
75 public function format(\DateTime $dateTime, $length)
76 {
77 $matchLengthMap = array(
78 1 => 'n',
79 2 => 'm',
80 3 => 'M',
81 4 => 'F',
82 );
83
84 if (isset($matchLengthMap[$length])) {
85 return $dateTime->format($matchLengthMap[$length]);
86 }
87
88 if (5 === $length) {
89 return substr($dateTime->format('M'), 0, 1);
90 }
91
92 return $this->padLeft($dateTime->format('m'), $length);
93 }
94
95 /**
96 * {@inheritDoc}
97 */
98 public function getReverseMatchingRegExp($length)
99 {
100 switch ($length) {
101 case 1:
102 $regExp = '\d{1,2}';
103 break;
104 case 3:
105 $regExp = implode('|', self::$shortMonths);
106 break;
107 case 4:
108 $regExp = implode('|', self::$months);
109 break;
110 case 5:
111 $regExp = '[JFMASOND]';
112 break;
113 default:
114 $regExp = '\d{'.$length.'}';
115 break;
116 }
117
118 return $regExp;
119 }
120
121 /**
122 * {@inheritDoc}
123 */
124 public function extractDateOptions($matched, $length)
125 {
126 if (!is_numeric($matched)) {
127 if (3 === $length) {
128 $matched = self::$flippedShortMonths[$matched] + 1;
129 } elseif (4 === $length) {
130 $matched = self::$flippedMonths[$matched] + 1;
131 } elseif (5 === $length) {
132 // IntlDateFormatter::parse() always returns false for MMMMM or LLLLL
133 $matched = false;
134 }
135 } else {
136 $matched = (int) $matched;
137 }
138
139 return array(
140 'month' => $matched,
141 );
142 }
143}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php
deleted file mode 100644
index 8e83dc75..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php
+++ /dev/null
@@ -1,64 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for quarter format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class QuarterTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $month = (int) $dateTime->format('n');
27 $quarter = (int) floor(($month - 1) / 3) + 1;
28 switch ($length) {
29 case 1:
30 case 2:
31 return $this->padLeft($quarter, $length);
32 case 3:
33 return 'Q'.$quarter;
34 default:
35 $map = array(1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter');
36
37 return $map[$quarter];
38 }
39 }
40
41 /**
42 * {@inheritDoc}
43 */
44 public function getReverseMatchingRegExp($length)
45 {
46 switch ($length) {
47 case 1:
48 case 2:
49 return '\d{'.$length.'}';
50 case 3:
51 return 'Q\d';
52 default:
53 return '(?:1st|2nd|3rd|4th) quarter';
54 }
55 }
56
57 /**
58 * {@inheritDoc}
59 */
60 public function extractDateOptions($matched, $length)
61 {
62 return array();
63 }
64}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/SecondTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/SecondTransformer.php
deleted file mode 100644
index ccbcdb41..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/SecondTransformer.php
+++ /dev/null
@@ -1,48 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for the second format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class SecondTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 $secondOfMinute = (int) $dateTime->format('s');
27
28 return $this->padLeft($secondOfMinute, $length);
29 }
30
31 /**
32 * {@inheritDoc}
33 */
34 public function getReverseMatchingRegExp($length)
35 {
36 return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
37 }
38
39 /**
40 * {@inheritDoc}
41 */
42 public function extractDateOptions($matched, $length)
43 {
44 return array(
45 'second' => (int) $matched,
46 );
47 }
48}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php
deleted file mode 100644
index 7d74bd36..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/TimeZoneTransformer.php
+++ /dev/null
@@ -1,99 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14use Symfony\Component\Intl\Exception\NotImplementedException;
15
16/**
17 * Parser and formatter for time zone format
18 *
19 * @author Igor Wiedler <igor@wiedler.ch>
20 */
21class TimeZoneTransformer extends Transformer
22{
23 /**
24 * {@inheritDoc}
25 *
26 * @throws NotImplementedException When time zone is different than UTC or GMT (Etc/GMT)
27 */
28 public function format(\DateTime $dateTime, $length)
29 {
30 $timeZone = substr($dateTime->getTimezone()->getName(), 0, 3);
31
32 if (!in_array($timeZone, array('Etc', 'UTC'))) {
33 throw new NotImplementedException('Time zone different than GMT or UTC is not supported as a formatting output.');
34 }
35
36 // From ICU >= 4.8, the zero offset is not more used, example: GMT instead of GMT+00:00
37 $format = (0 !== (int) $dateTime->format('O')) ? '\G\M\TP' : '\G\M\T';
38
39 return $dateTime->format($format);
40 }
41
42 /**
43 * {@inheritDoc}
44 */
45 public function getReverseMatchingRegExp($length)
46 {
47 return 'GMT[+-]\d{2}:?\d{2}';
48 }
49
50 /**
51 * {@inheritDoc}
52 */
53 public function extractDateOptions($matched, $length)
54 {
55 return array(
56 'timezone' => self::getEtcTimeZoneId($matched)
57 );
58 }
59
60 /**
61 * Get an Etc/GMT timezone identifier for the specified timezone
62 *
63 * The PHP documentation for timezones states to not use the 'Other' time zones because them exists
64 * "for backwards compatibility". However all Etc/GMT time zones are in the tz database 'etcetera' file,
65 * which indicates they are not deprecated (neither are old names).
66 *
67 * Only GMT, Etc/Universal, Etc/Zulu, Etc/Greenwich, Etc/GMT-0, Etc/GMT+0 and Etc/GMT0 are old names and
68 * are linked to Etc/GMT or Etc/UTC.
69 *
70 * @param string $formattedTimeZone A GMT timezone string (GMT-03:00, e.g.)
71 *
72 * @return string A timezone identifier
73 *
74 * @see http://php.net/manual/en/timezones.others.php
75 * @see http://www.twinsun.com/tz/tz-link.htm
76 *
77 * @throws NotImplementedException When the GMT time zone have minutes offset different than zero
78 * @throws \InvalidArgumentException When the value can not be matched with pattern
79 */
80 public static function getEtcTimeZoneId($formattedTimeZone)
81 {
82 if (preg_match('/GMT(?P<signal>[+-])(?P<hours>\d{2}):?(?P<minutes>\d{2})/', $formattedTimeZone, $matches)) {
83 $hours = (int) $matches['hours'];
84 $minutes = (int) $matches['minutes'];
85 $signal = $matches['signal'] == '-' ? '+' : '-';
86
87 if (0 < $minutes) {
88 throw new NotImplementedException(sprintf(
89 'It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: %s.',
90 $formattedTimeZone
91 ));
92 }
93
94 return 'Etc/GMT'.($hours !== 0 ? $signal.$hours : '');
95 }
96
97 throw new \InvalidArgumentException('The GMT time zone \'%s\' does not match with the supported formats GMT[+-]HH:MM or GMT[+-]HHMM.');
98 }
99}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php
deleted file mode 100644
index 0e67f8ae..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Transformer.php
+++ /dev/null
@@ -1,64 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for date formats
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19abstract class Transformer
20{
21 /**
22 * Format a value using a configured DateTime as date/time source
23 *
24 *
25 * @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
26 * @param int $length The formatted value string length
27 *
28 * @return string The formatted value
29 */
30 abstract public function format(\DateTime $dateTime, $length);
31
32 /**
33 * Returns a reverse matching regular expression of a string generated by format()
34 *
35 * @param int $length The length of the value to be reverse matched
36 *
37 * @return string The reverse matching regular expression
38 */
39 abstract public function getReverseMatchingRegExp($length);
40
41 /**
42 * Extract date options from a matched value returned by the processing of the reverse matching
43 * regular expression
44 *
45 * @param string $matched The matched value
46 * @param int $length The length of the Transformer pattern string
47 *
48 * @return array An associative array
49 */
50 abstract public function extractDateOptions($matched, $length);
51
52 /**
53 * Pad a string with zeros to the left
54 *
55 * @param string $value The string to be padded
56 * @param int $length The length to pad
57 *
58 * @return string The padded string
59 */
60 protected function padLeft($value, $length)
61 {
62 return str_pad($value, $length, '0', STR_PAD_LEFT);
63 }
64}
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/YearTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/YearTransformer.php
deleted file mode 100644
index c3bd699d..00000000
--- a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/YearTransformer.php
+++ /dev/null
@@ -1,50 +0,0 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\DateFormatter\DateFormat;
13
14/**
15 * Parser and formatter for year format
16 *
17 * @author Igor Wiedler <igor@wiedler.ch>
18 */
19class YearTransformer extends Transformer
20{
21 /**
22 * {@inheritDoc}
23 */
24 public function format(\DateTime $dateTime, $length)
25 {
26 if (2 === $length) {
27 return $dateTime->format('y');
28 }
29
30 return $this->padLeft($dateTime->format('Y'), $length);
31 }
32
33 /**
34 * {@inheritDoc}
35 */
36 public function getReverseMatchingRegExp($length)
37 {
38 return 2 === $length ? '\d{2}' : '\d{4}';
39 }
40
41 /**
42 * {@inheritDoc}
43 */
44 public function extractDateOptions($matched, $length)
45 {
46 return array(
47 'year' => (int) $matched,
48 );
49 }
50}