| Conditions | 1 |
| Paths | 1 |
| Total Lines | 32 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | * todo |
||
| 24 | * |
||
| 25 | * @param string $string |
||
| 26 | * |
||
| 27 | * @return DateTime |
||
| 28 | * @throws Exception |
||
| 29 | */ |
||
| 30 | public static function fromWikiSignature(string $string) |
||
| 31 | { |
||
| 32 | // 1 janvier 2020 à 17:44 (CET) => 1 January 2020 à 17:44 (CET) |
||
| 33 | $string = self::french2English(trim($string)); |
||
| 34 | |||
| 35 | $timezone = new DateTimeZone('Europe/Paris'); // CET, CEST |
||
| 36 | if (preg_match('/\(UTC\)/', $string)) { |
||
| 37 | $timezone = new DateTimeZone('UTC'); |
||
| 38 | } |
||
| 39 | $string = preg_replace('/\([A-Z]{3,4}\)/', '', $string); // strip CET,CEST,UTC |
||
| 40 | // convert fuseau ? https://stackoverflow.com/questions/5746531/utc-date-time-string-to-timezone |
||
| 41 | |||
| 42 | return DateTime::createFromFormat('d M Y \à H\:i', trim($string), $timezone); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function cleanDate(string $date) |
||
| 46 | { |
||
| 47 | return $this->english2french($date); |
||
| 48 | } |
||
| 49 | |||
| 50 | public static function english2french(string $date) |
||
| 51 | { |
||
| 52 | return str_replace( |
||
| 53 | [ |
||
| 54 | 'January', |
||
| 55 | 'February', |
||
| 120 |