fix RSS date format
This commit is contained in:
parent
ffa76d7822
commit
d47f444ba7
1 changed files with 8 additions and 2 deletions
|
@ -1,13 +1,15 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: UTF-8 -*-
|
# -*- coding: UTF-8 -*-
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
import markdown
|
import markdown
|
||||||
import PyRSS2Gen
|
import PyRSS2Gen
|
||||||
|
|
||||||
from stacosys.db import dao
|
from stacosys.db import dao
|
||||||
|
|
||||||
|
RFC_822_FORMAT = '%a, %d %b %Y %H:%M:%S +0000'
|
||||||
|
|
||||||
|
|
||||||
class Rss:
|
class Rss:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
|
@ -40,7 +42,7 @@ class Rss:
|
||||||
link=item_link,
|
link=item_link,
|
||||||
description=markdownizer.convert(row.content),
|
description=markdownizer.convert(row.content),
|
||||||
guid=PyRSS2Gen.Guid(f"{item_link}{row.id}"),
|
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:
|
with open(self._rss_file, "w", encoding="utf-8") as outfile:
|
||||||
rss.write_xml(outfile, encoding="utf-8")
|
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')
|
||||||
|
|
Loading…
Add table
Reference in a new issue