EraTransformer.php 790 B

123456789101112131415161718192021222324252627282930313233343536
  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 EraTransformer extends Transformer
  17. {
  18. public function format(\DateTime $dateTime, $length)
  19. {
  20. $year = (int) $dateTime->format('Y');
  21. return $year >= 0 ? 'AD' : 'BC';
  22. }
  23. public function getReverseMatchingRegExp($length)
  24. {
  25. return "AD|BC";
  26. }
  27. public function extractDateOptions($matched, $length)
  28. {
  29. return array();
  30. }
  31. }