1 | <?php |
||
14 | class DateTimeHumanizerExtension extends AbstractHumanizerExtension |
||
15 | { |
||
16 | /** |
||
17 | * {@inheritdoc} |
||
18 | */ |
||
19 | 45 | public function getFilters() |
|
20 | { |
||
21 | 1 | return [ |
|
22 | 45 | new Twig_SimpleFilter( |
|
23 | 45 | 'difference', |
|
24 | 30 | function (DateTime $fromDate, DateTime $toDate) { |
|
25 | 3 | return DateTimeHumanizer::difference( |
|
26 | 2 | $fromDate, |
|
27 | 2 | $toDate, |
|
28 | 3 | $this->translator->getLocale() |
|
29 | 1 | ); |
|
30 | 30 | } |
|
31 | 15 | ), |
|
32 | 45 | new Twig_SimpleFilter( |
|
33 | 45 | 'precise_difference', |
|
34 | 31 | function (DateTime $fromDate, DateTime $toDate) { |
|
35 | 3 | return DateTimeHumanizer::preciseDifference( |
|
36 | 2 | $fromDate, |
|
37 | 2 | $toDate, |
|
38 | 3 | $this->translator->getLocale() |
|
39 | 1 | ); |
|
40 | 30 | } |
|
41 | 15 | ), |
|
42 | 15 | ]; |
|
43 | } |
||
44 | |||
45 | 15 | public function getName() |
|
49 | } |
||
50 |