Skip to content
Snippets Groups Projects
Commit cc8395f7 authored by Ere Maijala's avatar Ere Maijala Committed by Robert Lange
Browse files

Alma: Fix time zone handling when parsing dates and times.

parent e540cc8c
No related merge requests found
...@@ -1480,8 +1480,8 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface ...@@ -1480,8 +1480,8 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
{ {
// Remove trailing Z from end of date // Remove trailing Z from end of date
// e.g. from Alma we get dates like 2012-07-13Z without time, which is wrong) // e.g. from Alma we get dates like 2012-07-13Z without time, which is wrong)
if (strpos($date, 'Z', (strlen($date) - 1))) { if (strpos($date, 'T') === false && substr($date, -1) === 'Z') {
$date = preg_replace('/Z{1}$/', '', $date); $date = substr($date, 0, -1);
} }
$compactDate = "/^[0-9]{8}$/"; // e. g. 20120725 $compactDate = "/^[0-9]{8}$/"; // e. g. 20120725
...@@ -1489,7 +1489,7 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface ...@@ -1489,7 +1489,7 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
$euro = "/^[0-9]+\/[0-9]+\/[0-9]{4}$/"; // e. g. 13/7/2012 $euro = "/^[0-9]+\/[0-9]+\/[0-9]{4}$/"; // e. g. 13/7/2012
$euroPad = "/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{2,4}$/"; // e. g. 13/07/2012 $euroPad = "/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{2,4}$/"; // e. g. 13/07/2012
$datestamp = "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/"; // e. g. 2012-07-13 $datestamp = "/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/"; // e. g. 2012-07-13
$timestamp = "/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/"; $timestamp = "/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$/";
// e. g. 2017-07-09T18:00:00 // e. g. 2017-07-09T18:00:00
if ($date == null || $date == '') { if ($date == null || $date == '') {
...@@ -1504,11 +1504,11 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface ...@@ -1504,11 +1504,11 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
return $this->dateConverter->convertToDisplayDate('d/m/y', $date); return $this->dateConverter->convertToDisplayDate('d/m/y', $date);
} elseif (preg_match($datestamp, $date) === 1) { } elseif (preg_match($datestamp, $date) === 1) {
return $this->dateConverter->convertToDisplayDate('Y-m-d', $date); return $this->dateConverter->convertToDisplayDate('Y-m-d', $date);
} elseif (preg_match($timestamp, substr($date, 0, 19)) === 1) { } elseif (preg_match($timestamp, $date) === 1) {
if ($withTime) { if ($withTime) {
return $this->dateConverter->convertToDisplayDateAndTime( return $this->dateConverter->convertToDisplayDateAndTime(
'Y-m-d\TH:i:s', 'Y-m-d\TH:i:sT',
substr($date, 0, 19) $date
); );
} else { } else {
return $this->dateConverter->convertToDisplayDate( return $this->dateConverter->convertToDisplayDate(
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment