actually good dates

This commit is contained in:
Jaume Delclòs Coll 2020-10-29 17:00:54 +01:00
parent 19a3eb0297
commit 3a8630f2a7
1 changed files with 7 additions and 1 deletions

View File

@ -37,6 +37,8 @@ from feedgen.feed import FeedGenerator
import os import os
import mistune import mistune
import datetime import datetime
import stat
import time
def publish_atom(entry_filenames, settings): def publish_atom(entry_filenames, settings):
fg = FeedGenerator() fg = FeedGenerator()
@ -66,7 +68,11 @@ def publish_atom(entry_filenames, settings):
fe.author(name=config.USER) fe.author(name=config.USER)
fe.content(html, type="html") fe.content(html, type="html")
try: # crashing because of an invalid date would be sad 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: except ValueError:
pass pass
outfile = os.path.join(config.WWW, 'atom.xml') outfile = os.path.join(config.WWW, 'atom.xml')