1
0
mirror of https://github.com/hacks-guide/Guide_3DS.git synced 2025-08-18 14:31:30 +02:00

rss.py: fix datetime deprecation warnings

/home/lifehackerhansol/git/hacks-guide/Guide_3DS/rss.py:38: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
  xml.write(f"\t\t<lastBuildDate>{datetime.datetime.utcnow().strftime("%a, %d %b %Y %X +0000")}</lastBuildDate>\n")
/home/lifehackerhansol/git/hacks-guide/Guide_3DS/rss.py:67: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
  pubdate = datetime.datetime.utcfromtimestamp(int(i["ts"]))
This commit is contained in:
lifehackerhansol
2025-04-12 08:25:04 -07:00
parent e57c6f2fb5
commit cb3539a3b1

4
rss.py
View File

@@ -35,7 +35,7 @@ with open(rss, "w") as xml:
xml.write("<rss version=\"2.0\">\n")
xml.write("\t<channel>\n")
xml.write("\t\t<title>Plailect Guide Feed</title>\n")
xml.write(f"\t\t<lastBuildDate>{datetime.datetime.utcnow().strftime("%a, %d %b %Y %X +0000")}</lastBuildDate>\n")
xml.write(f"\t\t<lastBuildDate>{datetime.datetime.now(datetime.UTC).strftime("%a, %d %b %Y %X +0000")}</lastBuildDate>\n")
xml.write("\t\t<link>https://github.com/hacks-guide/Guide_3DS/</link>\n")
for filename in os.listdir(dir):
@@ -64,7 +64,7 @@ with open(rss, "w") as xml:
items = sorted(items, key=lambda d: d['ts'], reverse=True)
for i in items:
pubdate = datetime.datetime.utcfromtimestamp(int(i["ts"]))
pubdate = datetime.datetime.fromtimestamp(int(i["ts"]), datetime.UTC)
xml.write("\t\t<item>\n")
xml.write(f"\t\t\t<title>{i['name']}</title>\n")
xml.write(f"\t\t\t<description>{i['name']}</description>\n".format(i["name"]))