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

Alma: Handle timestamps with milliseconds properly. (#1511)

parent d2e40bb0
No related merge requests found
...@@ -861,14 +861,8 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface ...@@ -861,14 +861,8 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
"title" => (string)($fee->title ?? ''), "title" => (string)($fee->title ?? ''),
"amount" => round(floatval($fee->original_amount) * 100), "amount" => round(floatval($fee->original_amount) * 100),
"balance" => round(floatval($fee->balance) * 100), "balance" => round(floatval($fee->balance) * 100),
"createdate" => $this->dateConverter->convertToDisplayDateAndTime( "createdate" => $this->parseDate($created, true),
'Y-m-d\TH:i:s.???T', "checkout" => $this->parseDate($checkout, true),
$created
),
"checkout" => $this->dateConverter->convertToDisplayDateAndTime(
'Y-m-d\TH:i:s.???T',
$checkout
),
"fine" => $this->getTranslatableString($fee->type) "fine" => $this->getTranslatableString($fee->type)
]; ];
} }
...@@ -1595,6 +1589,8 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface ...@@ -1595,6 +1589,8 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
$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}Z$/"; $timestamp = "/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$/";
$timestampMs
= "/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}Z$/";
// e. g. 2017-07-09T18:00:00 // e. g. 2017-07-09T18:00:00
if ($date == null || $date == '') { if ($date == null || $date == '') {
...@@ -1621,6 +1617,18 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface ...@@ -1621,6 +1617,18 @@ class Alma extends AbstractBase implements \VuFindHttp\HttpServiceAwareInterface
substr($date, 0, 10) substr($date, 0, 10)
); );
} }
} elseif (preg_match($timestampMs, $date) === 1) {
if ($withTime) {
return $this->dateConverter->convertToDisplayDateAndTime(
'Y-m-d\TH:i:s#???T',
$date
);
} else {
return $this->dateConverter->convertToDisplayDate(
'Y-m-d',
substr($date, 0, 10)
);
}
} else { } else {
throw new \Exception("Invalid date: $date"); throw new \Exception("Invalid date: $date");
} }
......
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