Last active
August 29, 2015 13:56
-
-
Save Gabelbombe/9277462 to your computer and use it in GitHub Desktop.
Filtering Filmaker Pro for bad dates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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