Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 7b315b47aa09611ff293fd6cfaf21b86f7045a2b 1 parent 33b7ef2
Adrian Holovaty authored November 14, 2005

Showing 1 changed file with 5 additions and 2 deletions. Show diff stats Hide diff stats

  1. 7  django/utils/feedgenerator.py
7  django/utils/feedgenerator.py
@@ -27,6 +27,9 @@
27 27
 def rfc2822_date(date):
28 28
     return email.Utils.formatdate(time.mktime(date.timetuple()))
29 29
 
  30
+def rfc3339_date(date):
  31
+    return date.strftime('%Y-%m-%dT%H:%M:%SZ')
  32
+
30 33
 def get_tag_uri(url, date):
31 34
     "Creates a TagURI. See http://diveintomark.org/archives/2004/05/28/howto-atom-id"
32 35
     tag = re.sub('^http://', '', url)
@@ -189,7 +192,7 @@ def write(self, outfile, encoding):
189 192
         handler.addQuickElement(u"title", self.feed['title'])
190 193
         handler.addQuickElement(u"link", "", {u"href": self.feed['link']})
191 194
         handler.addQuickElement(u"id", self.feed['link'])
192  
-        handler.addQuickElement(u"updated", rfc2822_date(self.latest_post_date()).decode('ascii'))
  195
+        handler.addQuickElement(u"updated", rfc3339_date(self.latest_post_date()).decode('ascii'))
193 196
         if self.feed['author_name'] is not None:
194 197
             handler.startElement(u"author", {})
195 198
             handler.addQuickElement(u"name", self.feed['author_name'])
@@ -211,7 +214,7 @@ def write_items(self, handler):
211 214
             handler.addQuickElement(u"title", item['title'])
212 215
             handler.addQuickElement(u"link", u"", {u"href": item['link']})
213 216
             if item['pubdate'] is not None:
214  
-                handler.addQuickElement(u"updated", rfc2822_date(item['pubdate']).decode('ascii'))
  217
+                handler.addQuickElement(u"updated", rfc3339_date(item['pubdate']).decode('ascii'))
215 218
 
216 219
             # Author information.
217 220
             if item['author_name'] is not None:

0 notes on commit 7b315b4

Please sign in to comment.
Something went wrong with that request. Please try again.