From d47f444ba759b59d3166945fd743384a500b3abf Mon Sep 17 00:00:00 2001 From: Yax Date: Wed, 24 Sep 2025 13:22:57 +0200 Subject: [PATCH] fix RSS date format --- src/stacosys/service/rssfeed.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/stacosys/service/rssfeed.py b/src/stacosys/service/rssfeed.py index 9c9ebe0..c9bea05 100644 --- a/src/stacosys/service/rssfeed.py +++ b/src/stacosys/service/rssfeed.py @@ -1,13 +1,15 @@ #!/usr/bin/env python # -*- coding: UTF-8 -*- -from datetime import datetime +from datetime import datetime, timezone import markdown import PyRSS2Gen from stacosys.db import dao +RFC_822_FORMAT = '%a, %d %b %Y %H:%M:%S +0000' + class Rss: def __init__(self) -> None: @@ -40,7 +42,7 @@ class Rss: link=item_link, description=markdownizer.convert(row.content), guid=PyRSS2Gen.Guid(f"{item_link}{row.id}"), - pubDate=row.published, + pubDate=self._to_rfc822(row.published) ) ) @@ -54,3 +56,7 @@ class Rss: ) with open(self._rss_file, "w", encoding="utf-8") as outfile: rss.write_xml(outfile, encoding="utf-8") + + def _to_rfc822(self, dt): + return dt.replace(tzinfo=timezone.utc) \ + .strftime('%a, %d %b %Y %H:%M:%S %z')