summaryrefslogtreecommitdiff
path: root/makesite.py
diff options
context:
space:
mode:
authorSunaina Pai <sunainapai.in@gmail.com>2018-06-16 16:18:57 +0530
committerSunaina Pai <sunainapai.in@gmail.com>2018-06-16 16:18:57 +0530
commit99c8e268a6c2c75943e1069ff95a5d64e1e19908 (patch)
tree91f5ec5c4e89f60b440d2862317f5f578bcc0758 /makesite.py
parent6c0d374ff14bbe76c8af7e585c8fecd26f25e912 (diff)
Use RFC 2822 format date in RSS feeds
Diffstat (limited to 'makesite.py')
-rwxr-xr-xmakesite.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/makesite.py b/makesite.py
index ce1c9b3..8f4c736 100755
--- a/makesite.py
+++ b/makesite.py
@@ -70,6 +70,12 @@ def read_headers(text):
yield match.group(1), match.group(2), match.end()
+def rfc_2822_format(date_str):
+ """Convert yyyy-mm-dd date string to RFC 2822 format date string."""
+ d = datetime.datetime.strptime(date_str, '%Y-%m-%d')
+ return d.strftime('%a, %d %b %Y %H:%M:%S +0000')
+
+
def read_content(filename):
"""Read content and metadata from file into a dictionary."""
# Read file content.
@@ -101,10 +107,11 @@ def read_content(filename):
except ImportError as e:
log('WARNING: Cannot render Markdown in {}: {}', filename, str(e))
- # Update the dictionary with content text and summary text.
+ # Update the dictionary with content, summary, and RFC 2822 date.
content.update({
'content': text,
'summary': truncate(text),
+ 'rfc_2822_date': rfc_2822_format(content['date'])
})
return content