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 quarter format
17 * @author Igor Wiedler <igor@wiedler.ch>
19 class QuarterTransformer
extends Transformer
24 public function format(\DateTime
$dateTime, $length)
26 $month = (int) $dateTime->format('n');
27 $quarter = (int) floor(($month - 1) / 3) +
1;
31 return $this->padLeft($quarter, $length);
35 $map = array(1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter');
37 return $map[$quarter];
44 public function getReverseMatchingRegExp($length)
49 return '\d{'.$length.'}';
53 return '(?:1st|2nd|3rd|4th) quarter';
60 public function extractDateOptions($matched, $length)