4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Intl\DateFormatter\DateFormat
;
15 * Parser and formatter for year format
17 * @author Igor Wiedler <igor@wiedler.ch>
19 class YearTransformer
extends Transformer
24 public function format(\DateTime
$dateTime, $length)
27 return $dateTime->format('y');
30 return $this->padLeft($dateTime->format('Y'), $length);
36 public function getReverseMatchingRegExp($length)
38 return 2 === $length ? '\d{2}' : '\d{4}';
44 public function extractDateOptions($matched, $length)
47 'year' => (int) $matched,