login consent app sql
This commit is contained in:
48
vendor/symfony/polyfill-intl-icu/DateFormat/AmPmTransformer.php
vendored
Normal file
48
vendor/symfony/polyfill-intl-icu/DateFormat/AmPmTransformer.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for AM/PM markers format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class AmPmTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
return $dateTime->format('A');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return 'AM|PM';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'marker' => $matched,
|
||||
];
|
||||
}
|
||||
}
|
65
vendor/symfony/polyfill-intl-icu/DateFormat/DayOfWeekTransformer.php
vendored
Normal file
65
vendor/symfony/polyfill-intl-icu/DateFormat/DayOfWeekTransformer.php
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for day of week format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DayOfWeekTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$dayOfWeek = $dateTime->format('l');
|
||||
switch ($length) {
|
||||
case 4:
|
||||
return $dayOfWeek;
|
||||
case 5:
|
||||
return $dayOfWeek[0];
|
||||
case 6:
|
||||
return substr($dayOfWeek, 0, 2);
|
||||
default:
|
||||
return substr($dayOfWeek, 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
switch ($length) {
|
||||
case 4:
|
||||
return 'Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday';
|
||||
case 5:
|
||||
return '[MTWFS]';
|
||||
case 6:
|
||||
return 'Mo|Tu|We|Th|Fr|Sa|Su';
|
||||
default:
|
||||
return 'Mon|Tue|Wed|Thu|Fri|Sat|Sun';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
48
vendor/symfony/polyfill-intl-icu/DateFormat/DayOfYearTransformer.php
vendored
Normal file
48
vendor/symfony/polyfill-intl-icu/DateFormat/DayOfYearTransformer.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for day of year format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DayOfYearTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$dayOfYear = (int) $dateTime->format('z') + 1;
|
||||
|
||||
return $this->padLeft($dayOfYear, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return '\d{'.$length.'}';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
48
vendor/symfony/polyfill-intl-icu/DateFormat/DayTransformer.php
vendored
Normal file
48
vendor/symfony/polyfill-intl-icu/DateFormat/DayTransformer.php
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for day format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class DayTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
return $this->padLeft($dateTime->format('j'), $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return 1 === $length ? '\d{1,2}' : '\d{1,'.$length.'}';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'day' => (int) $matched,
|
||||
];
|
||||
}
|
||||
}
|
312
vendor/symfony/polyfill-intl-icu/DateFormat/FullTransformer.php
vendored
Normal file
312
vendor/symfony/polyfill-intl-icu/DateFormat/FullTransformer.php
vendored
Normal file
@ -0,0 +1,312 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
use Symfony\Polyfill\Intl\Icu\Exception\NotImplementedException;
|
||||
use Symfony\Polyfill\Intl\Icu\Icu;
|
||||
|
||||
/**
|
||||
* Parser and formatter for date formats.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class FullTransformer
|
||||
{
|
||||
private $quoteMatch = "'(?:[^']+|'')*'";
|
||||
private $implementedChars = 'MLydQqhDEaHkKmsz';
|
||||
private $notImplementedChars = 'GYuwWFgecSAZvVW';
|
||||
private $regExp;
|
||||
|
||||
/**
|
||||
* @var Transformer[]
|
||||
*/
|
||||
private $transformers;
|
||||
|
||||
private $pattern;
|
||||
private $timezone;
|
||||
|
||||
/**
|
||||
* @param string $pattern The pattern to be used to format and/or parse values
|
||||
* @param string $timezone The timezone to perform the date/time calculations
|
||||
*/
|
||||
public function __construct(string $pattern, string $timezone)
|
||||
{
|
||||
$this->pattern = $pattern;
|
||||
$this->timezone = $timezone;
|
||||
|
||||
$implementedCharsMatch = $this->buildCharsMatch($this->implementedChars);
|
||||
$notImplementedCharsMatch = $this->buildCharsMatch($this->notImplementedChars);
|
||||
$this->regExp = "/($this->quoteMatch|$implementedCharsMatch|$notImplementedCharsMatch)/";
|
||||
|
||||
$this->transformers = [
|
||||
'M' => new MonthTransformer(),
|
||||
'L' => new MonthTransformer(),
|
||||
'y' => new YearTransformer(),
|
||||
'd' => new DayTransformer(),
|
||||
'q' => new QuarterTransformer(),
|
||||
'Q' => new QuarterTransformer(),
|
||||
'h' => new Hour1201Transformer(),
|
||||
'D' => new DayOfYearTransformer(),
|
||||
'E' => new DayOfWeekTransformer(),
|
||||
'a' => new AmPmTransformer(),
|
||||
'H' => new Hour2400Transformer(),
|
||||
'K' => new Hour1200Transformer(),
|
||||
'k' => new Hour2401Transformer(),
|
||||
'm' => new MinuteTransformer(),
|
||||
's' => new SecondTransformer(),
|
||||
'z' => new TimezoneTransformer(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a DateTime using ICU dateformat pattern.
|
||||
*
|
||||
* @return string The formatted value
|
||||
*/
|
||||
public function format(\DateTime $dateTime): string
|
||||
{
|
||||
$formatted = preg_replace_callback($this->regExp, function ($matches) use ($dateTime) {
|
||||
return $this->formatReplace($matches[0], $dateTime);
|
||||
}, $this->pattern);
|
||||
|
||||
return $formatted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the formatted ICU value for the matched date characters.
|
||||
*
|
||||
* @throws NotImplementedException When it encounters a not implemented date character
|
||||
*/
|
||||
private function formatReplace(string $dateChars, \DateTime $dateTime): string
|
||||
{
|
||||
$length = \strlen($dateChars);
|
||||
|
||||
if ($this->isQuoteMatch($dateChars)) {
|
||||
return $this->replaceQuoteMatch($dateChars);
|
||||
}
|
||||
|
||||
if (isset($this->transformers[$dateChars[0]])) {
|
||||
$transformer = $this->transformers[$dateChars[0]];
|
||||
|
||||
return $transformer->format($dateTime, $length);
|
||||
}
|
||||
|
||||
// handle unimplemented characters
|
||||
if (false !== strpos($this->notImplementedChars, $dateChars[0])) {
|
||||
throw new NotImplementedException(sprintf('Unimplemented date character "%s" in format "%s".', $dateChars[0], $this->pattern));
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a pattern based string to a timestamp value.
|
||||
*
|
||||
* @param \DateTime $dateTime A configured DateTime object to use to perform the date calculation
|
||||
* @param string $value String to convert to a time value
|
||||
*
|
||||
* @return int|false The corresponding Unix timestamp
|
||||
*
|
||||
* @throws \InvalidArgumentException When the value can not be matched with pattern
|
||||
*/
|
||||
public function parse(\DateTime $dateTime, string $value)
|
||||
{
|
||||
$reverseMatchingRegExp = $this->getReverseMatchingRegExp($this->pattern);
|
||||
$reverseMatchingRegExp = '/^'.$reverseMatchingRegExp.'$/';
|
||||
|
||||
$options = [];
|
||||
|
||||
if (preg_match($reverseMatchingRegExp, $value, $matches)) {
|
||||
$matches = $this->normalizeArray($matches);
|
||||
|
||||
foreach ($this->transformers as $char => $transformer) {
|
||||
if (isset($matches[$char])) {
|
||||
$length = \strlen($matches[$char]['pattern']);
|
||||
$options = array_merge($options, $transformer->extractDateOptions($matches[$char]['value'], $length));
|
||||
}
|
||||
}
|
||||
|
||||
// reset error code and message
|
||||
Icu::setError(Icu::U_ZERO_ERROR);
|
||||
|
||||
return $this->calculateUnixTimestamp($dateTime, $options);
|
||||
}
|
||||
|
||||
// behave like the intl extension
|
||||
Icu::setError(Icu::U_PARSE_ERROR, 'Date parsing failed');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a regular expression to match with a formatted value.
|
||||
*
|
||||
* @return string The reverse matching regular expression with named captures being formed by the
|
||||
* transformer index in the $transformer array
|
||||
*/
|
||||
private function getReverseMatchingRegExp(string $pattern): string
|
||||
{
|
||||
$escapedPattern = preg_quote($pattern, '/');
|
||||
|
||||
// ICU 4.8 recognizes slash ("/") in a value to be parsed as a dash ("-") and vice-versa
|
||||
// when parsing a date/time value
|
||||
$escapedPattern = preg_replace('/\\\[\-|\/]/', '[\/\-]', $escapedPattern);
|
||||
|
||||
$reverseMatchingRegExp = preg_replace_callback($this->regExp, function ($matches) {
|
||||
$length = \strlen($matches[0]);
|
||||
$transformerIndex = $matches[0][0];
|
||||
|
||||
$dateChars = $matches[0];
|
||||
if ($this->isQuoteMatch($dateChars)) {
|
||||
return $this->replaceQuoteMatch($dateChars);
|
||||
}
|
||||
|
||||
if (isset($this->transformers[$transformerIndex])) {
|
||||
$transformer = $this->transformers[$transformerIndex];
|
||||
$captureName = str_repeat($transformerIndex, $length);
|
||||
|
||||
return "(?P<$captureName>".$transformer->getReverseMatchingRegExp($length).')';
|
||||
}
|
||||
|
||||
return null;
|
||||
}, $escapedPattern);
|
||||
|
||||
return $reverseMatchingRegExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the first char of a string is a single quote.
|
||||
*/
|
||||
private function isQuoteMatch(string $quoteMatch): bool
|
||||
{
|
||||
return "'" === $quoteMatch[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces single quotes at the start or end of a string with two single quotes.
|
||||
*/
|
||||
private function replaceQuoteMatch(string $quoteMatch): string
|
||||
{
|
||||
if (preg_match("/^'+$/", $quoteMatch)) {
|
||||
return str_replace("''", "'", $quoteMatch);
|
||||
}
|
||||
|
||||
return str_replace("''", "'", substr($quoteMatch, 1, -1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a chars match regular expression.
|
||||
*/
|
||||
private function buildCharsMatch(string $specialChars): string
|
||||
{
|
||||
$specialCharsArray = str_split($specialChars);
|
||||
|
||||
$specialCharsMatch = implode('|', array_map(function ($char) {
|
||||
return $char.'+';
|
||||
}, $specialCharsArray));
|
||||
|
||||
return $specialCharsMatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a preg_replace match array, removing the numeric keys and returning an associative array
|
||||
* with the value and pattern values for the matched Transformer.
|
||||
*/
|
||||
private function normalizeArray(array $data): array
|
||||
{
|
||||
$ret = [];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (!\is_string($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ret[$key[0]] = [
|
||||
'value' => $value,
|
||||
'pattern' => $key,
|
||||
];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the Unix timestamp based on the matched values by the reverse matching regular
|
||||
* expression of parse().
|
||||
*
|
||||
* @return bool|int The calculated timestamp or false if matched date is invalid
|
||||
*/
|
||||
private function calculateUnixTimestamp(\DateTime $dateTime, array $options)
|
||||
{
|
||||
$options = $this->getDefaultValueForOptions($options);
|
||||
|
||||
$year = $options['year'];
|
||||
$month = $options['month'];
|
||||
$day = $options['day'];
|
||||
$hour = $options['hour'];
|
||||
$hourInstance = $options['hourInstance'];
|
||||
$minute = $options['minute'];
|
||||
$second = $options['second'];
|
||||
$marker = $options['marker'];
|
||||
$timezone = $options['timezone'];
|
||||
|
||||
// If month is false, return immediately (intl behavior)
|
||||
if (false === $month) {
|
||||
Icu::setError(Icu::U_PARSE_ERROR, 'Date parsing failed');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Normalize hour
|
||||
if ($hourInstance instanceof HourTransformer) {
|
||||
$hour = $hourInstance->normalizeHour($hour, $marker);
|
||||
}
|
||||
|
||||
// Set the timezone if different from the default one
|
||||
if (null !== $timezone && $timezone !== $this->timezone) {
|
||||
$dateTime->setTimezone(new \DateTimeZone($timezone));
|
||||
}
|
||||
|
||||
// Normalize yy year
|
||||
preg_match_all($this->regExp, $this->pattern, $matches);
|
||||
if (\in_array('yy', $matches[0])) {
|
||||
$dateTime->setTimestamp(time());
|
||||
$year = $year > (int) $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year;
|
||||
}
|
||||
|
||||
$dateTime->setDate($year, $month, $day);
|
||||
$dateTime->setTime($hour, $minute, $second);
|
||||
|
||||
return $dateTime->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add sensible default values for missing items in the extracted date/time options array. The values
|
||||
* are base in the beginning of the Unix era.
|
||||
*/
|
||||
private function getDefaultValueForOptions(array $options): array
|
||||
{
|
||||
return [
|
||||
'year' => $options['year'] ?? 1970,
|
||||
'month' => $options['month'] ?? 1,
|
||||
'day' => $options['day'] ?? 1,
|
||||
'hour' => $options['hour'] ?? 0,
|
||||
'hourInstance' => $options['hourInstance'] ?? null,
|
||||
'minute' => $options['minute'] ?? 0,
|
||||
'second' => $options['second'] ?? 0,
|
||||
'marker' => $options['marker'] ?? null,
|
||||
'timezone' => $options['timezone'] ?? null,
|
||||
];
|
||||
}
|
||||
}
|
64
vendor/symfony/polyfill-intl-icu/DateFormat/Hour1200Transformer.php
vendored
Normal file
64
vendor/symfony/polyfill-intl-icu/DateFormat/Hour1200Transformer.php
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for 12 hour format (0-11).
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Hour1200Transformer extends HourTransformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$hourOfDay = $dateTime->format('g');
|
||||
$hourOfDay = '12' === $hourOfDay ? '0' : $hourOfDay;
|
||||
|
||||
return $this->padLeft($hourOfDay, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function normalizeHour(int $hour, string $marker = null): int
|
||||
{
|
||||
if ('PM' === $marker) {
|
||||
$hour += 12;
|
||||
}
|
||||
|
||||
return $hour;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return '\d{1,2}';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'hour' => (int) $matched,
|
||||
'hourInstance' => $this,
|
||||
];
|
||||
}
|
||||
}
|
64
vendor/symfony/polyfill-intl-icu/DateFormat/Hour1201Transformer.php
vendored
Normal file
64
vendor/symfony/polyfill-intl-icu/DateFormat/Hour1201Transformer.php
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for 12 hour format (1-12).
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Hour1201Transformer extends HourTransformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
return $this->padLeft($dateTime->format('g'), $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function normalizeHour(int $hour, string $marker = null): int
|
||||
{
|
||||
if ('PM' !== $marker && 12 === $hour) {
|
||||
$hour = 0;
|
||||
} elseif ('PM' === $marker && 12 !== $hour) {
|
||||
// If PM and hour is not 12 (1-12), sum 12 hour
|
||||
$hour += 12;
|
||||
}
|
||||
|
||||
return $hour;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return '\d{1,2}';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'hour' => (int) $matched,
|
||||
'hourInstance' => $this,
|
||||
];
|
||||
}
|
||||
}
|
63
vendor/symfony/polyfill-intl-icu/DateFormat/Hour2400Transformer.php
vendored
Normal file
63
vendor/symfony/polyfill-intl-icu/DateFormat/Hour2400Transformer.php
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for 24 hour format (0-23).
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Hour2400Transformer extends HourTransformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
return $this->padLeft($dateTime->format('G'), $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function normalizeHour(int $hour, string $marker = null): int
|
||||
{
|
||||
if ('AM' === $marker) {
|
||||
$hour = 0;
|
||||
} elseif ('PM' === $marker) {
|
||||
$hour = 12;
|
||||
}
|
||||
|
||||
return $hour;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return '\d{1,2}';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'hour' => (int) $matched,
|
||||
'hourInstance' => $this,
|
||||
];
|
||||
}
|
||||
}
|
66
vendor/symfony/polyfill-intl-icu/DateFormat/Hour2401Transformer.php
vendored
Normal file
66
vendor/symfony/polyfill-intl-icu/DateFormat/Hour2401Transformer.php
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for 24 hour format (1-24).
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Hour2401Transformer extends HourTransformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$hourOfDay = $dateTime->format('G');
|
||||
$hourOfDay = '0' === $hourOfDay ? '24' : $hourOfDay;
|
||||
|
||||
return $this->padLeft($hourOfDay, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function normalizeHour(int $hour, string $marker = null): int
|
||||
{
|
||||
if ((null === $marker && 24 === $hour) || 'AM' === $marker) {
|
||||
$hour = 0;
|
||||
} elseif ('PM' === $marker) {
|
||||
$hour = 12;
|
||||
}
|
||||
|
||||
return $hour;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return '\d{1,2}';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'hour' => (int) $matched,
|
||||
'hourInstance' => $this,
|
||||
];
|
||||
}
|
||||
}
|
32
vendor/symfony/polyfill-intl-icu/DateFormat/HourTransformer.php
vendored
Normal file
32
vendor/symfony/polyfill-intl-icu/DateFormat/HourTransformer.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Base class for hour transformers.
|
||||
*
|
||||
* @author Eriksen Costa <eriksen.costa@infranology.com.br>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class HourTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* Returns a normalized hour value suitable for the hour transformer type.
|
||||
*
|
||||
* @param int $hour The hour value
|
||||
* @param string $marker An optional AM/PM marker
|
||||
*
|
||||
* @return int The normalized hour value
|
||||
*/
|
||||
abstract public function normalizeHour(int $hour, string $marker = null): int;
|
||||
}
|
50
vendor/symfony/polyfill-intl-icu/DateFormat/MinuteTransformer.php
vendored
Normal file
50
vendor/symfony/polyfill-intl-icu/DateFormat/MinuteTransformer.php
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for minute format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MinuteTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$minuteOfHour = (int) $dateTime->format('i');
|
||||
|
||||
return $this->padLeft($minuteOfHour, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'minute' => (int) $matched,
|
||||
];
|
||||
}
|
||||
}
|
136
vendor/symfony/polyfill-intl-icu/DateFormat/MonthTransformer.php
vendored
Normal file
136
vendor/symfony/polyfill-intl-icu/DateFormat/MonthTransformer.php
vendored
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for month format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class MonthTransformer extends Transformer
|
||||
{
|
||||
protected static $months = [
|
||||
'January',
|
||||
'February',
|
||||
'March',
|
||||
'April',
|
||||
'May',
|
||||
'June',
|
||||
'July',
|
||||
'August',
|
||||
'September',
|
||||
'October',
|
||||
'November',
|
||||
'December',
|
||||
];
|
||||
|
||||
/**
|
||||
* Short months names (first 3 letters).
|
||||
*/
|
||||
protected static $shortMonths = [];
|
||||
|
||||
/**
|
||||
* Flipped $months array, $name => $index.
|
||||
*/
|
||||
protected static $flippedMonths = [];
|
||||
|
||||
/**
|
||||
* Flipped $shortMonths array, $name => $index.
|
||||
*/
|
||||
protected static $flippedShortMonths = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (0 === \count(self::$shortMonths)) {
|
||||
self::$shortMonths = array_map(function ($month) {
|
||||
return substr($month, 0, 3);
|
||||
}, self::$months);
|
||||
|
||||
self::$flippedMonths = array_flip(self::$months);
|
||||
self::$flippedShortMonths = array_flip(self::$shortMonths);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$matchLengthMap = [
|
||||
1 => 'n',
|
||||
2 => 'm',
|
||||
3 => 'M',
|
||||
4 => 'F',
|
||||
];
|
||||
|
||||
if (isset($matchLengthMap[$length])) {
|
||||
return $dateTime->format($matchLengthMap[$length]);
|
||||
}
|
||||
|
||||
if (5 === $length) {
|
||||
return substr($dateTime->format('M'), 0, 1);
|
||||
}
|
||||
|
||||
return $this->padLeft($dateTime->format('m'), $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
switch ($length) {
|
||||
case 1:
|
||||
$regExp = '\d{1,2}';
|
||||
break;
|
||||
case 3:
|
||||
$regExp = implode('|', self::$shortMonths);
|
||||
break;
|
||||
case 4:
|
||||
$regExp = implode('|', self::$months);
|
||||
break;
|
||||
case 5:
|
||||
$regExp = '[JFMASOND]';
|
||||
break;
|
||||
default:
|
||||
$regExp = '\d{1,'.$length.'}';
|
||||
break;
|
||||
}
|
||||
|
||||
return $regExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
if (!is_numeric($matched)) {
|
||||
if (3 === $length) {
|
||||
$matched = self::$flippedShortMonths[$matched] + 1;
|
||||
} elseif (4 === $length) {
|
||||
$matched = self::$flippedMonths[$matched] + 1;
|
||||
} elseif (5 === $length) {
|
||||
// IntlDateFormatter::parse() always returns false for MMMMM or LLLLL
|
||||
$matched = false;
|
||||
}
|
||||
} else {
|
||||
$matched = (int) $matched;
|
||||
}
|
||||
|
||||
return [
|
||||
'month' => $matched,
|
||||
];
|
||||
}
|
||||
}
|
66
vendor/symfony/polyfill-intl-icu/DateFormat/QuarterTransformer.php
vendored
Normal file
66
vendor/symfony/polyfill-intl-icu/DateFormat/QuarterTransformer.php
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for quarter format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class QuarterTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$month = (int) $dateTime->format('n');
|
||||
$quarter = (int) floor(($month - 1) / 3) + 1;
|
||||
switch ($length) {
|
||||
case 1:
|
||||
case 2:
|
||||
return $this->padLeft($quarter, $length);
|
||||
case 3:
|
||||
return 'Q'.$quarter;
|
||||
default:
|
||||
$map = [1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter'];
|
||||
|
||||
return $map[$quarter];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
switch ($length) {
|
||||
case 1:
|
||||
case 2:
|
||||
return '\d{'.$length.'}';
|
||||
case 3:
|
||||
return 'Q\d';
|
||||
default:
|
||||
return '(?:1st|2nd|3rd|4th) quarter';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
50
vendor/symfony/polyfill-intl-icu/DateFormat/SecondTransformer.php
vendored
Normal file
50
vendor/symfony/polyfill-intl-icu/DateFormat/SecondTransformer.php
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for the second format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class SecondTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$secondOfMinute = (int) $dateTime->format('s');
|
||||
|
||||
return $this->padLeft($secondOfMinute, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return 1 === $length ? '\d{1,2}' : '\d{'.$length.'}';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'second' => (int) $matched,
|
||||
];
|
||||
}
|
||||
}
|
116
vendor/symfony/polyfill-intl-icu/DateFormat/TimezoneTransformer.php
vendored
Normal file
116
vendor/symfony/polyfill-intl-icu/DateFormat/TimezoneTransformer.php
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
use Symfony\Polyfill\Intl\Icu\Exception\NotImplementedException;
|
||||
|
||||
/**
|
||||
* Parser and formatter for time zone format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TimezoneTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws NotImplementedException When time zone is different than UTC or GMT (Etc/GMT)
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
$timeZone = substr($dateTime->getTimezone()->getName(), 0, 3);
|
||||
|
||||
if (!\in_array($timeZone, ['Etc', 'UTC', 'GMT'])) {
|
||||
throw new NotImplementedException('Time zone different than GMT or UTC is not supported as a formatting output.');
|
||||
}
|
||||
|
||||
if ('Etc' === $timeZone) {
|
||||
// i.e. Etc/GMT+1, Etc/UTC, Etc/Zulu
|
||||
$timeZone = substr($dateTime->getTimezone()->getName(), 4);
|
||||
}
|
||||
|
||||
// From ICU >= 59.1 GMT and UTC are no longer unified
|
||||
if (\in_array($timeZone, ['UTC', 'UCT', 'Universal', 'Zulu'])) {
|
||||
// offset is not supported with UTC
|
||||
return $length > 3 ? 'Coordinated Universal Time' : 'UTC';
|
||||
}
|
||||
|
||||
$offset = (int) $dateTime->format('O');
|
||||
|
||||
// From ICU >= 4.8, the zero offset is no more used, example: GMT instead of GMT+00:00
|
||||
if (0 === $offset) {
|
||||
return $length > 3 ? 'Greenwich Mean Time' : 'GMT';
|
||||
}
|
||||
|
||||
if ($length > 3) {
|
||||
return $dateTime->format('\G\M\TP');
|
||||
}
|
||||
|
||||
return sprintf('GMT%s%d', ($offset >= 0 ? '+' : ''), $offset / 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return 'GMT[+-]\d{2}:?\d{2}';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'timezone' => self::getEtcTimeZoneId($matched),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an Etc/GMT timezone identifier for the specified timezone.
|
||||
*
|
||||
* The PHP documentation for timezones states to not use the 'Other' time zones because them exists
|
||||
* "for backwards compatibility". However all Etc/GMT time zones are in the tz database 'etcetera' file,
|
||||
* which indicates they are not deprecated (neither are old names).
|
||||
*
|
||||
* Only GMT, Etc/Universal, Etc/Zulu, Etc/Greenwich, Etc/GMT-0, Etc/GMT+0 and Etc/GMT0 are old names and
|
||||
* are linked to Etc/GMT or Etc/UTC.
|
||||
*
|
||||
* @param string $formattedTimeZone A GMT timezone string (GMT-03:00, e.g.)
|
||||
*
|
||||
* @return string A timezone identifier
|
||||
*
|
||||
* @see https://php.net/timezones.others
|
||||
*
|
||||
* @throws NotImplementedException When the GMT time zone have minutes offset different than zero
|
||||
* @throws \InvalidArgumentException When the value can not be matched with pattern
|
||||
*/
|
||||
public static function getEtcTimeZoneId(string $formattedTimeZone): string
|
||||
{
|
||||
if (preg_match('/GMT(?P<signal>[+-])(?P<hours>\d{2}):?(?P<minutes>\d{2})/', $formattedTimeZone, $matches)) {
|
||||
$hours = (int) $matches['hours'];
|
||||
$minutes = (int) $matches['minutes'];
|
||||
$signal = '-' === $matches['signal'] ? '+' : '-';
|
||||
|
||||
if (0 < $minutes) {
|
||||
throw new NotImplementedException(sprintf('It is not possible to use a GMT time zone with minutes offset different than zero (0). GMT time zone tried: "%s".', $formattedTimeZone));
|
||||
}
|
||||
|
||||
return 'Etc/GMT'.(0 !== $hours ? $signal.$hours : '');
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf('The GMT time zone "%s" does not match with the supported formats GMT[+-]HH:MM or GMT[+-]HHMM.', $formattedTimeZone));
|
||||
}
|
||||
}
|
65
vendor/symfony/polyfill-intl-icu/DateFormat/Transformer.php
vendored
Normal file
65
vendor/symfony/polyfill-intl-icu/DateFormat/Transformer.php
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for date formats.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class Transformer
|
||||
{
|
||||
/**
|
||||
* Format a value using a configured DateTime as date/time source.
|
||||
*
|
||||
* @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
|
||||
* @param int $length The formatted value string length
|
||||
*
|
||||
* @return string The formatted value
|
||||
*/
|
||||
abstract public function format(\DateTime $dateTime, int $length): string;
|
||||
|
||||
/**
|
||||
* Returns a reverse matching regular expression of a string generated by format().
|
||||
*
|
||||
* @param int $length The length of the value to be reverse matched
|
||||
*
|
||||
* @return string The reverse matching regular expression
|
||||
*/
|
||||
abstract public function getReverseMatchingRegExp(int $length): string;
|
||||
|
||||
/**
|
||||
* Extract date options from a matched value returned by the processing of the reverse matching
|
||||
* regular expression.
|
||||
*
|
||||
* @param string $matched The matched value
|
||||
* @param int $length The length of the Transformer pattern string
|
||||
*
|
||||
* @return array An associative array
|
||||
*/
|
||||
abstract public function extractDateOptions(string $matched, int $length): array;
|
||||
|
||||
/**
|
||||
* Pad a string with zeros to the left.
|
||||
*
|
||||
* @param string $value The string to be padded
|
||||
* @param int $length The length to pad
|
||||
*
|
||||
* @return string The padded string
|
||||
*/
|
||||
protected function padLeft(string $value, int $length): string
|
||||
{
|
||||
return str_pad($value, $length, '0', \STR_PAD_LEFT);
|
||||
}
|
||||
}
|
52
vendor/symfony/polyfill-intl-icu/DateFormat/YearTransformer.php
vendored
Normal file
52
vendor/symfony/polyfill-intl-icu/DateFormat/YearTransformer.php
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Polyfill\Intl\Icu\DateFormat;
|
||||
|
||||
/**
|
||||
* Parser and formatter for year format.
|
||||
*
|
||||
* @author Igor Wiedler <igor@wiedler.ch>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class YearTransformer extends Transformer
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function format(\DateTime $dateTime, int $length): string
|
||||
{
|
||||
if (2 === $length) {
|
||||
return $dateTime->format('y');
|
||||
}
|
||||
|
||||
return $this->padLeft($dateTime->format('Y'), $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getReverseMatchingRegExp(int $length): string
|
||||
{
|
||||
return 2 === $length ? '\d{2}' : '\d{1,4}';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function extractDateOptions(string $matched, int $length): array
|
||||
{
|
||||
return [
|
||||
'year' => (int) $matched,
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user