Skip to content

Commit

Permalink
Datetime conversion rules extended #189 #173
Browse files Browse the repository at this point in the history
  • Loading branch information
Webklex committed Aug 19, 2022
1 parent 497e321 commit 7ba46d1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,9 +713,15 @@ private function parseDate($header) {

$date = trim(rtrim($date));
try {
if(strpos($date, ' ') !== false){
$date = str_replace(' ', ' ', $date);
}
$parsed_date = Carbon::parse($date);
} catch (\Exception $e) {
switch (true) {
case preg_match('/([0-9]{4}\.[0-9]{1,2}\.[0-9]{1,2}\-[0-9]{1,2}\.[0-9]{1,2}.[0-9]{1,2})+$/i', $date) > 0:
$date = Carbon::createFromFormat("Y.m.d-H.i.s", $date);
break;
case preg_match('/([0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ UT)+$/i', $date) > 0:
case preg_match('/([A-Z]{2,3}\,\ [0-9]{1,2}\ [A-Z]{2,3}\ [0-9]{4}\ [0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\ UT)+$/i', $date) > 0:
$date .= 'C';
Expand Down

0 comments on commit 7ba46d1

Please sign in to comment.