fix RSS date format

This commit is contained in:
Yax 2025-09-24 13:22:57 +02:00
parent ffa76d7822
commit d47f444ba7

View file

@ -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')