summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-11-14 04:28:31 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-11-14 04:28:31 +0000
commit7b315b47aa09611ff293fd6cfaf21b86f7045a2b (patch)
tree4fe84b716cd4272e2242a25c6b6607dc319e1478
parent33b7ef290ee0b4a5dbbb4f58b352f63e1b9ed2e8 (diff)
Fixed #784 -- Atom feeds now use RFC3339 datetime format
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1226 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/utils/feedgenerator.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
index fe0f9ce263..86c1a046ec 100644
--- a/django/utils/feedgenerator.py
+++ b/django/utils/feedgenerator.py
@@ -27,6 +27,9 @@ from xml.parsers.expat import ExpatError
def rfc2822_date(date):
return email.Utils.formatdate(time.mktime(date.timetuple()))
+def rfc3339_date(date):
+ return date.strftime('%Y-%m-%dT%H:%M:%SZ')
+
def get_tag_uri(url, date):
"Creates a TagURI. See http://diveintomark.org/archives/2004/05/28/howto-atom-id"
tag = re.sub('^http://', '', url)
@@ -189,7 +192,7 @@ class Atom1Feed(SyndicationFeed):
handler.addQuickElement(u"title", self.feed['title'])
handler.addQuickElement(u"link", "", {u"href": self.feed['link']})
handler.addQuickElement(u"id", self.feed['link'])
- handler.addQuickElement(u"updated", rfc2822_date(self.latest_post_date()).decode('ascii'))
+ handler.addQuickElement(u"updated", rfc3339_date(self.latest_post_date()).decode('ascii'))
if self.feed['author_name'] is not None:
handler.startElement(u"author", {})
handler.addQuickElement(u"name", self.feed['author_name'])
@@ -211,7 +214,7 @@ class Atom1Feed(SyndicationFeed):
handler.addQuickElement(u"title", item['title'])
handler.addQuickElement(u"link", u"", {u"href": item['link']})
if item['pubdate'] is not None:
- handler.addQuickElement(u"updated", rfc2822_date(item['pubdate']).decode('ascii'))
+ handler.addQuickElement(u"updated", rfc3339_date(item['pubdate']).decode('ascii'))
# Author information.
if item['author_name'] is not None: