diff --git a/lib/Controller/EpisodeActionController.php b/lib/Controller/EpisodeActionController.php index 5642061..e154815 100644 --- a/lib/Controller/EpisodeActionController.php +++ b/lib/Controller/EpisodeActionController.php @@ -61,7 +61,7 @@ class EpisodeActionController extends Controller { $episodeActionEntity->setPosition($episodeAction->getPosition()); $episodeActionEntity->setStarted($episodeAction->getStarted()); $episodeActionEntity->setTotal($episodeAction->getTotal()); - $episodeActionEntity->setTimestamp($episodeAction->getTimestamp()); + $episodeActionEntity->setTimestamp($this->convertTimestampToDbDateTimeString($episodeAction->getTimestamp())); $episodeActionEntity->setUserId($this->userId); try { @@ -101,4 +101,15 @@ class EpisodeActionController extends Controller { ? (new \DateTime)->setTimestamp($since) : (new \DateTime('-1 week')); } + + /** + * @param string $episodeAction + * + * @return string + */ + private function convertTimestampToDbDateTimeString(string $timestamp) + { + return \DateTime::createFromFormat('D F d H:i:s T Y', $timestamp) + ->format("Y-m-d\TH:i:s"); + } } diff --git a/tests/Unit/Core/EpisodeAction/EpisodeActionRequestTimestampConversionTest.php b/tests/Unit/Core/EpisodeAction/EpisodeActionRequestTimestampConversionTest.php new file mode 100644 index 0000000..9c6cc21 --- /dev/null +++ b/tests/Unit/Core/EpisodeAction/EpisodeActionRequestTimestampConversionTest.php @@ -0,0 +1,16 @@ +assertEquals("2021-05-18T23:45:11", $datetime->format("Y-m-d\TH:i:s")); + } +}