$push_definition = $env->user->createPushDefinition();
$push_definition->setOutputType($output_type);
// Now add the output_type-specific args from the command line
for ($i = 7; $i < count($env->args); $i++) {
$bits = explode('=', $env->args[$i], 2);
if (count($bits) != 2) {
usage('Invalid output_param: ' . $env->args[$i]);
}
$push_definition->setOutputParam($bits[0], $bits[1]);
}
// Subscribe the push definition to the historic query
$push_sub = $push_definition->subscribeHistoric($historic, $name);
// Start the historic
$historic->start();
// Display the details of the new subscription
$env->displaySubscriptionDetails($push_sub);
} catch (Exception $e) {
echo 'ERR: ' . get_class($e) . ' ' . $e->getMessage() . PHP_EOL;
}
/**
* Date string parser.
*
* @param string $date Date string.
*/
function parseDate($date)
{
if (strlen($date) != 14) {
usage('Invalid date: "' . $date . '"');
}
// Expand the date so strtotime can deal with it
return strtotime(substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2) . ' ' . substr($date, 8, 2) . ':' . substr($date, 10, 2) . ':' . substr($date, 12, 2));