From 3a8630f2a79813c9afa3517c64f89ad96e3cba9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaume=20Delcl=C3=B2s=20Coll?= Date: Thu, 29 Oct 2020 17:00:54 +0100 Subject: [PATCH] actually good dates --- ttbp/atom.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ttbp/atom.py b/ttbp/atom.py index 879a132..46cc255 100644 --- a/ttbp/atom.py +++ b/ttbp/atom.py @@ -37,6 +37,8 @@ from feedgen.feed import FeedGenerator import os import mistune import datetime +import stat +import time def publish_atom(entry_filenames, settings): fg = FeedGenerator() @@ -66,7 +68,11 @@ def publish_atom(entry_filenames, settings): fe.author(name=config.USER) fe.content(html, type="html") try: # crashing because of an invalid date would be sad - fe.updated("-".join(date)+"T00:00:00Z") + fe.published("-".join(date)+"T00:00:00Z") + stats = os.stat(path) + updated = datetime.datetime.fromtimestamp(stats[stat.ST_MTIME], + datetime.timezone.utc) + fe.updated(updated.strftime('%Y-%m-%dT%H:%M:%SZ')) except ValueError: pass outfile = os.path.join(config.WWW, 'atom.xml')