| Total Complexity | 5 |
| Total Lines | 97 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | class DateUtil |
||
| 21 | { |
||
| 22 | /** |
||
| 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) |
||
| 82 | ); |
||
| 83 | } |
||
| 84 | |||
| 85 | public static function french2English(string $date) |
||
| 120 |