Align episode upload format to gpodder-api

'started', 'position' and 'total' are optional and 'timestamp' is in 'Y-m-d\TH:i:s' format
This commit is contained in:
Jonathan Flueren 2021-10-06 16:41:19 +02:00 committed by thrillfall
parent d6c81e7f83
commit d131b59348
3 changed files with 5 additions and 18 deletions

View File

@ -84,17 +84,4 @@ class EpisodeActionController extends Controller {
public function filterEpisodesFromRequestParams(array $data): array {
return array_filter($data, "is_numeric", ARRAY_FILTER_USE_KEY);
}
/**
* @param int|null $since
*
* @return DateTime
*/
private function createDateTimeFromTimestamp(?int $since): DateTime {
return ($since !== null)
? (new \DateTime)->setTimestamp($since)
: (new \DateTime('-1 week'));
}
}

View File

@ -19,10 +19,11 @@ class EpisodeActionReader
$episodeAction["episode"],
$episodeAction["action"],
$episodeAction["timestamp"],
$episodeAction["started"],
$episodeAction["position"],
$episodeAction["total"],
$episodeAction["started"] ?? -1,
$episodeAction["position"] ?? -1,
$episodeAction["total"] ?? -1,
$episodeAction["guid"] ?? null,
null
);
}

View File

@ -56,8 +56,7 @@ class EpisodeActionSaver
private function convertTimestampToUnixEpoch(string $timestamp): string
{
return \DateTime::createFromFormat('D F d H:i:s T Y', $timestamp)
->setTimezone(new DateTimeZone('UTC'))
return \DateTime::createFromFormat('Y-m-d\TH:i:s', $timestamp)
->format("U");
}