From e92f8608664381b6002a025e490588df208234cc Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Tue, 13 Nov 2012 23:48:18 -0500 Subject: fix dates in rss feed --- famille.py | 7 +++++++ templates/rss.xml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/famille.py b/famille.py index 686878b..ab47090 100644 --- a/famille.py +++ b/famille.py @@ -10,6 +10,8 @@ import pytz from docutils import core from docutils.writers.html4css1 import Writer from datetime import datetime +import time +from email import utils from bs4 import BeautifulSoup from flask_mail import Mail, Message import locale @@ -52,6 +54,11 @@ def format_ago(date_object, format): return '{1}'. \ format(iso_format, readable).decode("utf8") +@app.template_filter('format_rfc2822') +def format_rfc2822(date_object): + timestamp = time.mktime(date_object.timetuple()) + return utils.formatdate(timestamp) + @app.template_filter('pluralize') def pluralize(word, count, plural=None): if count == 0: diff --git a/templates/rss.xml b/templates/rss.xml index d0e7caa..82363cb 100644 --- a/templates/rss.xml +++ b/templates/rss.xml @@ -11,7 +11,7 @@ {{news.name}} http://famille.horel.org{{url_for('show_news', news_id=news.id)}} {{news.content_cache}} -{{news.date}} +{{news.date|format_rfc2822}} {{news.id}} {% endfor %} -- cgit v1.2.3-70-g09d2