From 5a46233e46ad9f5be532b926f7130c78fc6c826a Mon Sep 17 00:00:00 2001 From: Jonathan Flueren Date: Sat, 24 Jul 2021 19:06:14 +0200 Subject: [PATCH 1/2] Update EpisodeActionController.php Use UTC timestamp for episode actions instead of the timezone used by the AntennaPod app. Correct conversion should be assured because the AntennaPod timestamp includes a timezone identifier (T). Also slightly change the output format for the DateTime-timestamp to equal other timestamp formats. --- lib/Controller/EpisodeActionController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Controller/EpisodeActionController.php b/lib/Controller/EpisodeActionController.php index e154815..d7fa3d5 100644 --- a/lib/Controller/EpisodeActionController.php +++ b/lib/Controller/EpisodeActionController.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace OCA\GPodderSync\Controller; use DateTime; +use DateTimeZone; use GuzzleHttp\Psr7\Response; use OCA\GPodderSync\Core\EpisodeAction\EpisodeActionReader; use OCA\GPodderSync\Db\EpisodeAction\EpisodeActionEntity; @@ -110,6 +111,7 @@ class EpisodeActionController extends Controller { private function convertTimestampToDbDateTimeString(string $timestamp) { return \DateTime::createFromFormat('D F d H:i:s T Y', $timestamp) - ->format("Y-m-d\TH:i:s"); + ->setTimezone(new DateTimeZone('UTC')) + ->format("Y-m-d H:i:s"); } } From e438ae94dd65a987935fb70a712c7d4887bd8ffb Mon Sep 17 00:00:00 2001 From: Jonathan Flueren <11487762+JonOfUs@users.noreply.github.com> Date: Sat, 24 Jul 2021 20:11:42 +0200 Subject: [PATCH 2/2] Revert change of timestamp format Reverting the change of format of the timestamp that gets saved into episode_action table. Reason: The 'T' was in there so that the timestamp format is like AntennaPod's timestamp format. --- lib/Controller/EpisodeActionController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Controller/EpisodeActionController.php b/lib/Controller/EpisodeActionController.php index d7fa3d5..8f17220 100644 --- a/lib/Controller/EpisodeActionController.php +++ b/lib/Controller/EpisodeActionController.php @@ -112,6 +112,6 @@ class EpisodeActionController extends Controller { { return \DateTime::createFromFormat('D F d H:i:s T Y', $timestamp) ->setTimezone(new DateTimeZone('UTC')) - ->format("Y-m-d H:i:s"); + ->format("Y-m-d\TH:i:s"); } }