From 740cd75c9ea882ca08d6d2ab4339705bc89cf683 Mon Sep 17 00:00:00 2001 From: Maurice Renck Date: Thu, 26 Sep 2024 12:27:35 +0200 Subject: [PATCH] fix: more resilient date format fixes: #72 thank you @batgithub --- app/Feed.php | 8 ++++++++ snippets/xml/item.php | 3 ++- templates/podcasterfeed.php | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Feed.php b/app/Feed.php index 021b226..89f9726 100644 --- a/app/Feed.php +++ b/app/Feed.php @@ -4,6 +4,8 @@ use Kirby\Toolkit\Xml; use Kirby\Toolkit\Str; +use IntlDateFormatter; + class Feed extends Podcast { @@ -145,4 +147,10 @@ public function getTranscript($episode) return $transcriptList; } + + public function getRssDate($timestamp) + { + $formatter = new IntlDateFormatter('en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'UTC', IntlDateFormatter::GREGORIAN, "EEE, dd MMM yyyy HH:mm:ss +0000"); + return datefmt_format($formatter,$timestamp); + } } diff --git a/snippets/xml/item.php b/snippets/xml/item.php index 8cf8f39..42d4508 100644 --- a/snippets/xml/item.php +++ b/snippets/xml/item.php @@ -5,13 +5,14 @@ $feed = new Feed(); $useUuid = option('mauricerenck.podcaster.feed.uuid', false); $audioFile = $feed->getAudioFile($episode); +$pubDate = $feed->getRssDate($episode->date()->modified()->toDate()); if(is_null($audioFile)) { return; } ?> - xmlTag('pubDate', $episode->date()->toDate(DATE_RSS));?> + xmlTag('pubDate', $pubDate);?> xmlTag('title', $episode->podcasterTitle()->or($episode->title()));?> xmlTag('itunes:title', $episode->podcasterTitle()->or($episode->title()));?> diff --git a/templates/podcasterfeed.php b/templates/podcasterfeed.php index c0ad7a1..676a703 100644 --- a/templates/podcasterfeed.php +++ b/templates/podcasterfeed.php @@ -8,6 +8,7 @@ $feed = new Feed(); kirby()->response()->type('application/rss+xml'); //kirby()->response()->type('text/xml'); // TODO for debugging + ?> @@ -73,4 +74,4 @@ $episode]); ?> - \ No newline at end of file +