Skip to content

Commit cb3539a

Browse files
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"]))
1 parent e57c6f2 commit cb3539a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: rss.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
xml.write("<rss version=\"2.0\">\n")
3636
xml.write("\t<channel>\n")
3737
xml.write("\t\t<title>Plailect Guide Feed</title>\n")
38-
xml.write(f"\t\t<lastBuildDate>{datetime.datetime.utcnow().strftime("%a, %d %b %Y %X +0000")}</lastBuildDate>\n")
38+
xml.write(f"\t\t<lastBuildDate>{datetime.datetime.now(datetime.UTC).strftime("%a, %d %b %Y %X +0000")}</lastBuildDate>\n")
3939
xml.write("\t\t<link>https://github.com/hacks-guide/Guide_3DS/</link>\n")
4040

4141
for filename in os.listdir(dir):
@@ -64,7 +64,7 @@
6464
items = sorted(items, key=lambda d: d['ts'], reverse=True)
6565

6666
for i in items:
67-
pubdate = datetime.datetime.utcfromtimestamp(int(i["ts"]))
67+
pubdate = datetime.datetime.fromtimestamp(int(i["ts"]), datetime.UTC)
6868
xml.write("\t\t<item>\n")
6969
xml.write(f"\t\t\t<title>{i['name']}</title>\n")
7070
xml.write(f"\t\t\t<description>{i['name']}</description>\n".format(i["name"]))

0 commit comments

Comments
 (0)