diff --git a/module/VuFind/src/VuFind/OAI/Server.php b/module/VuFind/src/VuFind/OAI/Server.php index 5d4c8ac18fac16e809a96017b36f5f1cac293787..c396bc233238816e0fe7b134939f0122eb580528 100644 --- a/module/VuFind/src/VuFind/OAI/Server.php +++ b/module/VuFind/src/VuFind/OAI/Server.php @@ -270,6 +270,21 @@ class Server $this->metadataFormats = []; } + /** + * Get the current UTC date/time in ISO 8601 format. + * + * @param string $time Time string to represent as UTC (default = 'now') + * + * @return string + */ + protected function getUTCDateTime($time = 'now') + { + // All times must be in UTC, so translate the current time to the + // appropriate time zone: + $utc = new \DateTime($time, new \DateTimeZone('UTC')); + return date_format($utc, $this->iso8601); + } + /** * Respond to the OAI-PMH request. * @@ -444,7 +459,7 @@ class Server // Get modification date: $date = $record->getLastIndexed(); if (empty($date)) { - $date = date($this->iso8601); + $date = $this->getUTCDateTime('now'); } // Set up header (inside or outside a <record> container depending on @@ -987,7 +1002,7 @@ class Server } } if (empty($params['until'])) { - $params['until'] = date($this->iso8601); + $params['until'] = $this->getUTCDateTime('now +1 day'); if (strlen($params['until']) > strlen($params['from'])) { $params['until'] = substr($params['until'], 0, 10); } @@ -1252,7 +1267,7 @@ class Server . 'http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd', 'http://www.w3.org/2001/XMLSchema-instance' ); - $xml->responseDate = date($this->iso8601); + $xml->responseDate = $this->getUTCDateTime('now'); $xml->request = $this->baseURL; if ($echoParams) { foreach ($this->params as $key => $value) {