Fixes to TIC processing that uses the Address::ftn_regex

This commit is contained in:
Deon George 2023-11-23 13:17:02 +11:00
parent a13028808a
commit 76dc90ceb3

View File

@ -87,9 +87,13 @@ class File extends Model
$zone = $model->fftn->zone; $zone = $model->fftn->zone;
// Parse PATH // Parse PATH
/**
* Path 21:4/106.0 @231005001126 PST+7 Foobar
* Path 21:1/100 1696489954 Thu Oct 05 07:12:34 2023 UTC htick/lnx 1.9 2022-07-03
*/
foreach ($model->set_path as $line) { foreach ($model->set_path as $line) {
$matches = []; $matches = [];
preg_match(sprintf('#^(\d+:\d+/\d+(\.\d+)?(@%s)?)\ ((\d+)\ )?(.*)$#',Address::ftn_regex),$line,$matches); preg_match(sprintf('#^(%s)\ ((@?)(\d+)(\ ([A-Z]{3}([\+\-][0-9]+)))?)\ ?(.*)$#',Address::ftn_regex),$line,$matches);
if ($x=Arr::get($matches,1)) { if ($x=Arr::get($matches,1)) {
$ftn = Address::parseFTN($x); $ftn = Address::parseFTN($x);
@ -102,7 +106,11 @@ class File extends Model
if (! $ao) if (! $ao)
$ao = Address::createFTN($x,System::createUnknownSystem()); $ao = Address::createFTN($x,System::createUnknownSystem());
$path->push(['address'=>$ao,'datetime'=>Carbon::createFromTimestamp($matches[12]),'extra'=>$matches[13]]); $datetime = ($matches[8] === '@')
? Carbon::createFromFormat('ymdHis',$matches[9],$matches[12])
: Carbon::createFromTimestamp($matches[7]);
$path->push(['address'=>$ao,'datetime'=>$datetime,'extra'=>$matches[13]]);
} }
} }