From d14dc6d2aa1877ba8b07f0fb767a685a4a411ea9 Mon Sep 17 00:00:00 2001 From: "peter@pcc.me.uk" Date: Mon, 1 Dec 2008 20:53:50 +0000 Subject: [PATCH] Start recording date_received in the database --- trunk/docs/include/application.php | 5 ++++- trunk/tools/application_parser.php | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/trunk/docs/include/application.php b/trunk/docs/include/application.php index b151258..e460e8d 100644 --- a/trunk/docs/include/application.php +++ b/trunk/docs/include/application.php @@ -6,7 +6,7 @@ require_once('DB.php'); class Application{ var $authority_id = 0; var $council_reference = ""; - var $date_recieved = ""; + var $date_received = ""; var $date_scraped =""; var $address = ""; var $postcode = ""; @@ -63,6 +63,7 @@ class Application{ $x = $db->quote($this->x); $y = $db->quote($this->y); $date_scraped = $db->quote($this->date_scraped); + $date_received = $db->quote($this->date_received); $map_url = $db->quote($this->map_url); $sql ="insert into application @@ -79,6 +80,7 @@ class Application{ x, y, date_scraped, + date_recieved, map_url ) values( @@ -94,6 +96,7 @@ class Application{ $x, $y, $date_scraped, + $date_received, $map_url )"; diff --git a/trunk/tools/application_parser.php b/trunk/tools/application_parser.php index 8fb03c7..beeb96d 100644 --- a/trunk/tools/application_parser.php +++ b/trunk/tools/application_parser.php @@ -135,7 +135,18 @@ //Grab basic data from the xml $application->authority_id = $authority_id; $application->council_reference = $parsed_application->council_reference; - $application->date_received = $parsed_application->date_received; + + $date_received_dmy = split("/", $parsed_application->date_received); + if (count($date_received_dmy) == 3){ + $application->date_received = "$date_received_dmy[2]-$date_received_dmy[1]-$date_received_dmy[0]"; + } else { + // Make a best effort attempt to parse the date + $ts = strtotime($parsed_application->date_received); + if ($ts != FALSE && $ts != -1) { + $application->date_received = date("Y-m-d", $ts); + } + } + $application->address = $parsed_application->address; $application->postcode = $parsed_application->postcode; $application->description = $parsed_application->description;