1 | <?php |
||
16 | class YearMonthTimeParser extends StringValueParser { |
||
17 | |||
18 | const FORMAT_NAME = 'year-month'; |
||
19 | |||
20 | /** |
||
21 | * @var int[] Array mapping localized month names to month numbers (1 to 12). |
||
22 | */ |
||
23 | private $monthNumbers; |
||
24 | |||
25 | /** |
||
26 | * @var ValueParser |
||
27 | */ |
||
28 | private $isoTimestampParser; |
||
29 | |||
30 | /** |
||
31 | * @see StringValueParser::__construct |
||
32 | * |
||
33 | * @param MonthNameProvider $monthNameProvider |
||
34 | * @param ParserOptions|null $options |
||
35 | */ |
||
36 | public function __construct( |
||
49 | |||
50 | /** |
||
51 | * Parses the provided string and returns the result. |
||
52 | * |
||
53 | * @param string $value |
||
54 | * |
||
55 | * @throws ParseException |
||
56 | * @return TimeValue |
||
57 | */ |
||
58 | protected function stringParse( $value ) { |
||
92 | |||
93 | /** |
||
94 | * If we have 2 integers parse the date assuming that the larger is the year |
||
95 | * unless the smaller is not a 'legal' month value |
||
96 | * |
||
97 | * @param string|int $a |
||
98 | * @param string|int $b |
||
99 | * |
||
100 | * @return TimeValue|bool |
||
101 | */ |
||
102 | private function parseYearMonthTwoInts( $a, $b ) { |
||
115 | |||
116 | /** |
||
117 | * If we have 1 int and 1 string then try to parse the int as the year and month as the string |
||
118 | * Check for both the full name and abbreviations |
||
119 | * |
||
120 | * @param string|int $year |
||
121 | * @param string $month |
||
122 | * |
||
123 | * @return TimeValue|bool |
||
124 | */ |
||
125 | private function parseYearMonth( $year, $month ) { |
||
134 | |||
135 | /** |
||
136 | * @param string $year |
||
137 | * @param string $month |
||
138 | * |
||
139 | * @return TimeValue |
||
140 | */ |
||
141 | private function getTimeFromYearMonth( $year, $month ) { |
||
144 | |||
145 | /** |
||
146 | * @param string|int $value |
||
147 | * |
||
148 | * @return bool can the given value be a month? |
||
149 | */ |
||
150 | private function canBeMonth( $value ) { |
||
153 | |||
154 | } |
||
155 |