Skip to content

Instantly share code, notes, and snippets.

@Gabelbombe
Last active August 29, 2015 13:56
Show Gist options
  • Save Gabelbombe/9277462 to your computer and use it in GitHub Desktop.
Save Gabelbombe/9277462 to your computer and use it in GitHub Desktop.
Filtering Filmaker Pro for bad dates
<?php
$result = json_decode(file_get_contents('data_raw.json'), 1);
/**
* Array filtering by force
*/
$jacked = [];
foreach ($result AS $key => $obj) // creates a reduction of array parts
{
$reduce[$key] = [
'ID' => $obj->ID,
'AirDate' => $obj->AirDate,
'ModifiedDateTime' => $obj->ModifiedDateTime,
'CreatedDateTime' => $obj->CreatedDateTime,
];
if (! preg_match('/[0-9]{2}-[0-9]{2}-[0-9]{2}T[0-2][0-9]:[0-9]{2}:[0-9]{2}\.[0-9]{2}Z/', $obj->AirDate)
|| ! preg_match('/[0-9]{2}-[0-9]{2}-[0-9]{2}T[0-2][0-9]:[0-9]{2}:[0-9]{2}\.[0-9]{2}(-|\+)[0-9]{2}:[0-9]{2}/', $obj->ModifiedDateTime)
|| ! preg_match('/[0-9]{2}-[0-9]{2}-[0-9]{2}T[0-2][0-9]:[0-9]{2}:[0-9]{2}\.[0-9]{2}(-|\+)[0-9]{2}:[0-9]{2}/', $obj->CreatedDateTime)
) { $jacked[$key] = $result[$key]; } // map reduction points
}
$result = array_diff_key($result, $jacked);
$notice = json_encode($jacked); //data filter
error_log("==========================================================");
error_log("WARNING: Bad data intercepted from Filemaker Pro {$notice}");
error_log("==========================================================");
echo json_encode($result);
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment