Skip to content

Commit

Permalink
Merge pull request #22 from derweba/master
Browse files Browse the repository at this point in the history
Fix namespace for DateTime and implement proper parsing of datetime object
  • Loading branch information
Benjamin-K authored Mar 15, 2021
2 parents c1487b8 + 99cca26 commit fb319de
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Classes/Controller/DatabaseStorageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,13 @@ public function showAction(string $identifier)
} elseif (is_string($value)) {
} elseif (is_object($value) && method_exists($value, '__toString')) {
$value = (string)$value;
} elseif (isset($value['date'])) {
$value = (new DateTime($value['date']))->format($this->settings['datetimeFormat']);
} elseif (isset($value['dateFormat'], $value['date'])) {
$timezone = null;
if(isset($value['timezone'])){
$timezone = new \DateTimeZone($value['timezone']);
}
$dateTime = \DateTime::createFromFormat($value['dateFormat'], $value['date'], $timezone);
$value = $dateTime->format($this->settings['datetimeFormat']);
} else {
$value = '-';
}
Expand Down Expand Up @@ -259,8 +264,13 @@ public function exportAction(string $identifier, string $writerType = 'Xlsx', bo
$values[] = $value;
} elseif (is_object($value) && method_exists($value, '__toString')) {
$values[] = (string)$value;
} elseif (isset($value['date'])) {
$values[] = (new DateTime($value['date']))->format($this->settings['datetimeFormat']);
} elseif (isset($value['dateFormat'], $value['date'])) {
$timezone = null;
if(isset($value['timezone'])){
$timezone = new \DateTimeZone($value['timezone']);
}
$dateTime = \DateTime::createFromFormat($value['dateFormat'], $value['date'], $timezone);
$values[] = $dateTime->format($this->settings['datetimeFormat']);
} else {
$values[] = '-';
}
Expand Down

0 comments on commit fb319de

Please sign in to comment.