AmPmTransformer.php 790 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Locale\Stub\DateFormat;
  11. /**
  12. * Parser and formatter for date formats
  13. *
  14. * @author Igor Wiedler <igor@wiedler.ch>
  15. */
  16. class AmPmTransformer extends Transformer
  17. {
  18. public function format(\DateTime $dateTime, $length)
  19. {
  20. return $dateTime->format('A');
  21. }
  22. public function getReverseMatchingRegExp($length)
  23. {
  24. return "?P<a>AM|PM";
  25. }
  26. public function extractDateOptions($matched, $length)
  27. {
  28. return array(
  29. 'marker' => $matched
  30. );
  31. }
  32. }