Skip to content

Commit 740cd75

Browse files
committed
fix: more resilient date format
fixes: #72 thank you @batgithub
1 parent a39497f commit 740cd75

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

app/Feed.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Kirby\Toolkit\Xml;
66
use Kirby\Toolkit\Str;
7+
use IntlDateFormatter;
8+
79

810
class Feed extends Podcast
911
{
@@ -145,4 +147,10 @@ public function getTranscript($episode)
145147

146148
return $transcriptList;
147149
}
150+
151+
public function getRssDate($timestamp)
152+
{
153+
$formatter = new IntlDateFormatter('en_US', IntlDateFormatter::FULL, IntlDateFormatter::FULL, 'UTC', IntlDateFormatter::GREGORIAN, "EEE, dd MMM yyyy HH:mm:ss +0000");
154+
return datefmt_format($formatter,$timestamp);
155+
}
148156
}

snippets/xml/item.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
$feed = new Feed();
66
$useUuid = option('mauricerenck.podcaster.feed.uuid', false);
77
$audioFile = $feed->getAudioFile($episode);
8+
$pubDate = $feed->getRssDate($episode->date()->modified()->toDate());
89

910
if(is_null($audioFile)) {
1011
return;
1112
}
1213
?>
1314
<item>
14-
<?=$feed->xmlTag('pubDate', $episode->date()->toDate(DATE_RSS));?>
15+
<?=$feed->xmlTag('pubDate', $pubDate);?>
1516

1617
<?=$feed->xmlTag('title', $episode->podcasterTitle()->or($episode->title()));?>
1718
<?=$feed->xmlTag('itunes:title', $episode->podcasterTitle()->or($episode->title()));?>

templates/podcasterfeed.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
$feed = new Feed();
99
kirby()->response()->type('application/rss+xml');
1010
//kirby()->response()->type('text/xml'); // TODO for debugging
11+
1112
?>
1213
<?php snippet('podcaster-feed-header'); ?>
1314

@@ -73,4 +74,4 @@
7374
<?php snippet('podcaster-feed-item', ['episode' => $episode]); ?>
7475
<?php endforeach; ?>
7576
</channel>
76-
</rss>
77+
</rss>

0 commit comments

Comments
 (0)