convert timestamp from episode action request to format also mysql can process
This commit is contained in:
parent
228be0b0b8
commit
ad3b9c107d
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\GPodderSync\Tests\Unit\Core\EpisodeAction;
|
||||
|
||||
use Test\TestCase;
|
||||
|
||||
class EpisodeActionRequestTimestampConversionTest extends TestCase
|
||||
{
|
||||
public function testTimestampConversion()
|
||||
{
|
||||
$episodeActionTimestamp = "Tue May 18 23:45:11 GMT+02:00 2021";
|
||||
$datetime = \DateTime::createFromFormat('D F d H:i:s T Y', $episodeActionTimestamp);
|
||||
$this->assertEquals("2021-05-18T23:45:11", $datetime->format("Y-m-d\TH:i:s"));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user