From 3559f6e932d413f538063e57bb209307e2684156 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 5 Oct 2011 11:20:58 +0200 Subject: [PATCH] Fix the last_modified and dtstamp? Nearly? --- inc/tz/expand.php | 4 ++-- inc/tz/get.php | 4 ++-- inc/tz/list.php | 11 +++++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/inc/tz/expand.php b/inc/tz/expand.php index 5b8cdff6..329ac68d 100644 --- a/inc/tz/expand.php +++ b/inc/tz/expand.php @@ -21,14 +21,14 @@ if ( empty($start) ) $start = sprintf( '%04d-01-01', date('Y')); if ( empty($end) ) $end = sprintf( '%04d-12-31', date('Y') + 10); $sql = 'SELECT our_tzno, tzid, active, olson_name, vtimezone, etag, '; -$sql .= 'to_char((last_modified::timestamp WITH TIME ZONE) AT TIME ZONE \'UTC\',\'Dy, DD Mon IYYY HH24:MI:SS "GMT"\') AS last_modified '; +$sql .= 'to_char(last_modified,\'Dy, DD Mon IYYY HH24:MI:SS "GMT"\') AS last_modified '; $sql .= 'FROM timezones WHERE tzid=:tzid'; $params = array( ':tzid' => $tzid ); $qry = new AwlQuery($sql,$params); if ( !$qry->Exec() ) exit(1); if ( $qry->rows() < 1 ) { $sql = 'SELECT our_tzno, tzid, active, olson_name, vtimezone, etag, '; - $sql .= 'to_char((last_modified::timestamp WITH TIME ZONE) AT TIME ZONE \'UTC\',\'Dy, DD Mon IYYY HH24:MI:SS "GMT"\') AS last_modified '; + $sql .= 'to_char(last_modified,\'Dy, DD Mon IYYY HH24:MI:SS "GMT"\') AS last_modified '; $sql .= 'FROM timezones JOIN tz_aliases USING(our_tzno) WHERE tzalias=:tzid'; if ( !$qry->Exec() ) exit(1); if ( $qry->rows() < 1 ) $request->DoResponse(404); diff --git a/inc/tz/get.php b/inc/tz/get.php index 6317a988..13d0785e 100644 --- a/inc/tz/get.php +++ b/inc/tz/get.php @@ -17,14 +17,14 @@ if ( $format != 'text/calendar' ) { } $sql = 'SELECT our_tzno, tzid, active, olson_name, vtimezone, etag, '; -$sql .= 'to_char((last_modified::timestamp WITH TIME ZONE) AT TIME ZONE \'UTC\',\'Dy, DD Mon IYYY HH24:MI:SS "GMT"\') AS last_modified '; +$sql .= 'to_char(last_modified,\'Dy, DD Mon IYYY HH24:MI:SS "GMT"\') AS last_modified '; $sql .= 'FROM timezones WHERE tzid=:tzid'; $params = array( ':tzid' => $tzid ); $qry = new AwlQuery($sql,$params); if ( !$qry->Exec() ) exit(1); if ( $qry->rows() < 1 ) { $sql = 'SELECT our_tzno, tzid, active, olson_name, vtimezone, etag, '; - $sql .= 'to_char((last_modified::timestamp WITH TIME ZONE) AT TIME ZONE \'UTC\',\'Dy, DD Mon IYYY HH24:MI:SS "GMT"\') AS last_modified '; + $sql .= 'to_char(last_modified,\'Dy, DD Mon IYYY HH24:MI:SS "GMT"\') AS last_modified '; $sql .= 'FROM timezones JOIN tz_aliases USING(our_tzno) WHERE tzalias=:tzid'; if ( !$qry->Exec() ) exit(1); if ( $qry->rows() < 1 ) $request->DoResponse(404); diff --git a/inc/tz/list.php b/inc/tz/list.php index 8bb4d1fb..705a1e0b 100644 --- a/inc/tz/list.php +++ b/inc/tz/list.php @@ -13,9 +13,16 @@ require_once('vComponent.php'); $response = new XMLDocument( array("urn:ietf:params:xml:ns:timezone-service" => "") ); $tzlist = $response->NewXMLElement('timezone-list'); -$tzlist->NewElement('dtstamp', gmdate('Y-m-d\TH:i:s\Z')); +$qry = new AwlQuery('SELECT to_char(max(last_modified),\'YYYY-MM-DD\"T\"HH24:MI:SS"Z"\') AS dtstamp FROM timezones'); +if ( $qry->Exec('tz/list',__LINE__,__FILE__) && $qry->rows() > 0 ) { + $row = $qry->Fetch(); + $tzlist->NewElement('dtstamp', $row->dtstamp); +} +else { + $tzlist->NewElement('dtstamp', gmdate('Y-m-d\TH:i:s\Z')); +} -$sql = 'SELECT our_tzno, tzid, active, to_char((last_modified::timestamp WITH TIME ZONE) AT TIME ZONE \'UTC\',\'YYYY-MM-DD\"T\"HH24:MI:SS"Z"\') AS last_modified, olson_name, vtimezone FROM timezones'; +$sql = 'SELECT our_tzno, tzid, active, to_char(last_modified,\'YYYY-MM-DD\"T\"HH24:MI:SS"Z"\') AS last_modified, olson_name, vtimezone FROM timezones'; $params = array(); $where = ''; if ( $returnall !== true ) {