Skip to content

Commit

Permalink
Fixed #784 -- Atom feeds now use RFC3339 datetime format
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1226 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Nov 14, 2005
1 parent 33b7ef2 commit 7b315b4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions django/utils/feedgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
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)
Expand Down Expand Up @@ -189,7 +192,7 @@ def write(self, outfile, encoding):
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'])
Expand All @@ -211,7 +214,7 @@ def write_items(self, handler):
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:
Expand Down

0 comments on commit 7b315b4

Please sign in to comment.