Skip to content

Commit

Permalink
fix: more resilient date format
Browse files Browse the repository at this point in the history
fixes: #72 thank you @batgithub
  • Loading branch information
mauricerenck committed Sep 26, 2024
1 parent a39497f commit 740cd75
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Kirby\Toolkit\Xml;
use Kirby\Toolkit\Str;
use IntlDateFormatter;


class Feed extends Podcast
{
Expand Down Expand Up @@ -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);
}
}
3 changes: 2 additions & 1 deletion snippets/xml/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
?>
<item>
<?=$feed->xmlTag('pubDate', $episode->date()->toDate(DATE_RSS));?>
<?=$feed->xmlTag('pubDate', $pubDate);?>

<?=$feed->xmlTag('title', $episode->podcasterTitle()->or($episode->title()));?>
<?=$feed->xmlTag('itunes:title', $episode->podcasterTitle()->or($episode->title()));?>
Expand Down
3 changes: 2 additions & 1 deletion templates/podcasterfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$feed = new Feed();
kirby()->response()->type('application/rss+xml');
//kirby()->response()->type('text/xml'); // TODO for debugging

?>
<?php snippet('podcaster-feed-header'); ?>

Expand Down Expand Up @@ -73,4 +74,4 @@
<?php snippet('podcaster-feed-item', ['episode' => $episode]); ?>
<?php endforeach; ?>
</channel>
</rss>
</rss>

0 comments on commit 740cd75

Please sign in to comment.