1 | <?php |
||
14 | class Formatter |
||
15 | { |
||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | const DEFAULT_PASSED_TIME_FORMAT = 'H:i'; |
||
20 | const DEFAULT_PASSED_MONTH_FORMAT = 'd f \a\t H:i'; |
||
21 | const DEFAULT_PASSED_YEAR_FORMAT = 'd f Y \a\t H:i'; |
||
22 | |||
23 | /** |
||
24 | * @var TranslatorInterface |
||
25 | */ |
||
26 | protected $translator; |
||
27 | |||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $trans_format = [ |
||
32 | 'f' => ['F', 'month.genitive.%s'], |
||
33 | 'D' => ['l', 'weekday.short.%s'], |
||
34 | 'l' => ['l', 'weekday.long.%s'], |
||
35 | 'F' => ['F', 'month.long.%s'], |
||
36 | 'M' => ['F', 'month.short.%s'], |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * @param TranslatorInterface $translator |
||
41 | */ |
||
42 | 29 | public function __construct(TranslatorInterface $translator) |
|
46 | |||
47 | /** |
||
48 | * Format date. |
||
49 | * |
||
50 | * @see date() |
||
51 | * |
||
52 | * Additional: |
||
53 | * f - Full name of the month, such as 'января' or 'марта' of January through December |
||
54 | * |
||
55 | * @param \DateTime $date |
||
56 | * @param string $format |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | 27 | public function format(\DateTime $date, $format) |
|
91 | |||
92 | /** |
||
93 | * Passed date, such as 'X minutes ago', 'In X minutes', 'Today at X', 'Yesterday at X' or 'Tomorrow at X'. |
||
94 | * |
||
95 | * @param \DateTime $date |
||
96 | * @param string $time_format |
||
97 | * @param string $month_format |
||
98 | * @param string $year_format |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | 7 | public function passed( |
|
130 | |||
131 | /** |
||
132 | * @param string $id |
||
133 | * @param array $parameters |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | 13 | private function trans($id, array $parameters = []) |
|
141 | } |
||
142 |