From 4f5b44bd3bd490309eb2ba7b44df4769816ba729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 3 Aug 2013 19:26:54 +0200 Subject: twig implementation --- .../DateFormat/Hour2400Transformer.php | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php (limited to 'vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php') diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php new file mode 100644 index 00000000..8f22da13 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/Hour2400Transformer.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Intl\DateFormatter\DateFormat; + +/** + * Parser and formatter for 24 hour format (0-23) + * + * @author Igor Wiedler + */ +class Hour2400Transformer extends HourTransformer +{ + /** + * {@inheritDoc} + */ + public function format(\DateTime $dateTime, $length) + { + return $this->padLeft($dateTime->format('G'), $length); + } + + /** + * {@inheritDoc} + */ + public function normalizeHour($hour, $marker = null) + { + if ('AM' == $marker) { + $hour = 0; + } elseif ('PM' == $marker) { + $hour = 12; + } + + return $hour; + } + + /** + * {@inheritDoc} + */ + public function getReverseMatchingRegExp($length) + { + return '\d{1,2}'; + } + + /** + * {@inheritDoc} + */ + public function extractDateOptions($matched, $length) + { + return array( + 'hour' => (int) $matched, + 'hourInstance' => $this + ); + } +} -- cgit v1.2.3