diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
commit | 4f5b44bd3bd490309eb2ba7b44df4769816ba729 (patch) | |
tree | 6cefe170dfe0a5a361cb1e2d1fc4d580a3316d02 /vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php | |
parent | 2b840e0cfb63a453bea67a98541f3df9c273c5f5 (diff) | |
download | wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.gz wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.zst wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.zip |
twig implementation
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php')
-rw-r--r-- | vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php new file mode 100644 index 00000000..8e83dc75 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/DateFormatter/DateFormat/QuarterTransformer.php | |||
@@ -0,0 +1,64 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Intl\DateFormatter\DateFormat; | ||
13 | |||
14 | /** | ||
15 | * Parser and formatter for quarter format | ||
16 | * | ||
17 | * @author Igor Wiedler <igor@wiedler.ch> | ||
18 | */ | ||
19 | class QuarterTransformer extends Transformer | ||
20 | { | ||
21 | /** | ||
22 | * {@inheritDoc} | ||
23 | */ | ||
24 | public function format(\DateTime $dateTime, $length) | ||
25 | { | ||
26 | $month = (int) $dateTime->format('n'); | ||
27 | $quarter = (int) floor(($month - 1) / 3) + 1; | ||
28 | switch ($length) { | ||
29 | case 1: | ||
30 | case 2: | ||
31 | return $this->padLeft($quarter, $length); | ||
32 | case 3: | ||
33 | return 'Q'.$quarter; | ||
34 | default: | ||
35 | $map = array(1 => '1st quarter', 2 => '2nd quarter', 3 => '3rd quarter', 4 => '4th quarter'); | ||
36 | |||
37 | return $map[$quarter]; | ||
38 | } | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * {@inheritDoc} | ||
43 | */ | ||
44 | public function getReverseMatchingRegExp($length) | ||
45 | { | ||
46 | switch ($length) { | ||
47 | case 1: | ||
48 | case 2: | ||
49 | return '\d{'.$length.'}'; | ||
50 | case 3: | ||
51 | return 'Q\d'; | ||
52 | default: | ||
53 | return '(?:1st|2nd|3rd|4th) quarter'; | ||
54 | } | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * {@inheritDoc} | ||
59 | */ | ||
60 | public function extractDateOptions($matched, $length) | ||
61 | { | ||
62 | return array(); | ||
63 | } | ||
64 | } | ||