AmPmTransformer.php 937 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.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\Polyfill\Intl\Icu\DateFormat;
  11. /**
  12. * Parser and formatter for AM/PM markers format.
  13. *
  14. * @author Igor Wiedler <igor@wiedler.ch>
  15. *
  16. * @internal
  17. */
  18. class AmPmTransformer extends Transformer
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public function format(\DateTime $dateTime, int $length): string
  24. {
  25. return $dateTime->format('A');
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function getReverseMatchingRegExp(int $length): string
  31. {
  32. return 'AM|PM';
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function extractDateOptions(string $matched, int $length): array
  38. {
  39. return [
  40. 'marker' => $matched,
  41. ];
  42. }
  43. }